Hi,
I have the following problem: I'm using Phys2d for collision detection for a platformer right now. The logic is sort of modeled after the alien-platformer demo, but the map consists of polygons loaded from an SVG file instead of tiles, the player is represented by a non-rotating box. What I want to do is to check for any edges that are too step for the player to climb, so I take the last collision event that occured and look at its normal - if its angle is above a certain value, the player can't move upwards.
For testing purposes I tried drawing the collision normal as a line drawn at the point of the collision, and I noticed that it is not always the same - it constantly jumps between at least two directions when the player moves, one seems to be right and directly perpendicular to the edge I'm moving on, and at other times it is off by quite a few degrees, usually something like 20-30°. I guess this depends on which edge of the player polygon exactly is detected to collide against the floor polygons.
So my question is: How can I detect the perpendicular vector to the edge I collided with as exactly as possible, meaning I always get the same collision normal everytime I collide with the same edge?
Thanks in advance,
Roland
|