L
LunarIceCream
Guest
So I was making a platformer using a tutorial from Shaun Spalding, and it was a little outdated but overall working fine, until I got to this specific line of code with the oEnemy object in the step event.
if (place_meeting(x+hsp,y,oWall))
{
while (!place_meeting(x+sign(hsp),y,oWall))
{
x = x + sign(hsp);
}
hsp = -hsp;
}
It should work fine, but it always thinks it's doing a horizontal collision, resulting in the Enemy sprite pretty much dancing (moving left and right over and over again) in place as soon as it hits the floor instead of moving in the other direction when it hits a wall, like I want it to. I've tried everything I can think of, but there's seemingly no foolproof way to prevent the Enemy obj. from either dancing in place or walking through the walls straight off the screen. I'm not sure if it's a bug or if there's something I'm missing to prevent this, but I'd really appreciate any help on this topic.
if (place_meeting(x+hsp,y,oWall))
{
while (!place_meeting(x+sign(hsp),y,oWall))
{
x = x + sign(hsp);
}
hsp = -hsp;
}
It should work fine, but it always thinks it's doing a horizontal collision, resulting in the Enemy sprite pretty much dancing (moving left and right over and over again) in place as soon as it hits the floor instead of moving in the other direction when it hits a wall, like I want it to. I've tried everything I can think of, but there's seemingly no foolproof way to prevent the Enemy obj. from either dancing in place or walking through the walls straight off the screen. I'm not sure if it's a bug or if there's something I'm missing to prevent this, but I'd really appreciate any help on this topic.
Last edited by a moderator: