Slerp ignoring time component?
Hi,
Here's my problem; Regardless of the value of "t" argument, the function produces nearly instant 90° rotations (no smoothing)?
Quaternion or Vector3 slerp have the same behavior... (Commented in code)
The lerp part perfectly interpolates smoothly to different "t" values using the same time variables...
I tried simple floats values like "0.00001f" to try to get something very slow in there as well... same behavior :/
Any idea?
bool lerpOn = false;
bool slerpOn = false;
Vector3 lerpDest;
Vector3 curPos;
Transform from;
Transform to;
float startTime;
float movSpeed = 0.5f;
float rotSpeed = 0.5f;
void Update () {
if (lerpOn) {
transform.position = Vector3.Lerp (curPos, lerpDest, (Time.time - startTime) / movSpeed);
if (Vector3.Distance (Camera.main.transform.position, lerpDest) < Vector3.kEpsilon) {
lerpOn = false;
}
}
if(slerpOn){
transform.rotation = Quaternion.Slerp(from.rotation, to.rotation, (Time.time - startTime) / rotSpeed);
//transform.position = Vector3.Slerp(from.position, to.position, (Time.time - startTime) / rotSpeed);
if (Vector3.Angle (Camera.main.transform.position, to.position) < Vector3.kEpsilon ){
slerpOn = false;
}
}
}
Answer by Flavor · Aug 16, 2016 at 09:44 AM
"to" & "from" seemed to both reference the transform the script was attached to.
When I changed the "to" to create a destination, it changed the from at the same time since they were referring to the same object.
Anyhow, that's what I gathered from the debugging I went thru.
Case closed! :)
Your answer
Follow this Question
Related Questions
How to use Quaternion.Slerp with transform.LookAt? 3 Answers
GameObject Smooth Movement 0 Answers
Opening door script in C# 3 Answers
Object rotation naturally change 0 Answers
Cannot implicity convert type 'UnityEngine.Vector3' to 'UnityEngine.Quaternion' 1 Answer