Need help with Topdown collisions.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
_Juice
Prole
Posts: 2
Joined: Sun Oct 04, 2015 2:32 pm

Need help with Topdown collisions.

Post 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
Attachments
GAME.love
(332.09 KiB) Downloaded 117 times
"A man may die, a nation may rise and fall, but an idea lives on." - John F. Kennedy
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Need help with Topdown collisions.

Post 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
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 4 guests