mjjones0 / manaonline

1 stars 0 forks source link

Collision resolution is incorrect #1

Open mjjones0 opened 6 years ago

mjjones0 commented 6 years ago

Players push enemies incorrectly when changing directions and it can cause the player to jump around and even jump into an inanimate object, causing them to freeze, and freezing the monster they were colliding with too for that matter.

mjjones0 commented 6 years ago

Here's some more specifics for myself or anyone else venturing into this issue:

Collisions are currently handled in the level itself, via 4 functions:

(1) collidePlayerX (2) collidePlayerY (3) collideMonsters (4) collideWithExit

It may be correct for collisions to be handled in the level as there will be intricate logical ties between the level entities (with the scale of our game anyway), but the actual procedures to determine and resolve collisions physically should be moved outside of the level. Ordering of collisions is also in need of specification so that it can be further elaborated as the game gets more complex.

Currently, players push the monsters with their velocity and direction at 100%. This should be changed to a slower push for normal monsters and no push for heavy monsters (somewhat already coded). The logic for determining how the player is colliding with the monster and how the player should influence the monster is incorrect as there are bugs. This needs to be figured out. There is a push animation for the player already loaded in, but no state surrounding it. What should happen is that the player should try to push entities (inanimates and monsters) he runs into and is trying to still run into. You can see it from youtube searching some videos of Secret of Mana 2 (or playing it yourself). The push velocity is much slower than running velocity. When players hit monsters generally they're knocked back as well, and the same should happen for the player being knocked back. There is no code in place for "knock back" currently, though it sounds like an acceleration to me, so that's another thing to add to the collision/physics system.

Summary:

(1) Collisions should have 0 glitchy looking movements (2) Players should go into a push animation and push state for trying to move monsters that should be slower than their normal movement speed and this should not conflict with other animations or states. (3) Collision code should use spatial hashing to result in as few intersection tests as possible as these are quite expensive and will affect framerate. (4) There should be some knockback. (5) Refactor as much as reasonably possible