
I have an AABB collision resolution issue.
I allow the intersection of AABB, first resolving the X axis, then the Y axis. This is done to prevent this error: http://i.stack.imgur.com/NLg4j.png
The current method works great when an object moves into the player and the player must be pressed horizontally. As you can see in .gif, horizontal bursts correctly press the player.
However, when the vertical spikes move into the player, the X axis is still resolved first. This makes it impossible to "use the spikes as an elevator."
When a player goes into vertical spikes (under the influence of gravity, gets into them), he clicks on the Y axis, because there was no overlap on the X axis to start with.
What I tried is the method described in the first answer of this link . However, the spikes and moving objects move by changing their position, not the speed, and I do not calculate their next predicted position until the Update () method is called. Needless to say, this solution didn't work either. :(
I need to solve the AABB collision so that both of the cases described above work as intended.
This is my current collision source code: http://pastebin.com/MiCi3nA1
I would be very grateful if someone could understand this, since this error is present in the engine from the very beginning, and I tried my best to find a good solution without any success. This seriously makes me spend nights looking at the conflict code and preventing me from getting to the "fun part" and coding the game logic :(
I tried to implement the same collision system as in the XNA AppHub platformer demo (after copying most of the material). However, the error "jumping" occurs in my game, while it does not occur in the demo version of AppHub. [jumping bug: http://i.stack.imgur.com/NLg4j.png ]
To jump, I check to see if the onGround player is on, then add -5 to Velocity.Y.
Since the Velocity.X player is higher than Velocity.Y (see the fourth panel on the diagram), onGround is set to true when it should not be, and thus the player can jump in the air.
I believe that this does not happen in the demo version of AppHub, because the Velocity.X player will never be higher than Velocity.Y, but I could be wrong.
I solved this earlier, resolving first along the X axis, then along the Y axis. But this makes it run into the spikes, as I said above.