I’ve been trying to figure out how to make my movement not have the age old problem of double speed when going diagonal. The various answers out there don’t seem to help me solve the way I’m doing movement. Any help on where to normalize or whatnot would be greatly appreciated. Thank you.
float accelRate_x;
float accelRate_y;
accelRate_x = (Mathf.Abs(targetSpeed_x) > 0.01f) ? runAccelAmount : runDeccelAmount;
accelRate_y = (Mathf.Abs(targetSpeed_y) > 0.01f) ? runAccelAmount : runDeccelAmount;
float speedDif_x = targetSpeed_x - rigid_body.velocity.x;
float speedDif_y = targetSpeed_y - rigid_body.velocity.y;
float movement_x = speedDif_x * accelRate_x;
float movement_y = speedDif_y * accelRate_y;
Vector2 final_movement = new Vector2(movement_x, movement_y);
rigid_body.AddForce(final_movement, ForceMode2D.Force);