I am currently using the FPSWalkerEnhanced C# script found here.
When I apply air control, the movement is the same as if the player were standing on the ground. I want to add the player’s current momentum into the formula, so that it will take a while to slow down, or incrementally change direction, as opposed to being able to stop on a dime in mid air, or shoot off in a different direction instantly.
This is the original code:
if (airControl playerControl) {
moveDirection.x = inputX * speed * inputModifyFactor;
moveDirection.z = inputY * speed * inputModifyFactor;
moveDirection = myTransform.TransformDirection(moveDirection);
}
Here is what I have tried (one of many):
if (airControl playerControl) {
moveDirection.x = moveDirection.x + (inputX * speed * Time.deltaTime);
moveDirection.z = moveDirection.z + (inputY * speed * Time.deltaTime);
moveDirection = myTransform.TransformDirection(moveDirection);
}
All I end up with are some weird jerky movements in the wrong direction, like the script is not using the player’s transform, but the world’s. I have been fighting this for hours now, and am pretty frustrated. Any help would be greatly appreciated, and will deserve a special spot in the credits once the game is done.