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
Need help with Topdown collisions.
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Need help with Topdown collisions.
- 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
Re: Need help with Topdown collisions.
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
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
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 4 guests