ioncrisneamtu
Member
Hello guys, I'm working on a platformer but it seems that enemies' horizontal collision is not working.
I'm using this code in the step event:
///h collision
if (place_meeting(x+hsp,y,oSolid))
{
while (!place_meeting(x+sign(hsp),y,oSolid))
{
x = x + sign(hsp);
}
hsp = -hsp;
}
x = x + hsp;
///vert collision
if (place_meeting(x,y+vsp,oSolid))
{
while (!place_meeting(x,y+sign(vsp),oSolid))
{
y += sign(vsp);
}
vsp = 0;
}
y += vsp;
///move
{
move_towards_point(oDrifter.x,oDrifter.y,walkspd);
}
(oDrifter being the player)
I'm using this code in the step event:
///h collision
if (place_meeting(x+hsp,y,oSolid))
{
while (!place_meeting(x+sign(hsp),y,oSolid))
{
x = x + sign(hsp);
}
hsp = -hsp;
}
x = x + hsp;
///vert collision
if (place_meeting(x,y+vsp,oSolid))
{
while (!place_meeting(x,y+sign(vsp),oSolid))
{
y += sign(vsp);
}
vsp = 0;
}
y += vsp;
///move
{
move_towards_point(oDrifter.x,oDrifter.y,walkspd);
}
(oDrifter being the player)