Download

How to Get Player Location for Augmented Reality Application

I am starting from the AR template in UE4 and am trying to create an actor component which gets the location of the owner. My implementation works fine for actors added to the level that I move around with the UxtGenericManipulator. However, if I try to do this on the active player the found location stays locked at the player start. I’ve tried, for example, to add my actor component to the pawn blueprint to no avail.

I think I’ve tracked the issue down to the point that it is the UxtInputSimulationActor which is actually the actor moving around the level (doesn’t exist, I think, until the game is started).

Question: How do I get access to that actor? Either from Blueprint of c++? Below is how I am currently doing it in C++.

FVector m_location = GetOwner()->GetActorLocation();

or

FVector m_location = GetWorld()->GetFirstPlayerController()->GetPawn()->GetActorLocation();

image