I have a little tank that is suppose to turn and shoot the player when the player gets too close. Working so far.

However, I found that I use the little formula for pointing an object at another alot so I tried to make it its own function:

Code:

//turn to .wdl
//makes an object look at another object
//angleFrom is the vector the object to be looked at is
//angleTo is the euler angle that is turned.
function turnTo(angleFrom,angleTo)
{
var dirB[3];
vec_set(dirB,angleFrom);
vec_diff(dirB,dirB,my.x);
vec_to_angle(angleTo,dirB);
}




Problem is, when I put it in the game and run it, it spits out an empty pointer error.

Code:
 
action enemyTurret
{
//var dir[3];
while (!player){ wait(1); }
my.passable = on;
while(you)
{
my.health = you.health;
if(my.health < 0) { break;}
if(vec_dist(my.x,player.x) < 1000)
{
turnTo(player.x,my.pan);
//vec_set(dir,player.x);
//vec_diff(dir,dir,my.x);
//vec_to_angle(my.pan,dir);
}
else
{
my.pan = you.pan;
}
wait(1);
}
ent_remove(me);
}



The commented lines are what I originally had. I was hoping to give turnTo(); its own WDL file so I could use it in other projects.

The entity* player as of right now always exists and cannot yet be killed or removed from the game.

The problem I keep getting is "empty pointer: turnTo(player.x,my.pan);" What would be causing this and how can I be rid of it and still keep this function?

Last edited by jonkuhl; 02/16/08 05:14.