In my platformer I’m trying to figure out the best way of getting the collision directions of the player, a rectangular collision object; left/up/right/down. I want to use those flags to determine which state the player should be in to allow wall jumps and wall slides. Trickier than I thought!
So far I’ve tried these approaches:
-
Using the normal from contact_point_response. This doesn’t work when the player is next to a wall, because the collision stops when the player stops running. Adding a force to press the player into the wall kind of works, but can lead to unexpected behaviour, such as jumping straight up when standing next to a short wall lands you on the ledge above, which feels weird.
-
Adding a collision trigger which is slightly bigger than the player. This kind of works, but is not ideal because the player only needs to be close for it to trigger, so may trigger at slightly the wrong time. I also noticed that the trigger lag behind the player collision object for some reason.
Any other ideas on how to achieve this more cleanly? I’m going to try to use raycasts next.