Hi!

I'm programing friend npc, who I can make following me.
the problem is, when I got more then one friend, and they try to follow me, they walk into each other.

how can I make them not touch each other and still follow me?

here is the friend code so far:
------------------------------------------------------
action skinnyfriend()
{
my.HEALTH = 100;

var follow_mode = false;
VECTOR temp;
VECTOR skinnyfriend_distance;

while(my.HEALTH > 0)
{
if(player)
{

if(follow_mode == true)
{

vec_set(temp, player.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
my.tilt = 0;



if(vec_dist(my.x, player.x) < 340 && vec_dist(my.x, player.x) > 50 && player.HEALTH > 0)
{

skinnyfriend_distance.x = 10 * time_step;
skinnyfriend_distance.y = 0;
skinnyfriend_distance.z = 0;

c_move(my, skinnyfriend_distance, nullvector, NULL);
ent_animate(my, "run", my.skill1, ANM_CYCLE);
my.skill1 += 9 * time_step;
if(my.skill1 > 100) {my.skill1 = 0;}
}

if(vec_dist(my.x, player.x) < 50 || player.HEALTH < 1)
{
ent_animate(my, "control", 1, ANM_CYCLE);
vec_set(temp, player.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
my.tilt = 0;
}

if(key_2)
{
follow_mode = false;
}
}

else if(vec_dist(my.x, player.x) < 70 && player.HEALTH > 0)
{
ent_animate(my, "control", 1, ANM_CYCLE);
vec_set(temp, player.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
my.tilt = 0;

if(key_1)
{
follow_mode = true;
}
if(key_3)
{
//shut up
}
if(key_4)
{
//run n' hide
}
}



else if(vec_dist(my.x, player.x) < 30 && player.HEALTH > 0)
{
c_move(my,vector(-1 * time_step, 0, 0), nullvector, GLIDE);
}

else if(vec_dist(my.x, player.x) < 150 && player.HEALTH > 0)
{
vec_set(temp, player.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
my.tilt = 0;

ent_animate(my, "shout", my.skill4, ANM_CYCLE);
my.skill4 += 9 * time_step;
if(my.skill4 > 100) {my.skill4 = 0;}
}

else
{
ent_animate(my, "idle", my.skill3, ANM_CYCLE);
my.skill3 += 1 * time_step;
if(my.skill3 > 100) {my.skill3 = 0;}
}

}

wait(1);
}
}
------------------------------------------------------

Thanks for the help!


- Muhsin Kaymak


Come and play my new browsergame - Valley Of Wolves:

http://www.mafiacreator.com/ValleyOfWolves

Hurry and be the first to take over the different business' in the Valley Of Wolves, before anybody else does it!
And be the most feared MafiaBoss in the World!!