E
Elkrom
Guest
having multiple issues with this code, at first glance when i started the room it seemed like it was working until i realized that if i was to the left of the enemy they would run away from me rather than at me , and if i came in contact with the enemy i got this fatal error. "unable to find any instances for object index '0' name 'obj_player' ..... dir = sign(obj_player.x - x);" and its weird when i just have it written as dir = sign(obj_player - x) i do not get this error. if anyone can give any insight i would be much appreciated and also if anyone could help with making the enemy look towards the direction its moving that would be awesome too ive tried for the last couple days but cant seem to make it work. also might be worth noting this is from the shaun spaulding enemy chase AI tutorial video.
case e_state.chase:
{
dir = sign(obj_player.x - x);
hsp = dir * 2;
vsp = vsp + grav;
sprite_index = spr_slimeAttack
if (abs(obj_player.x-x)<1) { hsp = 0; }
if (distance_to_object(obj_player) > 128) state = e_state.idle;
// Animate / character flip where pointing
}
break;
}
case e_state.chase:
{
dir = sign(obj_player.x - x);
hsp = dir * 2;
vsp = vsp + grav;
sprite_index = spr_slimeAttack
if (abs(obj_player.x-x)<1) { hsp = 0; }
if (distance_to_object(obj_player) > 128) state = e_state.idle;
// Animate / character flip where pointing
}
break;
}