From ZDoom Wiki
Jump to navigation Jump to search
Note: This feature is for ZScript only.

clearscope double AngleTo(Actor target, bool absolute = false) const


Returns the angle from the caller to the target actor.


  • target: The actor to return the angle to.
  • absolute: If the function should not account for static portals. Default is false.

Return value

The absolute angle that faces in the target actors' direction.


This simple function can be used to make a monster ONLY shoot if it will hit its' target. It uses AngleTo() and PitchTo() to give an angle and pitch to LineTrace that fires the raycast at the targets' direction.

	bool A_OnlyHitTarget()
		if (!Target) return false;
		FLineTraceData LOF;
		double AimPitch = PitchTo (Target,Height/2,Target.Height/2);
		LineTrace (AngleTo (Target),INT.MAX,AimPitch,TRF_SOLIDACTORS,Height/2,data:LOF);
		if (LOF.HitActor == Target)
			return true;
		return false;

See also