wrestitaway
Member
I've got an enemy that runs back and forth on a platform
create:
step:
Parent to enemy_shell (decides whether the death is a skelton or explosion)
All of that works, in that they will drop to the floor and run in the right direction and turn around at the edge, but it only seems to work on the floor I'm on as the player. I didn't realize this was a problem as I was debugging the code with oll the objects on the same platform.
I don't see my mistake. What could be causing this?
Any help appreciated. Thanks.
create:
GML:
image_speed = 1;
dir = -1;
en_movespeed = 2;
grav = .2
en_xspd = 0;
en_yspd = 0;
grounded = true;
aoh = true;
GML:
//gravity and speed
if (en_yspd < 10) en_yspd += grav
en_xspd = en_movespeed * -dir
image_xscale = sign(-en_xspd)
//Horizontal Collision
if (place_meeting(x+en_xspd,y,ob_wall))
{
while(!place_meeting(x+sign(en_xspd),y,ob_wall))
{
x += sign(en_xspd);
}
en_xspd = 0;
}
x += en_xspd;
//Vertical Collision
if (place_meeting(x,y+en_yspd,ob_wall))
{
while(!place_meeting(x,y+sign(en_yspd),ob_wall))
{
y += sign(en_yspd);
}
en_yspd = 0;}
y += en_yspd;
//keep on platform
if grounded and aoh and (!place_meeting(x+en_xspd,y+16,ob_wall))
{
en_movespeed = -en_movespeed;
}
GML:
if place_meeting(x,y,ob_hitbox)
{if explode == true {instance_change(ob_explosion,true)}
}
if skeleton == true {instance_change(ob_skeleton,true)}
I don't see my mistake. What could be causing this?
Any help appreciated. Thanks.