RealDocs

ACharacter::CacheInitialMeshOffset

function Engine Blueprint Since 4.6
#include "GameFramework/Character.h"
Access: public Specifiers: virtualUFUNCTIONBlueprintCallable

Description

Caches the mesh's offset from the capsule so network smoothing can use it as the interpolation target. Called automatically during initialization; call it again at runtime if you intentionally change the mesh offset after construction.

Caveats & Gotchas

  • • Must be called after manually repositioning the mesh at runtime, otherwise network smoothing will interpolate back to the old cached offset and the mesh will appear to snap.
  • • The cached values are stored in BaseTranslationOffset and BaseRotationOffset — reading those properties before calling this will return stale data if the mesh was moved post-construction.
  • • Calling this every tick is unnecessary and wastes CPU; it only needs to be called once per intentional offset change.

Signature

ENGINE_API virtual void CacheInitialMeshOffset(FVector MeshRelativeLocation, FRotator MeshRelativeRotation)

Parameters

Name Type Description Default
MeshRelativeLocation FVector Desired relative location of the mesh from the capsule center. —
MeshRelativeRotation FRotator Desired relative rotation of the mesh from the capsule rotation. —

Return Type

void

Example

Re-cache after repositioning the mesh at runtime C++
// Shift the mesh down for a crouched mesh variant
GetMesh()->SetRelativeLocation(FVector(0.f, 0.f, -70.f));
GetMesh()->SetRelativeRotation(FRotator(0.f, -90.f, 0.f));
CacheInitialMeshOffset(FVector(0.f, 0.f, -70.f), FRotator(0.f, -90.f, 0.f));

Version History

Introduced in: 4.6

Version Status Notes
5.6 stable —

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.