I have the collision detection down. Now, I need to find where to move the player so that he is not clipping any blocks. Once I have the collision detection, I want to move the player to the nearest open space. Is there a way to do this easily? I know I need to find the overlapping rectangle, but I don’t know how to do that. If you have any information on this post it please!
Share
A very common way is to try to move the player to a position, and then see if he’s actually colliding with anything. If he isn’t, move there, else, try another location. In pseudocode:
Basically though, I’d have a list to off all the spaces (or available directions) around the player, and loop over that, instead of hard coding all the direction by hand.