• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Enemies stuck in walls

Zwaya

Member
So I'm making a shooter where the player is in a room and enemies randomly spawn around him. Room has no gravitational force pulling the players so I don't have hsp and vsp variables for enemy movement I just have walksp. For the enemies movement I used
mp_potential_step(oPlayer.x, oPlayer.y, walksp, false)
Now while moving towards the player enemies would obviously go through a wall because I didn't setup any code for collision. I used Spalding's code for wall collision
if (place_meeting(x+walksp, y, oWall))
{
while (!place_meeting(x+sign(walksp), y, oWall))
{
x = x + sign(walksp);
}
walksp = 0;
}
Now, the enemies will stop when colliding with the wall, but they don't move anymore after that. What I mean is when they collide with a wall, they just stick to it. They do move around, look and shoot at the player, but they don't move. How can I fix this? Any reply helps. Sorry for my bad description and thanks in advance!
 
Top