diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 01f3555d3b..4fbc2e761d 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -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