I agree. A dedicated function is the proper way to not only detect obstacles and avoid that moves but check also for check first other special things like enter traps, fall in holes, enter in portals, some object interactions and made respective function re-route).Ellohir wrote:The usual first approach to collision resolution is "if the player enters a wall, push it out quickly". It works, but that makes it really ugly. What you want is to, in one only function, decide if the player can move or not. Doing so, the player is never "inside" the wall. You move the player where it wants, test collision, and let it be or return to previous position.
Character movement on collision problem
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Character movement on collision problem
-
- Prole
- Posts: 28
- Joined: Tue Mar 20, 2012 10:39 am
Re: Character movement on collision problem
That code, produced the same error when walking against a wall, maybe I did something wrong when modifying it for my code, but I think I found a solution.
I will add 4 invisible objects around the player, if these objecs touches a wall the corresponding direction on the keyboard is disabled. This is simple but could produce a perfomance hit I think. When I get my idea working I will add a new .love for you to see, as it is proper manners to provide the solution for a problem if found.
I will add 4 invisible objects around the player, if these objecs touches a wall the corresponding direction on the keyboard is disabled. This is simple but could produce a perfomance hit I think. When I get my idea working I will add a new .love for you to see, as it is proper manners to provide the solution for a problem if found.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Character movement on collision problem
This is sometimes called the "white cane" solution. You can save performance by only having one cane, and positioning it in front of the player (based on the direction they are facing). It's not the greatest solution in terms of performance, but it's easy to wrap your head around, which is a plus.
Kurosuke needs beta testers
Who is online
Users browsing this forum: No registered users and 3 guests