My game seems to be running too fast for certain tasks
Hi
I recently just opened up an older project on my new computer and I've noticed a few things broke. I've always gotten around 45 FPS and everything worked perfectly but now when I get around 300, according to the editor, it is almost impossible to jump and the mouse sensitivity is so unstable. So in other words, I need to make the game frame rate independent. But I am not sure how I would go about this.
Here's some of my code.
Here's to handle the mouse movement.
mouseInput = new Vector2(Input.GetAxis(mouseX), Input.GetAxis(mouseY)) * mouseSensitivity * Time.deltaTime;
And here's most of the code related to the Y direction when moving, also known as "jumping". Please note that I've only used certain parts and they are all spread out over a bigger script.
//Sets the move direction y-axis to the desired jump speed variable. This is called when the space bar is pressed.
moveDirection.y = jumping.jumpSpeed;
//This is called in Update and if the player is grounded. It makes the player stick to the floor.
moveDirection.y = -other.groundStick;
I've tried to call the ground stick function in fixed update and it makes a small difference but there are still sometimes where the player refuses to jump.
But there is also some "spooky" part about this. I have another project that uses this exact same setup and there everything works fine. I get about the same FPS there.
So any help with converting the code to be framerate independent this is greatly appreciated!
Your answer
Follow this Question
Related Questions
Mouse movement disables Vsync (leading to very bad stuttering) 0 Answers
Mouse Input for Build Mode Windows are switched 0 Answers
Detect mouse inputs when the scene is changing to another scene. 2 Answers
Player input independent of frame rate? 1 Answer
Mouse cannot move when key is held down 0 Answers