Raptor007 / aq2-tng

Action Quake 2: The Next Generation. Raptor007's sandbox for testing changes. When verified stable, this code is pushed to the official aq2-tng repo:
https://github.com/aq2-tng/aq2-tng/tree/bots
4 stars 2 forks source link

Walking down slight inclines animates badly. #90

Closed Raptor007 closed 3 years ago

Raptor007 commented 4 years ago

This issue is caused by Quake 2 client Pmove, but shows up mostly in Action Quake maps with sloped ground, like teamjungle and cliff.

The problem is that the client sends pm.groundentity NULL intermittently as you walk forward down a slight incline, where ideally it would always be the entity you're walking on (world or other): https://github.com/Raptor007/aq2-tng/blob/3835e46b4016a0e7c582c9bad0e831da1171bf55/source/p_client.c#L2995

This causes G_SetClientFrame to start "jump" animations because it thinks you are leaving the ground: https://github.com/Raptor007/aq2-tng/blob/3835e46b4016a0e7c582c9bad0e831da1171bf55/source/p_view.c#L1056-L1057

It also makes the 3rd person spectator look annoying, especially at higher framerates. UpdateChaseCam increases the spectator camera height when the player has groundentity == NULL so the camera rapidly jiggles up and down: https://github.com/Raptor007/aq2-tng/blob/3835e46b4016a0e7c582c9bad0e831da1171bf55/source/g_chase.c#L152-L154

I think I can work around this. If the ClientThink is claiming a pm.groundentity NULL but ent->groundentity != NULL it should do some kind of sanity check to see if it should honor the incoming "in-air" state or keep the previous groundentity... maybe based on how far the height has changed?

Raptor007 commented 4 years ago

This should probably be a cvar since the "buggy" slope behavior has been around since 1.52 (and baseq2).

Raptor007 commented 4 years ago

Looking at the Quake 2 Pmove function used for client-side movement, I was able to confirm my guess about why this is happening. Here is the order of relevant events:

  1. Add gravity to velocity unless touching the ground.
  2. Add control movement to velocity.
  3. Apply velocity to position, and check for bumping into things.
  4. Check if touching the ground.

This means if you are on the ground and step towards a downward slope (no matter how steep or shallow) the first movement frame will not apply any gravity (velocity[2] = 0). You will move horizontally only, so you won't "bump into" the ground, and you will be marked as "in air" (groundentity = NULL) at the final position check of the frame. To the server, this change from "on ground" to "in air" starts a jump animation. The next few frames will apply gravity until you land on the ground, and then the cycle repeats. This is why players appear to hop down all slopes. aq2-slope This behavior is probably desirable on steep hills, but looks silly on very shallow ones.

The ideal fix would have been in 1997 for Quake 2 to apply gravity during movement even when on the ground, but it would no longer be appropriate to change the way Quake 2 feels. However, there are ways for a mod like AQ2 to work around the side-effects of this behavior, such as preventing the hopping animation when walking down small slopes.

Raptor007 commented 4 years ago

I've added the slopefix cvar, enabled (1) by default. It's not latched, so feel free to toggle this on and off on your server to see the difference. I think this is a massive improvement for walk animations on maps like cliff and teamjungle with sloped terrain.