the-mallory/factorygame

Collision check strange behavior for pushback

Closed this issue · 4 comments

The AABB pushback has an unexpected result when pushing up against a wall of collision boxes. Movement stops when pressing left/right and up into wall, but continues fine when pressing left/right and down into wall.

This also applies to the SAT check. Additionally, the simple AABB check seems to occasionally push really large entities straight through to the other side.

The solution to this issue may require some fundamental changes. It appears that the collision algorithm cannot make a decision when it comes to pushing back the entity in situations where the velocity in the x and y are identical as well as the distance when colliding on the very corner of the bounding box. This means in my mind that further knowledge is needed by the collision method to resolve this. For example, a "preferred movement axis" variable indicating x or y would be needed. If the preferred axis is x then the collision algorithm will pick to push back along the y in situations where the resolution is ambiguous to the algorithm.

Further compounding this issue is that the method is "blind" to other bounding boxes, and so the pushback may result in pushing into another bounding box. If the bounding box pushed into has already been checked for collision by the overall algorithm, then such a situation will not be resolved. My idea would be to have a finalization check, where if the final position calculated is a position with collision, then cancel all the overall calculations and revert to the last known good position. This relies on the assumption that the initial position of an entity is "good", and so then the next will be "good" as well, and so on.

This has been fixed for simple AABB. Rotated bounding boxes should not allow this issue to be apparent.