polygon collisions and jumping

This topic is 3269 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello! I'm currently making a simple 2D engine and after creating a sustainable collision system I've came to a problem: In my previous collision system I simply used AABBs to determine if there occurred a collision or not. Into a function you pass two objects A and B and a trace structure that holds the collision data such as a normal and the penetration, which can be used in solving the collision. It was quite simple because all I had to do was to find the smallest penetration in the object B. and I could easily tell if I was colliding with a wall, a floor, a ceiling or another wall. However the shit hit the fan when I started meddling in polygonal collisions, where I find the smallest penetration vector on both of the entities, and push object A away from B. The collisions itself work fine but now I don't know how do I check if it collided with the floor so it can jump, as the normals can be in any of the objects depending on the smallest penetration vector. Long story short: how do I know if I am standing on something in a polygon-based collision system? thank you in advance -Spliter

Share on other sites
What I'm currently experimenting with is storing normals for each line segment. I'm treating them as push directions - this solves the slide-down-a-slope problem, and as a bonus, lets you know what kind of thing you're colliding with (floor, wall, ceiling). I figured I didn't need polygons, I just needed their edges - so I went with line segments. And then I figured that I could attach additional data to each edge - like the normal, but also things like material, to use different footstep sounds or to emit dust particles on dusty materials, and so on.

Another approach could be to use an additional shape underneath the player, as a 'sensor' - if the player collides with something, but the sensor shape doesn't, then he's not touching the floor.

Share on other sites
I get normals just from the vertices as they are always concave polygons and always have the clockwise orientation of vertices.

Also I would prefer to not have a separate collision check for the separate case of jumping as I also use the left right and top, which would mean 4 separate collision checks instead of one.

Anyways, I finally got it working, on storing the normal of the collision I simply check if it's made of a surface from the player or if it's from a surface of the wall if it's from the wall I invert it and so the player can always assume that the normal of the surface that was used for collision solving is always pointing away from him.

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 18
• 20
• 13
• 14
• 9
• Forum Statistics

• Total Topics
633365
• Total Posts
3011520
• Who's Online (See full list)

There are no registered users currently online

×