![]() The sign of the components of the resulting vector will indicate how the wall relates to the player's motion while the vector itself indicates which direction the player may now move.įor the third point, assuming you have collision rectangles for both the wall and the player, you should be able to determine how much of the player's collision rectangle contacts with the wall's collision rectangle. ![]() If you were having an issue with this, it might be due to a a confusing choice of representation for your world and tile space, so perhaps you should post more details about it / ask a separate, specific question.įor the second point, the most direct approach would be to take the player's (normalized) movement vector and add it to the wall's normal vector, then renormalize. You simply store and manipulate the character's position in world or pixel coordinates instead of tile-based coordinates. I'm using the XNA Framework, is there anything in it to help with this? Are their resources available on this kind of movement? Equations or algorithms explained on a wiki or something? To be clear I'm talking about the human character's movement, not an NPC's movement. I've hunted for efficient ways to achieve this and have had no luck. bumping into the corner causes you to be pushed into the hall/door. If you're a few pixels off from walking squarely into a door or hallway, you are corrected into walking through the hall or down the hallway, i.e.This should work for both diagonals correcting in both directions. If you're walking West and you come to a wall that is diagonal in a North East/South West fashion, you are corrected into a South West movement even if you continue holding left (West) on the controller.This floating movement should be able to achieve diagonal motion. ![]()
0 Comments
Leave a Reply. |