Hey guys. Recently, I added a health bar above my character in the 3D world, and I have been struggling with how to let it always face the camera. It is easy to get a vector from the health bar to the camera, but how could I convert it into euler angles?
You can use Transform.LookAt - Unity - Scripting API: Transform.LookAt
Better use Quaternion.LookRotation - Unity - Scripting API: Quaternion.LookRotation
If you don’t want to consider y direction you can set it to 0 (new Vector3(x,0,z)). Or use Vector3.ProjectOnPlane … and set as normal your up direction.
Remember to normalize directions.