Hello guys, today i built my game and find out that rotation speed is dependent on FPS(frames per second), when i test on pc with 144 fps rotation speed is too fast, when on 60 fps, it is all ideal, but when on 30fps it is too slow rotation. I want to ask if it is possible for a lines of rotation code to be dependent on FPS, even when i dont want to, I also found out that .entity.translate is dependent too.is there a way i can disable such thing?
I see that you’re adding dt in your rotate time in your rotate script. Try multiplying both your rotate and translate values by dt instead. This should give you a consistent speed regardless of frame rate .
dt in the update(dt) method gives you a delta time, in other words time passed since last frame. It will have more or less the same value at constant FPS, but if you compare dt between 60 FPS and 30, it will be twice as low.
When you do interpolation between 2 quaternions with slerp(from, to, step), step should be from 0 to 1 (0% to 100%). If you have step as a contant value, let’s say 0.1, then each frame the rotation will be moved by 10% (fist from 0% to 10% of the total, then from 0% to 10% of the remainder, then from 0% to 10% of the remainder of the remainder, etc, until you reach the target).
Now, when you do a slerp you also want to take the time since last frame into consideration. That way, the less time passed, the smaller the step should be, the more time passed, the larger the step. One option is to multiply your step by dt. The faster the frame is rendered, the smaller dt will be and as a result the smaller the interpolation step will be.