Issue with enemies getting stuck in ground

Working on a simple 2d platformer, with a mechanic where enemies can be grappled. So far all going well, though I made it so that if while the player is grappling an enemy and they take a hit from another enemy, they're supposed to be knocked back and release the enemy. With how this currently works, occasionally released enemies will be placed in a wall, unable to move.

I'm just looking for a simple fix for this, such as an event for collision between the enemy and a wall/ground object, where the enemy is moved up one pixel as long as they're in collision to get them up out of the wall/ground. For some reason however, this isn't currently working (presumably because I have "solid" checked for the wall/ground objects, but I need this option checked as otherwise when my player recieves knockback, they will sometimes be knocked into a wall, unable to escape).

Is there a different block of code I can use or a way to make my current setup work? Don't need anything too complex, just something that moves enemy objects up if they are stuck in the ground.


Without seeing your current code we can just guess how it works
Here's a piece of code that pushes the object up until it doesn't collide with the ground
while(place_meeting(x, y, obj_ground)) y--;
In most cases when an enemy gets knocked back you can check if the enemy doesn't collide with the wall and if it does just reverse the speed so the enemy bounces off
Last edited: