RealDocs

AActor::AddActorLocalOffset

function Engine Since 4.0
#include "GameFramework/Actor.h"
Access: public

Description

Moves the actor by a delta offset expressed in the actor's local space. Use this instead of AddActorWorldOffset when the movement direction should be relative to the actor's current orientation.

Caveats & Gotchas

  • • DeltaLocation is in local space. Passing a world-space delta will give incorrect results if the actor is rotated. Use AddActorWorldOffset for world-space deltas.
  • • When used on a physics-simulating actor without ETeleportType::TeleportPhysics, physics will override the position immediately. Use AddForce or SetPhysicsLinearVelocity for physics actors.
  • • Calling this every frame with bSweep=true is expensive. Profile when used on large numbers of actors.
  • • Blueprint-exposed equivalent is K2_AddActorLocalOffset.

Signature

void AddActorLocalOffset(FVector DeltaLocation, bool bSweep=false, FHitResult* OutSweepHitResult=nullptr, ETeleportType Teleport = ETeleportType::None)

Parameters

Name Type Description Default
DeltaLocation FVector Offset in the actor's local space to apply. —
bSweep bool If true, sweeps through the world for collision, stopping at the first blocking hit. false
OutSweepHitResult FHitResult* Optional output populated with sweep hit data when bSweep is true. nullptr
Teleport ETeleportType Controls physics velocity reset behaviour. ETeleportType::None

Return Type

void

Example

Move forward in local space each tick C++
void AMyActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	AddActorLocalOffset(FVector(100.f * DeltaTime, 0.f, 0.f));
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable —

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.