|
Hello there. I've been trying to make a script that allows NPC to look at the character when they are in the trigger zone. So far I have been able to make them do so, but whenever the character goes out of the zone, the NPC snaps back to the initial position immediately. How do I smooth out the movement? This is the script I'm using. Thanks in advance.
(comments are locked)
|
|
I use iTween for basic look rotations and turning. Very easy to use to make simple damped turning of objects and some other stuff. Hope it helps you out.
(comments are locked)
|
|
Thanks for the answers. I actually scrapped most of the previous script and figured out this script which works. And now I just need to make the LookAt smooth instead. //returns the object to initial rotation else head.transform.rotation = Quaternion.Slerp (head.transform.rotation, target, Time.deltaTime * speed); } I just started scripting today and I am really trying to figure out most stuff.. and my head is quite overloaded now. Thanks again for the quick answers!,Thanks for the answers. I actually scrapped most of the previous script and figured out this script which works. And now I just need to make the LookAt smooth instead. I just started scripting today and I am really trying to figure out most stuff.. and my head is quite overloaded now. Thanks again for the quick answers!
(comments are locked)
|

there are several things wrong with this script. First thing Quaternion does not have variable for rotation. So the values in your Lerp won't work. Next you are never setting "last" so your lerp does nothing except set the rotation back to Quaternion.identity. Also in OnTriggerExit you are setting your "head.transform.rotation = last" which is setting it to Quaternion.identity. Adjustments to these issues.