RealDocs

AActor::SetActorLocation

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

Description

Sets the world-space location of the actor. If bSweep is true, the movement will collide with the world and stop at the first blocking hit, returning false if blocked.

Caveats & Gotchas

  • Returns true if the move was fully completed, false if blocked by a sweep collision.
  • Using `ETeleportType::TeleportPhysics` is required when teleporting physics-simulated actors to avoid incorrect velocity transfer.
  • In multiplayer, location changes on the server are automatically replicated if `bReplicateMovement` is true.

Signature

bool SetActorLocation(const FVector& NewLocation, bool bSweep = false, FHitResult* OutSweepHitResult = nullptr, ETeleportType Teleport = ETeleportType::None)

Parameters

Name Type Description Default
NewLocation const FVector& The desired new world-space location.
bSweep bool If true, sweeps through physics and stops at the first blocking hit. false
OutSweepHitResult FHitResult* If sweep is enabled, populated with the hit result. nullptr
Teleport ETeleportType Whether to teleport physics state (ResetPhysics) or maintain velocity (None). ETeleportType::None

Return Type

bool

Examples

Move this actor to a fixed location when another actor overlaps it Blueprint
Event Actor Begin Overlap Other Actor Set Actor Location Target is Actor Target New Location Sweep false Teleport true Return Value Sweep Hit Result Make Vector X 0.0 Y 0.0 Z 1000.0 Return Value Return Value
Edit Blueprint graph Move this actor to a fixed location when another actor overlaps it
Drag node headers to move · Drag from an output pin to an input pin to connect · Scroll to zoom · Right-click for actions
Teleporting an actor C++
// Instant teleport, no collision check
MyActor->SetActorLocation(FVector(0.f, 0.f, 500.f));

// Sweep: stop at first obstacle
FHitResult Hit;
bool bMoved = MyActor->SetActorLocation(TargetLocation, true, &Hit);
if (!bMoved)
{
    UE_LOG(LogTemp, Warning, TEXT("Blocked by: %s"), *Hit.GetActor()->GetName());
}

Version History

Introduced in: 1.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.