Quantcast
Channel: Questions in topic: "quaternion.slerp"
Viewing all articles
Browse latest Browse all 133

Getting a smooth rotation with Quaterminions slerp in IEnumerator

$
0
0
I'm trying to get an AI character to follow me around and I'm having some trouble getting him to face the object he is chasing. Here's my code. IEnumerator UpdatePath() { float refreshRate = .25f; while (target != null) { hasTarget = true; Vector3 targetPosition = new Vector3(target.position.x, 0, target.position.z); pathfinder.SetDestination(targetPosition); Quaternion rotation = Quaternion.LookRotation(target.position - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.time * turnSpeed); yield return new WaitForSeconds(refreshRate); } } Right now it's very janky. Every time the cycle repeats he snaps to face me instead of getting a smooth turn. is this somethin I should use Update for? or is there a better way. What do I need to do?

Viewing all articles
Browse latest Browse all 133

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>