Wednesday, August 24, 2011

Struggling with Collisions

Just so that people don't think I've abandoned this project, I wanted to post on what I've been doing.  Once I got the tile map up and in place, I wanted to handle collisions with the walls.  I managed to modify my TMX parser to handle my "collision layer" and build the collision volumes for each wall.  I got a collision volume on my main player, great!  And then the trouble started...

I can get the "OnTriggerEnter" message (or the corresponding method from Orthello) to fire, but I'm having difficulty with the math that will stop the penetration from happening and back the sprite up.

In other words, I can detect that the wall was hit, but I haven't so far been able to get the player to not walk over the top of it.  My last attempt was to avoid using rigid bodies and just start doing ray casts when I want to move.  However, I think to do that correctly, I'd have to cast 3 rays (from the outside edges of my collision box).

It's getting late now, so I'm going to attack it again with a fresh pair of eyes tomorrow.  Sometimes, you just have to claim defeat and rest.

0 comments:

Post a Comment