My jumping enemies jump out of the room. They collide with the right wall and bounce off correctly. however when they collide with a left wall they jump out of the room and fall out. Please help. Thanks. This is in gamemaker studio 2 and I am creating a platformer game.
//Gravity and movementvsp = vsp + grv;//Dont walk off the edgeif (grounded == true) and (afraidofheights == true) and (!place_meeting(x+sign(hsp),y+1,oWall)){ hsp = -hsp;}//Horizontal collisionif (place_meeting(x+walksp,y,oWall)){ while (!place_meeting(x+sign(walksp),y,oWall)) { //x = x + sign(walksp); } hsp = -walksp;}x = x + hsp;//Vertical collisionif (place_meeting(x,y+vsp,oWall)){ while (!place_meeting(x,y+sign(vsp),oWall)) { y = y + sign(vsp); } vsp = -jumpheight; }y = y + vsp;//Animations//if the enemy is off the ground they use jumping and falling animationsif (!place_meeting(x,y+1,oWall)){ grounded = false; sprite_index = jumpsprite; image_speed = 0; if (sign(vsp) > 0) image_index = 1; else image_index = 0;}else{ grounded = true; image_speed = 1; //if the player is standing still plays idle animation if (hsp == 0) { sprite_index = idlesprite; } //if the player is moving plays running animation else { sprite_index = runsprite; }}//Changes direction of spriteif (hsp!= 0 ) image_xscale = sign(hsp) *size;image_yscale = size;