Alternative display style

If you prefer the bar to be on the same axis as the camera, regardless of character orientation, just modify the script;

        private void LateUpdate() {
            transform.forward = -Camera.main.transform.forward;
        }
13 Likes

A good tip, thank you.

Isn’t it transform.forward = Camera.main.transform.forward;?
For me the - flips it all around

1 Like

@Phoque That’s a little strange. Usually a canvas’ forward vector points away from the camera. That is, in the same direction as we are looking. If you run the code supplied without the -, the canvas will flip around an look towards us which inverts everything in it. By negating the camera’s forward vector, we turn the canvas back around

You’re right, it might be the case.
I should use the invert parameter to handle all cases.

transform.forward = (invert ? 1 : -1) * cameraTransform.forward;

Thanks

5 Likes

Another working method without additional checks
private void LateUpdate() { transform.rotation = _cameraTransform.rotation; }

2 Likes

I was just thinking about this and saw your post. Thank you!

I also really like your visuals e.g. unit selected, that bluish debug grid. Do you mind sharing?

Hi, these visuals are from the original Synty Polygon Prototype pack.
With this course, only a few assets from this pack are offered.
Visit the Unity Asset Store or Synty Studios store, for more details.
(I don’t think I’m allowed to post links here…)

1 Like

That depends on the context. To help others find information related to the post, they’re generally fine.

1 Like

Privacy & Terms