AActor::SetActorLocation
#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
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());
} Tags
Version History
Introduced in: 1.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?