About the turning entity, I assumed you has assigned an action to it, it would not work without one. Anyway, here is a small action that you need to assign to the entity that is going to turn toward you. You can actually assign it to look at any other entity. The "you" pointer has to be assigned to whatever is going to be looked at. Also, the version of Game Studio is important. Prior to 6.4 "time" was used to correct the time factor for different computers. After that, it was changed to "time_factor". Look it up on a newer manual. (Found in the download area).

Edit: I included a line if(mouse_middle) just to give the option of starting the turn by mouse input. Remove it when it is not needed any more.

This action code works:

Code:
action a_turner
{
var original_direction[3];
var new_direction[3];
var pan_difference;
var pan_direction;
var turnspeed = 4;

while(1) // action goes on forever or entity is removed
{
// Check angles
you = player; // or whatever is going to be turned toward
vec_set(original_direction,my.pan);
vec_set(temp,your.pos);
vec_sub(temp,my.pos);
vec_to_angle(new_direction,temp);

if(mouse_middle)
{
// Turn if needed
if(abs(original_direction.pan - new_direction.pan) > 1) // only turn if not looking toward player (within +/- x degrees)
{
pan_difference = (360-new_direction.x) - (360-original_direction.x);
if(pan_difference < 0)
{
pan_direction = 1;
}
else
{
pan_direction = -1;
}

while(abs(my.pan - new_direction.x) > turnspeed)
{
my.pan += pan_direction * turnspeed; // adjust angle increment by multiplying with turnspeed

if(abs(my.pan - new_direction.pan) < turnspeed)
{
my.pan - new_direction.pan
}

// edited: added to ensure end to panning

wait(-time_step*0.01); // adjust step speed by multiplying with 0.01 .. 100
wait(1);

// (use time instead of time_step in Game Studio prior to 6.8)

}
}
}
wait(1);
}
}



cheers,
tindust

Last edited by tindust; 03/03/08 00:33.