I have a KinematicBody2D
(the player) which is able to see platforms, walls, and enemies in its collision mask. All simple collisions with these entities behave as expected. I use move_and_slide
inside the _physics_process
function to move both the player and the enemy.
My Tilemap
tiles all have rectangle collision shapes (I've used grid snapping so all walls and floors are "flush"). There are no slopes.
The issue I'm having is that when an enemy bumps into the player in just the right way it can push the player into the floor or wall, where it gets stuck.
I'm not sure, but I think the reason is that I'm only handling movement in the player node's _physics_process
as a result of player input, whereas the movement into the wall is the result of a collision with another KinematicBody2D
. So move_and_slide
doesn't get called (this is just a guess).
The only advice to handling this kind of issue I could find is this answer, but on the one hand there are no details for how to implement the solution, and on the other hand I wonder if there is a better, more recommended way to handle this since it seems like overkill to have to add a bunch of raycasts to the player and all enemies.
Does anyone know how I should proceed?