ok you might think this is something covered before, but i have a problem with my angle function....here is what it is
Code:
function getAngle(ENTITY* pObject1, ENTITY* pObject2){
return atan((pObject1.y - pObject2.y) / (pObject1.z - pObject2.z));
}
action roll_me ()
{
while(1){
var angle = getAngle(g_cCharacters[0].eChar, g_cCharacters[1].eChar);
me.roll = angle;
wait(1);
}
}
int main(){
g_cCharacters[0].eChar = ent_create("block.mdl", vector(-144,-112,160) , cursor_me);// mouse
g_cCharacters[1].eChar = ent_create("block.mdl", vector(-144,-112,160) , roll_me);// player/gun
}
NOTE: its in 3d so don't get confused to see Y and Z instead of X and Y. I know the cursor_me action is missing it's just a complex calculation to put the object in 3d on the exact spot where my mouse is in 2d on my screen.
Ok my problem is I get a E1513 error. If I do that calculations in the roll_me action itself it works just fine only with this simple function it does not work....any thoughts anyone?