AActor::SetActorLocationAndRotation
#include "GameFramework/Actor.h"
Access: public
Description
Sets the actor's world location and rotation in a single call, which is more efficient than calling SetActorLocation and SetActorRotation separately because it only triggers one transform update.
Signature
bool SetActorLocationAndRotation(FVector NewLocation, FRotator NewRotation, bool bSweep=false, FHitResult* OutSweepHitResult=nullptr, ETeleportType Teleport = ETeleportType::None) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| NewLocation | FVector | New world-space location. | — |
| NewRotation | FRotator | New world-space rotation. | — |
| bSweep | bool | If true, sweeps through the world for collision, stopping at the first blocking hit. | false |
| OutSweepHitResult | FHitResult* | Optional output hit result populated when bSweep is true. | nullptr |
| Teleport | ETeleportType | Controls whether physics velocity is reset and whether overlap events are generated. | ETeleportType::None |
Return Type
bool Caveats & Gotchas
- • Returns false if the actor was blocked by sweep collision and was not fully moved to the target transform.
- • When bSweep is false and ETeleportType::None is used, physics bodies may generate a large velocity spike on the next physics tick if the displacement is large. Use ETeleportType::TeleportPhysics to avoid this.
- • Does not work correctly on simulating physics actors when bSweep is true — the physics simulation will override the position on the next tick.
- • The Blueprint-exposed equivalent is K2_SetActorLocationAndRotation. A FQuat overload also exists for higher-precision rotations.
Example
Teleport an actor to a new transform C++
MyActor->SetActorLocationAndRotation(
FVector(100.f, 200.f, 50.f),
FRotator(0.f, 90.f, 0.f),
false,
nullptr,
ETeleportType::TeleportPhysics
); See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?