mwhicks-dev / splat-alpha

2D platforming game engine based in C++ and built on top of the SFML multimedia suite.
0 stars 0 forks source link

Weird collision behavior right after resolution #12

Closed mwhicks-dev closed 5 months ago

mwhicks-dev commented 6 months ago

When a collision is resolved on a vertical space, this causes the offending Asset's ID to be set to zero. Because of how events are dispatched, sometimes gravity is still added to such an Asset and it is moved, causing another collision, until it eventually converges.

This causes a bug where, sometimes, if a Character is moving (under control of a player), it will have a zero y-velocity even though it is experiencing a vertical collision. The result of this is that the Character will snap to the side of the colliding object, as this becomes the "shortest" resolution w.r.t. the Character's velocity.

This will be fixed by introducing some sort of minimum-resolution tolerance; say, if the selected resolution direction causes at least four times the movement of the shortest resolution, then we will use the minimum resolution instead.