Transform.LookAt - wrong vector


i ve created a gameobject with a simple plane. The material is a transparent/vertexlit and i gave it simple 2d-grafic as the base-texture. Now ive added the following script/code.

private void Update(){

If i run the gamemode, the texture always has the wrong rotations, so ive never see it. All these gameobjects should everytime directly face up to my orbit-camera. Unfortunately ive too few knowledge about vector-math, so therefore it would be great to get some hints on that..

thanks a lot,

Might be that the plane doesn't have the forward direction you're thinking it does. If I remember correctly the lookat function uses the forward vector which I think is the positive z axis for the game object (might be x but IIRC I think x is 'right').

So depending on how you set up the plane it might be looking in the right place, but on it's side so you only see the edge and therefor might not actually 'see' it.

If that's the case you can either fix the plane's rotation in max/blender/what have you, or you can stick it it in an empty gameobject and orient it properly as a child then stick the rotation code on the parent gameobject.

Hope that helps, if you need clarification on anything let me know.


Try using transform.rotation = Camera.main.transform.rotation

Sprites and Planes are very often made so that they face the camera when oriented the same way

Try comparing what you're doing to this script:

Not sure if you created your own plane or not, but if you did, you might have assigned the vertices in the wrong order. Try reversing the direction you assign the points in i.e. clockwise instead of counter-clockwise or vice-versa.