x


LookAt something while rotating on z?

How do you get an object to do a LookAt while enabling transform.rotate on its z? I just realized that using LookAt forces the y axis to look upward, disabling the possibility for rotating on the z axis. I need the object to to both at the same time in Update.

Thanks

more ▼

asked Jun 09 '12 at 06:46 AM

superventure gravatar image

superventure
634 44 53 63

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

1 answer: sort voted first

LookAt has an optional 2nd parm for the local y-axis, which merely defaults to world-Y. To sort of preserve the current up, could do:

Vector3 oldY = transform.up;
transform.LookAt(target, oldY);
more ▼

answered Jun 09 '12 at 07:37 AM

Owen Reynolds gravatar image

Owen Reynolds
11.2k 1 7 45

this still locks the y axis. It wont rotate still.

Jun 12 '12 at 03:10 PM superventure
(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
x1274
x327
x322
x17

asked: Jun 09 '12 at 06:46 AM

Seen: 482 times

Last Updated: Jun 12 '12 at 03:10 PM