SOLVED colliding teleport glitch

GONE

Member
I just finished making my enemies walk and I realized that every time they collided with a wall they teleport ahead.



vsp = vsp + grv;



// horizontal collision

if (place_meeting(x+hsp,y,Owall))
{
while (!place_meeting(x+sign(hsp),y,Owall))
{
x = x + sign(hsp);
}
hsp = -hsp;
}
x = x + hsp


// vertical collision

if (place_meeting(x,y+vsp,Owall))
{
while (!place_meeting(x,y+sign(vsp),Owall))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp

// damage taken
if(instance_exists(Oplayer)) {
if(place_meeting(x,y-1,Oplayer)) || place_meeting(x,y+1,Oplayer) {
hp -= 4

}
}


// Player animation transition
mask_index = sFox_r;

if (!place_meeting(x,y+1,Owall))
{
sprite_index = sFox_r;
image_speed = 0;
if (sign(vsp) > 0) image_index = 1; else image_index = 0;
}
else
{
image_speed = 1;
if (hsp == 0)
{
sprite_index = sFox_r;

}
else
{
sprite_index = sFox_r;
}
}

if (hsp != 0) image_xscale = sign(hsp);

if (place_meeting(x-5,y,Owall))
{
sprite_index = sFox_r;
image_speed = 0;
if (sign(vsp) > 0) image_index = 1; else image_index = 0;
}

Thanks in advance
 
Last edited:

Nidoking

Member
It looks like you only pasted some of your code, missed the part that actually does horizontal movement, and forgot to put it in CODE blocks.
 

GONE

Member
CODE blocks
[/QUOTE]

thank you so much for sending that guide. I thought you were asking why I was doing the dnd in game maker studio.

I also fix the problem but thank you so much for your aid and effort.
 
Top