T
Tchoup15
Guest
Hi, so I am trying to build a stealth aspect into the game. When my player (obj_heroteam) moves, it creates obj_sound (not solid), which is (at the moment) represented as a white circle around him that lasts half a second before being destroyed, with a radius of 250. I want my enemy characters (obj_enemy) to move towards obj_heroteam when he "hears" him, or when he collides with the obj_sound.
My issue is that as long as obj_enemy is within obj_sound, so while the collision event keeps happening, the obj_enemy doesn't move, he waits until after the collision to begin moving.
Here's where I am at:
Under obj_enemy Create Event
sprite_index = spr_enemy;
var_speed = 2;
var_distance = distance_to_object(obj_heroteam);
can_hear = false;
Under obj_enemy Collision event with obj_sound:
can_hear = true;
Under obj_enemy Step Event:
if (can_hear = true) {
sprite_index = spr_enemynoise;
img_speed = 1;
mp_potential_step(obj_heroteam.x, obj_heroteam.y, var_speed, false);
}
Any advice for making sure that the obj_enemy doesn't stall?
(Side note: I created the can_hear = true / can_hear = false, because, as a next step, I want to add code to the obj_enemy step event where, after the obj_enemy is a certain distance away from obj_heroteam, an alarm is triggered and after a couple seconds can_hear = false and the character stops chasing the obj_heroteam. Basically, the next step is after the hero gets far enough away from the enemy, the enemy gets bored and stops chasing.)
Thanks guys!
My issue is that as long as obj_enemy is within obj_sound, so while the collision event keeps happening, the obj_enemy doesn't move, he waits until after the collision to begin moving.
Here's where I am at:
Under obj_enemy Create Event
sprite_index = spr_enemy;
var_speed = 2;
var_distance = distance_to_object(obj_heroteam);
can_hear = false;
Under obj_enemy Collision event with obj_sound:
can_hear = true;
Under obj_enemy Step Event:
if (can_hear = true) {
sprite_index = spr_enemynoise;
img_speed = 1;
mp_potential_step(obj_heroteam.x, obj_heroteam.y, var_speed, false);
}
Any advice for making sure that the obj_enemy doesn't stall?
(Side note: I created the can_hear = true / can_hear = false, because, as a next step, I want to add code to the obj_enemy step event where, after the obj_enemy is a certain distance away from obj_heroteam, an alarm is triggered and after a couple seconds can_hear = false and the character stops chasing the obj_heroteam. Basically, the next step is after the hero gets far enough away from the enemy, the enemy gets bored and stops chasing.)
Thanks guys!