My Quaternion.RotateTowards is instant
Hi short question,
I am using Quaternion.RotateTowards for a smooth rotation, but it doesn't work, because my Quaternion.RotateTowards is always instant (I watched it it takes always only 1 Frame).
"Door.transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, Time.deltaTime * speed);"
My speed can be 1000000.0f or 0.0000001f, it is always done in 1 Frame and I don't get why.
Ttg
uimpag
Answer by Elapse · Apr 11, 2020 at 10:27 PM
I get the same result. Did you found out whats wrong or is it a bug?
Yes I did, for the speed you don't need a number * Time.deltaTime, you just need to call a function which does the "Quaternion.RotateTowards" once and that's it
$$anonymous$$ine looked like this then:
public void OpenDoor(float rotateSpeed) { Door.transform.localRotation = Quaternion.RotateTowards(Door.transform.localRotation, targetRotation, rotateSpeed); }
Thank you for your reply. $$anonymous$$y fault was at a different spot. I tryed to clamp the Quaternion value from my target rotation and it failed. It actually applied the rotation ins$$anonymous$$d of reading it only.
The thing with Time.deltaTime or in my case Time.fixedDeltaTime works as intended when I removed my clamp function. And it should be. Otherwise it applies the rotation in a step = rotateSpeed once per call. in fixedUpdate its still s$$anonymous$$dy, but in your case you can rely on Time.deltaTime for hardware independent rotations in the same speed. I guess its degree per second with delta.
Your answer
Follow this Question
Related Questions
How can I make my game object move like this? 0 Answers
How to smoothly rotate gameobject 20 degrees on key press? 0 Answers
Rotating an object smoothly, towards user inputted Vector3 1 Answer
How to have smooth rotation? 0 Answers
Smooth look at 0 Answers