AActor::GetVerticalDistanceTo
#include "GameFramework/Actor.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallableconst
Description
Returns the absolute vertical (Z-axis only) distance between this actor and OtherActor, ignoring XY. Useful for height-difference checks such as detecting whether a target is above or below a platform.
Caveats & Gotchas
- • Returns the absolute value of the Z difference — you cannot determine which actor is higher without comparing their Z locations directly.
- • Does not guard against a null OtherActor — passing null will crash.
Signature
ENGINE_API float GetVerticalDistanceTo(const AActor* OtherActor) const; Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| OtherActor | const AActor* | The other actor to measure vertical distance to. | — |
Return Type
float Example
Check if player is significantly above or below an actor C++
float HeightDiff = SomeActor->GetVerticalDistanceTo(Player);
if (HeightDiff > 500.f)
{
UE_LOG(LogTemp, Log, TEXT("Player is far above or below"));
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?