Ok GetCurrentOrientationAndPosition gives me position “RELATED” to the character! I guess there is no way to get the world position right? i will just have to add it to the character position.
Ok GetCurrentOrientationAndPosition gives me the position relative to the character and will not change if the character is rotating, so just adding them would do the trick, why is there no simple “GetWorldPosition” function ?! Isn’t it obvious that the world position is one of the most wanted value developers will look for between all that functions in that big list?
I need to make some actor to look at me, why does it have to be so difficult?
Use camera location. In VR, the camera location and rotation end up being the actual HMD. That should help you. Its what im doing to trace the view target and use the head to aim.
Just get CameraManager->GetCameraLocation() to get the world location of the camera, in VR, its also the updated camera with the HMD offsets.
You were indeed right, so i went and tried to find a way to get it to work
and found it.
FVector Loc;
FQuat quat;
//get local space HMD orientation
GEngine->HMDDevice->GetCurrentOrientationAndPosition(quat, Loc);
//get player controller
APlayerController *PlayerController = Cast<APlayerController>(Controller);
//rotate the local space hmd position, then sum the camera 0 location to it
FVector finalloc = GetActorRotation().RotateVector(Loc) + PlayerController->PlayerCameraManager->GetCameraLocation();
You get the local position of the HMD, then rotate it with your current pawn rotation, then you add the camera location to it. We use actor rotation and not camera rotation becouse the camera rotation actualy DOES change with the HMD rotation, we want the “Zero” rotation, so we get the pawn one.
In this, finalloc ends up being the final HMD position in world rotation, exactly in the middle beetween both eyes. This is on a vehicle-like oculus implementation, where the pawn doenst turn when you turn the head.