Unity 5 - make a GameObject UI to follow a GameObject in a 3D environment?

Hi guys, I am making a first-person 3D game with lots of interactive objects and I am wondering if it is possible in Unity to make a UI follow the position of the object while it is being moved. The UI should also stay flat while facing the screen, as if it were projected from the camera, regardless of the Player’s rotation. I hope to make it similar with the UI of the game ‘Layers of Fear’. Any help will be appreciated. Thanks!

If you want a constant screen position (like a normal FPS health bar gui), you can simply create the element on a canvas that’s set to Screen Space - Camera or Overlay.

If you want the UI to follow an object in world space, you can still use a canvas. Use your current camera’s WorldToScreenPoint method to find what coordinates on the screen the object should have to be over the thing in the world.

2 Likes

I followed what you said and it worked! Thanks a lot!