ich würde das so lösen:
erst gucks du wie gewohn, ob der spieler in reichweite ist, wenn ja nimmst du 2 punkte die relativ zur tür sind und bestimmst welcher näher ist...:
z.b.:
Code:
action door
{
var standart_rotation[3];
vec_set(standart_rotation,my.pan);
while(1)
{
if(vec_dist(my.x,player.x)<300)
{
vec_set(temp,vector(0,20,0));
vec_rotate(temp,standart_rotation);
vec_add(temp,my.x);
vec_set(target,vector(0,-20,0));//abuse target-vector
vec_rotate(target,standart_rotation);
vec_add(target,my.x);
if(vec_dist(temp,player.x)<vec_dist(target,player.x))
{
while(abs(my.pan-standart_rotation.pan)<90)
{
my.pan+=5*time_step;
wait(1);
}
}
else
{
while(abs(my.pan-standart_rotation.pan)<90)
{
my.pan-=5*time_step;
wait(1);
}
}
while(vec_dist(my.x,player.x)<400){wait(1);}
if(my.pan>standart_rotation.pan)
{
while(abs(my.pan-standart_rotation.pan)<2)
{
my.pan-=5*time_step;
wait(1);
}
}
else
{
while(abs(my.pan-standart_rotation.pan)<2)
{
my.pan+=5*time_step;
wait(1);
}
}
my.pan = standart_rotation.pan;
}
wait(1);
}
}
PS: wouldn't it be easy when that forum would support highlighting...?