x


using slerp

having trouble getting this right can someone explain this better

im tring to use this code to get a gameobject to face another that is moving the code below is what im tring. i don't want smooth follow as smoothing i dont think can be seen. the trouble im having is the first part of the slerp, the transform.position, i tried transform.rotation also.

transform.rotation = Quaternion.Slerp(transform.position, target.position);
more ▼

asked May 30 '12 at 02:23 AM

bodec gravatar image

bodec
356 6 13 18

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

1 answer: sort voted first

To if you want a game object to face another one, no smoothing, you can just do transform.LookAt(target);

You would Slerp to smooth it:

  transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(target.position-transform.position), t);

Where t is a number between 0 and 1 that you normally use a time calculate to update. t=1, it's at the target rotation, t=0 it's the start rotation.

more ▼

answered May 30 '12 at 02:30 AM

whydoidoit gravatar image

whydoidoit
33k 11 23 98

Awsome THANK YOU so much works great!!!!!!

May 30 '12 at 02:37 AM bodec
(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:

x5058

asked: May 30 '12 at 02:23 AM

Seen: 348 times

Last Updated: May 30 '12 at 02:37 AM