When I click play button I start noticing that the rotation speed is a lot faster more than in normal Game window of the a game object . Also the player jump is stronger in maximize view . Game : 3d I appreciate your help. Here is the code :
{
transform.Rotate(0, 0.07f, 0);
}
CodePudding user response:
Because your code is completely frame-rate dependent! This means if you run at e.g. 60 frames per second you get around 4.2
degrees per second .. but if for some reason you run suddenly with 120 frames per second you rotate twice as fast!
This won't only happen in the editor itself but in particular in a built application which is most probably run on differently strong devices later.
You always want to use Time.deltaTime
- the time passed since the last frame - to be sure your values are not in value per frame
but rather value per second
transform.Rotate(0, 5f * Time.deltaTime, 0);
you will want to adjust the value according to your needs of course where 5
now actually means 5 degrees per second
regardless of the frame-rate.
(Time.deltaTime
is still dependent on the Time.timeScale
, so in some use cases you even need Time.unscaledDeltaTime
which as the name suggests ignores the time scale and uses actual seconds)
What happens in your specific case is most probably that in a maximized GameView you can render more frames a second since performance is fully concentrated on the GameView and skipping all the Inspector, SceneView (probably the strongest impact), HierarchyView etc repaint overhead.