Download

Getting HMD position and orientation for hud elements

Hi guys, i’m currently trying to add the ability to spawn an object in front of the player to give them an alert, be it “Out of ammo” or something like that. To do that i need to get the location and rotation of the HMD and then spawn an object at that location plus the forward vector multiplied by an amount.

This is what i have tried:

This rotates the sphere i am moving quite nicely but there is a few big issues. One is that it doesn’t care what way i am facing, the x,y position of the sphere is based only on where i am stood in the playspace, and the coordinates are exagerated so it doesnt track my position properly. It is also keeping the sphere a little bit above my head no matter what, even if i hold the HMD upside down.

Has anyone tried this and found a fix or good way to implement it?

The forward vector in your room space wont always align with world space. You should get the Cameras world location and add the cameras forward vector * desired distance to set the world location. You could also always attach the out of ammo indicator to the camera and just give it some distance in front of the camera, this would keep it in front of the camera as the player moved their head, otherwise the player might be rotating their head our running when it appears and fail to see it. You will need to keep the camera locked to HMD for this to work iirc.

i did something along these lines to add a hidden reload box for my guns. So when out of ammo you just bring your guns down to your hips and it reloads. I can post my blueprint after work…so far what I’ve done has worked out great for me.

Don’t worry, i’ve figured it out, if I get the player pawns location instead of the camera manager it works perfectly

I would appreciate a look at your solution, if you don’t mind.

@wivy1 no problem i can grab it after work. 8:45 in texas right now. so sometime after 5pm ill be able to grab it.