Why does the player moving acceleration increase with more fps?
So I'm developing a 3D game with player movement with accelerations where the player moves using the translate function, but before that, we decide what type of movement he does (in the case of the problem is when the player is pressing the joystick and changing the direction), find the direction we want to travel to (currentMovDir) and what acceleration do we use. In our game, we have a different acceleration for changing direction on the floor and in the air (falling, jumping). The problem is that when there's a higher frame rate, the player changes direction a lot faster, like it had much more acceleration when moving. The next code is executed inside an Update every frame:
currentVel = currentVel + currentMovDir * finalMovingAcc;
horizontalVel = new Vector3(currentVel.x, 0, currentVel.z);
if (horizontalVel.magnitude > currentMaxMoveSpeed)
{
horizontalVel = horizontalVel.normalized * currentMaxMoveSpeed;
currentVel = new Vector3(horizontalVel.x, currentVel.y, horizontalVel.z);
currentSpeed = currentMaxMoveSpeed;
}
"currentVel" is the Vector3 that contains the current direction and speed, "currentMovDir" is a normalized Vector3 that contains direction we want to go (by pressing the joystick), "finalMovingAcc" is a float with the acceleration value, which can be: 2 on the floor 0.3 on the air "currentSpeed" is just a float to store the currentVel.magnitude. "currentMaxMoveSpeed" is a float with the max moving horizontal speed we allow the player to have, which is 10.
After this we do the Translate function:
transform.Translate(currentVel * Time.deltaTime, Space.World);
I tried changing Time.deltaTime for Time.fixedDeltaTime, and changing the Update for a FixedUpdate, believing this would fix the different frame rates problem, but It made the player go super fast (in the first case) or just didn't change anything, except adding a small stutter with the camera and not registering most of the inputs (as they were together in the same Update that I changed to a FixedUpdate).
Any ideas why is this happening?
Sorry for not posting more code, but the 2 classes in charge of the movement are 1000 lines of code each, and these are the only ones that I think can affect this movement. If you need any more information I will be glad to answer or provide it. Thank you.