Skip to content

Commit

Permalink
Added PitchTo Function
Browse files Browse the repository at this point in the history
  • Loading branch information
Boondorl authored and coelckers committed Nov 18, 2022
1 parent eb97346 commit ef456a4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions wadsrc/static/zscript/actors/actor.zs
Expand Up @@ -810,6 +810,20 @@ class Actor : Thinker native
native void DoMissileDamage(Actor target);
native void PlayPushSound();

clearscope double PitchTo(Actor target, double zOfs = 0, double targZOfs = 0, bool absolute = false) const
{
Vector3 origin = (pos.xy, pos.z - floorClip + zOfs);
Vector3 dest = (target.pos.xy, target.pos.z - target.floorClip + targZOfs);

Vector3 diff;
if (!absolute)
diff = level.Vec3Diff(origin, dest);
else
diff = dest - origin;

return -atan2(diff.z, diff.xy.Length());
}

//==========================================================================
//
// AActor :: GetLevelSpawnTime
Expand Down

1 comment on commit ef456a4

@Talon1024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember the LevelLocals.SphericalCoords was added some time ago in response to a request for a PitchTo function. Here's the original pull request.

Please sign in to comment.