I am basically creating a script so that when an entity gets close to the "enemy" entity, the "enemy" entity follows it. This is sooooo annooying. When i run the script the enemy entitys just continue moving upward.


Edit:
-The enemy entity is supposed to return to it's starting position once player get out of range (>100 quants)

Heres the code:

/////////////////////////////////////////////
#define health skill1
#define distance_tp skill2
/////////////////////////////////////////////
ENTITY* pl;// this is the player entity
/////////////////////////////////////////////
VECTOR player_pos;// this is where the player is
/////////////////////////////////////////////
action enemy_act()
{
vec_set(vector(my.skill5, my.skill6, my.skill7), my.x);
c_setminmax(me);
my.health = 100;
my.skill8 = 0;
my.skill9 = 0;
while(1)
{
my.distance_tp = vec_dist(vector(my.skill5, my.skill6, my.skill7), player_pos.x);

if(my.distance_tp < 100)
{
vec_set(vector(my.skill8, my.skill9, 0), player_pos.x);
vec_sub(vector(my.skill8, my.skill9, 0), my.x);
vec_to_angle(my.pan, vector(my.skill8, my.skill9, 0));
c_move(me, vector(2,0,0), nullvector, GLIDE);
my.tilt = 0;
}
else
{
vec_set(vector(my.skill8, my.skill9, 0), vector(my.skill5, my.skill6, my.skill7));
vec_sub(vector(my.skill8, my.skill9, 0), my.x);
vec_to_angle(my.pan, vector(my.skill8, my.skill9, 0));
my.tilt = 0;
c_move(me, vector(1,0,0), nullvector, GLIDE);
}
wait(1);
}
}

Last edited by dakilla; 09/30/09 19:01.

One day there will be an unfixable bug,
That day is not today.