why does the quaternion slerp occur instantly?

void OnTriggerEnter (Collider other) {
if (other.tag == “swordrange”) {
rb.angularVelocity = new Vector3 (0f, 0f, 0f);
while (Quaternion.Angle(transform.rotation,qt)>.1f) {
transform.rotation = Quaternion.Slerp (transform.rotation, qt, .01f * Time.deltaTime);
}
}
}
qt is a quaternion value I stored from before, currently the object rotates to the quaternion qt but it does it instantly, any help?

Slerp is a math function which does a spherical linear interpolation from one quaternion to another. Slerp is more complicated but here is the lerp function (pseudo-code)

lerp(a, b, d)
{
    return (a * (1 - d) + b * d);
}

Which means your last parameter should be in range [0, 1].
I’m not sure I understand what’s your problem is.

Edit:
Oh, I missed the while cycle. You’re doing the interpolation while the angle between the two quaternion is bigger than an amount. Put that section into the update / fixedupdate / lateupdate with replacing the while with an if statement.

OnTriggerEnter is only called once when an object enter in it so you should use Coroutine launched in OnTriggerEnter

Edit: Alucardj was faster and more accurate ^^

In line 4 change “while” to “if”. I believe that what you expected, because your while will be executed until angle between your Object and qt object won’t be lower than .1f - that’s what you stated in your code. Also you should move that to some continuously running function like for example Coroutine or Update/FixedUpdate (depending on what you expect).

P.S. If you’ll want to restrict other movements while you rotate you can just add some boolean variable (for example let it be iRotating) and do something like that:

//in your trigger enter:
if (Quaternion.Angle(transform.rotation,qt)>.1f) iRotating = true;

//then in your continuously running function:
if (iRotating)
{
transform.rotation = Quaternion.Slerp (transform.rotation, qt, .01f * Time.deltaTime); //note that you shouldn't use deltaTime variable in functions that doesn't rely on frames
if (Quaternion.Angle(transform.rotation,qt)<.1f) iRotating = false;
}

//and then just wrap your other movements in:
if (!iRotating)