AngleTo

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

Actor

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

Usage

Returns the angle from the caller to the target actor.

Parameters

  • Actor target
The actor to return the angle to.
  • bool 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.

Example

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*0.5, target.height*0.5);
		LineTrace (AngleTo (target), INT.MAX, AimPitch, TRF_SOLIDACTORS, height*0.5, data:LOF);
		return (LOF.HitActor == target) 
	}

See also