x


Set Rotation Angle

I know this will sound very simple, but how do you set the angle of an object instead of a continuous rotation like Rotate(). I want to figure out the angle the mouse is from the center of the screen and set the y angle of an object to that mouse's angle.

more ▼

asked Jan 19 '11 at 01:29 AM

gatorules gravatar image

gatorules
15 2 2 6

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

1 answer: sort voted first

To set an object's rotation 'from scratch', you can make an assignment to the Transform 'rotation', 'localRotation', 'eulerAngles', or 'localEulerAngles' field, whichever is appropriate.

Unless the object is a child object of another object, you'll probably want to use 'rotation' or 'eulerAngles'. Of these, 'eulerAngles' is probably closest to what you want, as it allows you to specify the angles of rotation directly without any intermediate steps.

more ▼

answered Jan 19 '11 at 01:38 AM

Jesse Anders gravatar image

Jesse Anders
7.3k 7 17 48

(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:

x2155
x720
x286

asked: Jan 19 '11 at 01:29 AM

Seen: 3641 times

Last Updated: Jan 19 '11 at 01:29 AM