[Include] Arrow.inc Create And Point Arrows At Stuff
#15

Here's the code for target_z, ie object Y rotation
pawn Code:
// x,y,z arrow position; ax,ay,az, target position
stock Float:GetYRotation(Float:x,Float:y,Float:z, Float:ax, Float:ay, Float:az)
{
    new Float:Yoff;
    new Float:xd = ax - x;
    new Float:yd = ay - y;
    new Float:zd = az - z;
    new Float:dist = floatsqroot(xd*xd+yd*yd+zd*zd);
    Yoff = acos((az-z)/dist);
    return Yoff-180;
}
EDIT: This is 20% faster since it uses two less calculations
pawn Code:
stock Float:GetYRotation(Float:x,Float:y,Float:z, Float:ax, Float:ay, Float:az)
{
    new Float:xd = ax - x;
    new Float:yd = ay - y;
    new Float:dist = floatsqroot(xd*xd+yd*yd);
    new Float:Yoff = atan((z-az)/dist);
    return Yoff-90;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)