I am losing my mind trying to get my collision detection working perfectly for my player in my game.
I have platforms moving up constantly at a specific rate, and the player is supposed to fall from platform to platform. Sort of like those falldown games on calculators.
I have recoded the whole collision system three times now.
I first tried using boundary checking using player’s position added to the player’s velocities (predicting). This included code to move the character to the top of the platform if he moves into it (which happens when the platform moves up). That caused the issue where if I walked off the edge of a platform but moved back towards it, the character got bumped up to the top of the platform.
I then tried starting again and tried keeping track of the previous X and previous Y.
Of course, that failed miserably.
Is there a solid step by step formula to this sort of collision detection? (Ex. First add gravity, then check collisions and if colliding - zero the player velocity and move him up. Update positions.) It boggles my mind, especially since I have done collision detection quite a few times before, and something always goes terribly wrong.
I also should mention that I have Keith Peter’s AS3 Making Things Move book… I have read through the chapters many times.