I am having a hell of a time trying to get a simple plane to face the camera. I have tried everything in all of the following posts:
- http://answers.unity3d.com/questions/192331/make-an-instantiated-plane-face-the-camera-at-all.html
- http://wiki.unity3d.com/index.php?title=CameraFacingBillboard
- http://answers.unity3d.com/questions/52656/how-i-can-create-an-sprite-that-always-look-at-the.html
To try to isolate the problem, I have a scene with nothing but a light, a plane with a JavaScript attached, and a camera.
First I tried this code:
transform.LookAt(Camera.main.transform.position, Vector3.up);
When I put this into the Update function of a JavaScript and slap it on the plane, it rotates! But the edge is always facing the camera rather than the face.
Then I tried several variations of the code described in the CameraFacingBillboard wiki post, including both of the C# scripts.
transform.LookAt(transform.position+Camera.main.transform.rotation*Vector3.right,Camera.main.transform.rotation*Vector3.up);
or
transform.LookAt(transform.position + Camera.main.transform.rotation * Vector3.back,Camera.main.transform.rotation * Vector3.up);
This method seems more accurate, but when I try them, almost nothing at all happens. The plane rotates 90 on the y axis, and then just doesn’t respond to the camera
I’m somewhat new to Unity so it’s probably something simple. Help greatly appreciated.