I’m not sure if the version of Mirror that was used in the video contained this, but newer versions of Mirror contain an identically-named script called FaceCamera.cs
that does a similar thing to the script in the video, however it does not set the “up” direction so it doesn’t behave the same way when the camera rotates. So just keep an eye out for that when adding the script to your HealthBar prefab, as you may be given two options.
Also, the maths code here is a little more complicated than it needs to be. Instead of applying rotations to unit vectors as done in the video:
// original code
transform.LookAt(
transform.position + _mainCameraTransform.rotation * Vector3.forward,
_mainCameraTransform.rotation * Vector3.up);
Instead the camera transform’s own axial unit vectors can be directly used:
transform.LookAt(transform.position + _mainCameraTransform.forward,
_mainCameraTransform.up);
But perhaps even simpler, without having to worry about the transform’s world coordinates at all, just make the Health Bar transform “look” in the same direction and rotation as the camera itself, using a function designed for this exact situation:
transform.rotation = Quaternion.LookRotation(_mainCameraTransform.forward,
_mainCameraTransform.up);
This sets the HealthBar’s forward and up vectors to match the camera’s in a combined transformation.