Log In  
Follow
_Marshmallow_

I am doing a jump platformer (8px*8px tiled).

My collision is currently detecting (player location + player x/y acceleration). e.g if (y.player + y.acceleration= -1.4), then the collision detection will check the above block.

If the player was in position 100, and acceleration was y-3, then I tell the checkbox, "player position is 97 (100-3), check up block collision".
The checkbox then notifies back that there is a block ahead, if so I cancel next movement.

Problem example: Position 100 was 1 or 2 blocks away from the block, so the player position remains 1 or 2 blocks away from its target after the update.
(The checkbox moves at the speed of the player, by so, the collision occurs either 3 blocks inside the collided block, or 2 or 1).

What can be done so the hitbox check the block ahead the player, and if true, then the player touches the block surface?

So far I have thought of these two potential solutions:

  1. Check multiple times collision until the player match the block surface, so check 3 blocks ahead, if colliding, then check 2 blocks ahead, if colliding, then check 1 block ahead, if not colliding then this is the distance to the block ahead, then update the player position (by such amount of attempts) into the tile direction.

[ Continue Reading.. ]

1 comment