-
Trying to figure out how to use Quat Slerp and other functions in SK. I could not find any demonstration in the SK demo for this function. I am trying to transform and rotate model based on where the user is in an environment, sort of like "follow-me" concept. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Slerp is just a higher quality lerp for Quaternions. It blends between two different Quaternions while preserving some of the spherical properties! You'd use it kinda like this: Quat start = ...;
Quat destination = ...;
float percentage = ...;
Quat current = Quat.Slerp(start, destination, percentage); Or for like a smoothed chasing sort of behavior: Quat destination = ...;
Quat current = ...;
float followPower = 16; // Somewhat arbitrary, higher is snappier
current = Quat.Slerp(current, destination, followPower * Time.Stepf); |
Beta Was this translation helpful? Give feedback.
-
In the first suggestion above are start and destination set "outside" the Update loop and just the percentage changing? In the second suggestion is seems that destination is maybe some point in space relative to the current head position? I guess I'm trying to figure out how it works in the bigger picture of the Update loop. In my experiments it doesn't do anything or I can't find where it went. |
Beta Was this translation helpful? Give feedback.
-
Thanks! Now it makes sense. |
Beta Was this translation helpful? Give feedback.
Here's a complete application for context:
And here's what it looks like in action: