0
\$\begingroup\$

I'm developing a game using bullet for the physics logic, but rendering using my own isometric algorithm (sprites). I'm currently dealing with the issue of how the physics object of the player would work when they're standing and walking. Standing is easy enough, the model basically just looks like a rounded rectangle. Handling walking is more difficult.

I have a couple of options on how I can handle walking.

  1. Keep the object the same. However, problems arise when the sprite the player sees doesn't match the player's movement (e.g. the player's leg might appear to go 'into' a wall).
  2. Alternate between two objects, one standing, one with legs spread as far apart as they would when walking. So, at a certain point in the walking animation, the object would switch to the latter. However, if the player walks into a wall, they would constantly oscillate against the wall.
  3. Same as option 2 but have the object where the legs are spread apart active whenever the player walks. This removes the problem with option 2 (as the player would never touch the wall whilst standing), but this is a disadvantage in itself; the player would not be able to climb up walls (assuming I use a system where the player has to be touching said wall), for example.

I'm pretty stuck as to what other options are available, any ideas would be great.

\$\endgroup\$
1
\$\begingroup\$

Typically the collision capsule remains the same most of the time, and is large enough to contain the full length of the locomotion animation (that is, the diameter is large enough that it will always contain the feet, even at full extension).

In cases where specialized animations extend beyond this basic capsule, additional collision primitives are added temporarily if needed; generally these have different interaction properties anyway (such as triggering damage to another actor, in the case of an arm extended outside the main capsule in a punch, for example).

Handling specialized interactions such as "pressing" against a wall or similar kinds of leans that make it look like the collision geometry is more complex is generally a matter of detecting the case and applying specialized animation blending.

You can make the collision capsule expand and contract with the bounds of the locomotion animation, if you want (this is more typical in 2D games), but you will still need to handle special cases as such. The oscillation problem you mention is, like the "press against the wall" problem above, a matter of detecting that and setting the appropriate state on the character controller code so you don't keep trying to play the walking animation while the player pressed into the wall (even if you have no sensible leaning animation, you don't want the player walking in place, presumably).

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.