AActor::GetActorLocation

Returns the location of the RootComponent of this Actor

Windows
MacOS
Linux

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/GameFramework/Actor.h

Include

#include "GameFramework/Actor.h"

Syntax

FVector GetActorLocation() const

Remarks

Returns the location of the RootComponent of this Actor

Example Code

ShooterProjectile.cpp at line 118:

void AShooterProjectile::OnRep_Exploded()  
{  
    FVector ProjDirection = GetActorForwardVector();  

    const FVector StartTrace = GetActorLocation() - ProjDirection * 200;  
    const FVector EndTrace = GetActorLocation() + ProjDirection * 150;  
    FHitResult Impact;  

    if (!GetWorld()->LineTraceSingleByChannel(Impact, StartTrace, EndTrace, COLLISION_PROJECTILE, FCollisionQueryParams(SCENE_QUERY_STAT(ProjClient), true, Instigator)))  
    {  
        // failsafe  
        Impact.ImpactPoint = GetActorLocation();  
        Impact.ImpactNormal = -ProjDirection;  
    }  

    Explode(Impact);  
}  

MyActor.cpp at line 94:

    // Get the current location  
    FVector ActorLocation = GetActorLocation();  
    // Move it slightly  
    ActorLocation.Z += 10.0f;  
    // Set the location- this will blindly place the actor at the given location  
    SetActorLocation( ActorLocation, false );
Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback