GetTargetPitch
This function acts as an extension to VectorAngle, it returns the relative pitch of a thing with tid2, from a thing with tid1.
function int GetTargetPitch (int tid1, int tid2)
{
int x, y, z, xy, a;
x = GetActorX(tid2) - GetActorX(tid1);
y = GetActorY(tid2) - GetActorY(tid1);
z = GetActorZ(tid2) - GetActorZ(tid1);
a = VectorAngle(x, y);
if ((a + 0.125) % 0.5 > 0.25)
xy = FixedDiv(y, sin(a));
else
xy = FixedDiv(x, cos(a));
return -VectorAngle(xy, z);
}
This article is issued from Zdoom. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.