Page 1 of 1

Need help with Topdown collisions.

Posted: Sun Oct 04, 2015 3:08 pm
by _Juice
Hello, I've been working on a small project for a while now, and have recently run into a problem. I have a player with a top-down view, and walls, I have a problem where if the player goes into the corner of a wall in a certain way they can get stuck, except it's very easy to get stuck. I've been scratching my head for awhile over this problem, and I was wondering any of you could spot an error in my code or recommend me a better method for this.

I'll post the .love

Re: Need help with Topdown collisions.

Posted: Sun Oct 04, 2015 4:25 pm
by ivan
Hi and welcome to the forums.
Firstly, I would advise adding some debug rendering in there so you can see the collision boxes,
since right now it's very hard to tell what's going on with the treetops covering everything. :)
Also, the current approach to collisions is not very accurate.
What I mean is, the code checks for a collision and if one is found, the player's position is reverted.
A more robust approach is to:
1.move the player to the new position
2.check for collisions between the player and the environment
3.move the player so that he is no longer intersecting with the environment