ok, so now the enemy detects the player and walks towards it. the problem is it wont stop walking cause the loop wont break because it doesnt implement the statement in
================================================
if(dist == 0)
================================================
here are the codes
================================================
action player_cb()
{
ENTITY* enemy = NULL;
//ENEMY IS STANDING ON GROUND=================================================================
VECTOR vFeet;
vec_for_min(vFeet,me);
set(my,FLAG2);
my.STATE = 1;
while(1)
{
//ENEMY IS IDLE===============================================================================
if(my.STATE == 1)
{
//DETECT THE ENEMY============================================================================
c_scan(my.x,my.pan,vector(900,0,900),SCAN_ENTS | SCAN_FLAG2 | IGNORE_ME);
my.ANIMATION += 10 * time_step;
ent_animate(my, "idle", my.ANIMATION, ANM_CYCLE);
if(you)
{
my.ANIMATION = 0;
my.STATE = 2;
enemy = your.PLAYER;
}
}
//PERFORM WALK ANIMATION======================================================================
if(my.STATE == 2)
{
var dist = vec_dist(my.x, your.x);
while(1)
{
if(dist != 0)
{
var distance =-5*time_step;
c_move(me, vector(0,distance,0), NULL, GLIDE);
walk_percentage += 2* distance;
ent_animate(my,"walk",walk_percentage,ANM_CYCLE);
if(dist == 0)
{
my.ANIMATION = 0;
my.STATE = 1;
}
}
wait(1);
}
}
wait(1);
}
}
======================================================
if anyone notices whats wrong please reply. thx a lot.