This is conceptually a little complicated so here's a screenshot of the project:
So this project uses the Platform behavior in conjunction with the Solid collision filter/tags. You can see in the screenshot above that there are 7 "lanes" of collision/depth, and the player object only collides with solids tagged with the lane theyre in.
This works fine, but we run into edge-case issues when switching lanes. Currently the game does the following to move lanes up down:
- First, it calls a function that checks if the position above/below the player in the lane theyre trying to move to is free.
- Next, it initiates a tween that moves the player either up or down lanes, and temporarily disables the lane collision checking while the tween is active.
- Finally, when the tween is finished the game updates the collision filter for the player object to check for collisions in the lane the player has moved to.
If the player is standing still, this works fine. We run into problems when the player is moving left/right during a lane change, because during the tween the player continues to move left/right, and the position they end up at when the tween ends and re-initiates collisions could include a solid the player is now stuck in.
Up until now I've been able to slightly combat this issue by checking directly above/below the player and slightly in front of them as well, but this has only lessened the frequency of this issue, it still occurs.
I could of course stop the players horizontal movement during the lane change tween, but this makes movement really clunky and unsatisfying, so that's not ideal.
Any suggestions on how to accomplish this would be appreciated, if I could predict the range of locations the player could end up at during step 1, then I feel like I could eliminate this issue, but I don't know how to do that or if there is a better alternative. Thank you!