- Home /
How do I rotate accurately over time while ignoring other axis's?
I have a rotation that I want to happen over time, but can't really use slerp or lerp (as far as I know), because I need to allow for dynamic movement and rotation over that period. I've currently been using function with a regular transform.rotate along with a countdown using a comparison between a float variable and time.deltatime, but it does not grant me the accuracy that I need as when the function is called several times. I just need it to move along the world axis, with which the function works fine short of this problem. I've tried several fixed and unfixed variants to make it more accurate, but It's not working.
Using slerp earlier caused the player to be trapped in limbo, constantly moving toward the target rotation, but not being able to leave it. It's also very inefficient since I just want to rotate it a set amount without restricting the other rotations of the player, which I can't seem to with (s)lerp; I don't know how to get it to ignore the other axis's.
function Update() {
if (rotateBackFlip == true){
if (backFlipTime > 0){
targetScript.myPlayer.Rotate(Vector3.right * degreesPerSecond * Time.deltaTime , Space.World);
backFlipTime -= Time.deltaTime;
}
}
}
I don't quite understand what you're asking and want to get some clarification before I try and answer. Your trying to get an object to rotate (around a point, or around one of its axis?) over time? And what do you mean by accuracy? Are you talking about the degrees rotated, time to rotate, etc?
Getting accurate rotation around some axis and at the same time allow rotation in the other axes doesn't make much sense: the rotations are combined and the result is absolutely unpredictable for any human $$anonymous$$d!
I have on object rotated along the world axis - not its own, nor around a point - so that it can move along its local rotations while it's being rotated, and it's working fine in that regard. Deltatime, however, isn't accurate enough to end up being rotated the full 90/180 degrees that it's multiplied with every time, sometimes less, sometimes more. i'm sure if this has something to do with the way the time and numbers are updated, but it's just not accurate enough.
Your answer
![](https://koobas.hobune.stream/wayback/20220613084827im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Programming Accurate Clock Hands 1 Answer
Rotating around the Y axis then on Z axis makes my object rotate on the X axis 1 Answer
Spinning a sphere, like a globe. 1 Answer
90 Degree stopping rotation on y-axis issue 0 Answers
LookAt on one axis 2 Answers