AActor::TeleportTo
#include "GameFramework/Actor.h"
Access: public
Specifiers: virtual
Description
Moves this actor to a destination location and rotation, attempting to push it clear of overlapping geometry if it does not fit exactly at the target point.
Signature
virtual bool TeleportTo(const FVector& DestLocation, const FRotator& DestRotation, bool bIsATest=false, bool bNoCheck=false) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| DestLocation | const FVector& | The target world-space location to teleport to. | — |
| DestRotation | const FRotator& | The target world-space rotation to adopt at the destination. | — |
| bIsATest | bool | When true, the actor is not actually moved — only the feasibility of the teleport is tested. Used by AI pathfinding. | false |
| bNoCheck | bool | When true, skips all encroachment and collision checks and moves unconditionally. | false |
Return Type
bool Caveats & Gotchas
- • Returns false if no valid placement is found at or near the destination — the actor does not move in that case.
- • Unlike SetActorLocation(), TeleportTo() accounts for the actor's collision shape when finding a valid landing spot, making it more reliable for character teleportation.
- • For a simple unconditional teleport, use SetActorLocationAndRotation() with ETeleportType::TeleportPhysics to preserve physics velocity.
Example
Teleport a character to a spawn point C++
AActor* SpawnPoint = GetSpawnPoint();
if (SpawnPoint)
{
bool bSuccess = TeleportTo(SpawnPoint->GetActorLocation(), SpawnPoint->GetActorRotation());
if (!bSuccess)
{
UE_LOG(LogGame, Warning, TEXT("TeleportTo failed — destination may be blocked."));
}
} Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?