x


Stop camera rotation when x axis = 90

I'm using the following code to rotate a camera while looking at an object. I'm having some real problems trying to stop the camera when the camera's x axis =90 degrees. I can't find out how to reference this value that I can see in the inspector...

var target : Transform;

    function Update() {
        transform.RotateAround (Vector3.zero, Vector3(1,0,0), 5 * Time.deltaTime);
        transform.LookAt(target);
    }
more ▼

asked Apr 26 '12 at 07:05 PM

valichm gravatar image

valichm
136 19 22 27

(comments are locked)
10|3000 characters needed characters left

1 answer: sort newest

You can access the x,y,z of rotation through the euler functions:

http://unity3d.com/support/documentation/ScriptReference/Transform-eulerAngles.html

http://unity3d.com/support/documentation/ScriptReference/Quaternion-eulerAngles

This article should be very helpful in learning how transform.rotation relates to the Euler angles you see in the inspector:

http://answers.unity3d.com/questions/48609/whats-the-difference-between-rotation-eulerangles.html

more ▼

answered Apr 26 '12 at 08:08 PM

Julien.Lynge gravatar image

Julien.Lynge
7.4k 20 25 51

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3010
x2168
x143

asked: Apr 26 '12 at 07:05 PM

Seen: 810 times

Last Updated: Apr 26 '12 at 08:08 PM