- Home /
setting Transform.forward results in strange artifact
I want to do this in my update method:
//Look at camera
gameObject.transform.forward = transform.position - Camera.main.transform.position;
content.forward = Camera.main.transform.forward;
Content is the transform of a game object containing UI elements which I want always facing the camera. But when I do that, the UI elements are completely distorted. If I don't set forward, they look ok, just not exactly the orientation I want.
See attachments for actual and expected result.
Answer by g-augview · Dec 29, 2019 at 10:15 PM
I worked around this issue by setting the canvas' game object scale to (.002,.002,.002)
Answer by revolute · Dec 18, 2019 at 01:25 AM
Camera.main.transform.forward is the direction that camera faces at, simply the direction you are looking at. If something needs to be seen, for instance a billboard, it needs to face towards you not towards what you are looking at. Simply change to content.forward = -Camera.main.transform.forward
should do the job.
Thanks @revolute. $$anonymous$$y problem is not the orientation; my problem is that setting the content rotation changes its size too (doing like you said results in the same artifact). I will file a bug unless someone actually tells me this is normal behaviour. Content is a child of a gameobject that has a world space canvas on it; the canvas's scale is (0.002,0.002,1). I might try to make it (0.002,0.002,0.002).