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