When the fps decreases, the character starts to run faster

Good afternoon, there was a problem when changing fps in the project, the character also starts to change its speed and jump (as I understand it all depends on the frame rate).
As I understand it, everything must be multiplied by Time.deltaTime
but to be honest I don’t know where
Here is the part of the code responsible for walking and jumping.

private void On_PlayerMovement(){
                if(Input.GetAxis("Horizontal") != 0){
                        Vector2 localvelocity;
                        localvelocity = transform.InverseTransformDirection(RB2B.velocity)  ;
                        localvelocity.x = Input.GetAxis("Horizontal") * Time.deltaTime * PlayerSpeed * 100 * CalculateAngularSpeedLimitation();
                        RB2B.velocity = transform.TransformDirection(localvelocity);

                        anim.SetBool("PlayerMoving", true);
                }
                else { //Slow down the player when no pressure on the Horizontal Axis (For more responcive controls).
                       
                        Vector2 localvelocity;
                        localvelocity = transform.InverseTransformDirection(RB2B.velocity) ;
                        localvelocity.x = localvelocity.x * 0.5F;
                        RB2B.velocity = transform.TransformDirection(localvelocity);

                        anim.SetBool("PlayerMoving", false);
                }
        }

        private void On_PlayerJump(){
                if(Input.GetButtonDown("Jump")){
                        if(JumpCount != 0){
                                Vector2 localvelocity;
                                localvelocity = transform.InverseTransformDirection(RB2B.velocity) ;
                                localvelocity.y = 0;
                                RB2B.velocity = transform.TransformDirection(localvelocity);
                                JumpCount --;
                                RB2B.AddRelativeForce(new Vector2(0,1) * JumpSpeed * 10, ForceMode2D.Impulse);
                        }
                }
        }

All these classes are called in update

localvelocity.x = localvelocity.x * 0.5F * Time.deltaTime;

// you may need to change * 0.5F to * 5F or more, since movement will be a lot slower, as Time.deltaTime should be a very small number.

Velocity is Distance/Time. Anything related with Time should be multiplied by Time.deltaTime to account for framerate change.

1 Like

If you’re moving something by a certain distance per frame then you want to multiply that amount by time.deltaTime. Multiplying a rigidbody’s velocity by time.deltaTime makes no sense though so don’t do that. Velocity is distance over time already so the time is already accounted for. The physics engine already handles that.