I'm attempting source-style air movement, but there's some caveats...
-
Hey everyone! I'm working on an FPS game for Game Off 2023, and I was running into a very strange and unique issue. Whenever the player is heading along the Z axis and they're in the air, they are able to gain infinite speed if they have both W and either A or D pressed, whereas when they're heading along the X axis, it works as intended. Here are the if statements regarding air movement:```
# "relative_speed" is the velocity relative to the player's camera, # "max_speed" is the maximum velocity in the given direction (set to 10), # "air_accel" is the value associated with the movement correction speed midair, # and the rest of the variables' functions are either the default or self-explanatory. if (-relative_speed.x < max_speed && input_dir.x < 0): velocity.x += direction.x * air_accel * delta; if (relative_speed.x < max_speed && input_dir.x > 0): velocity.x += direction.x * air_accel * delta; if (-relative_speed.z < max_speed && input_dir.y < 0) : velocity.z += direction.z * air_accel * delta; if (relative_speed.z < max_speed && input_dir.y > 0): velocity.z += direction.z * air_accel * delta;
-
I would like to clarify that it's actually the Z axis that it works on but not the X
-
Man, I need to start solving my own problems, because at the expense of around 10 hours of my time and a little bit of sanity, I've finally fixed it! For any of you trying to make a movement FPS in Godot for whatever reason, you can use this as a base. It's klunky, but it works:
if (velocity.x <= 0 && -velocity.x <= max_speed || velocity.x <= 0 && velocity.x * direction.x < 0): velocity.x += direction.x * air_accel * delta; if (velocity.z <= 0 && -velocity.z <= max_speed || velocity.z <= 0 && velocity.z * direction.z < 0): velocity.z += direction.z * air_accel * delta; if (velocity.x >= 0 && velocity.x <= max_speed || velocity.x >= 0 && velocity.x * direction.x < 0): velocity.x += direction.x * air_accel * delta; if (velocity.z >= 0 && velocity.z <= max_speed || velocity.z >= 0 && velocity.z * direction.z < 0): velocity.z += direction.z * air_accel * delta;
-
-