AbsAngle

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

double absangle (double angle1, double angle2)

Usage

Used to find the absolute difference between two angles, because raw actor angles may not always be normalized. For example, the player's angle variable can return inconsistent results if the player has turned a complete circle.

If you need to get whether the difference goes right or left, use DeltaAngle instead.

Parameters

  • angle1: The first angle to be compared.
  • angle2: The angle to be subtracted from the first.

Return Value

  • The difference between the two angles, normalized to between [0,180] (whether the original was positive or negative).

Example

This replicates the GetAngle functionality with GAF_RELATIVE specified, only it does not consider if the target is either to the right or left.

if (target && absangle(angle, AngleTo(target)) < 20)

See Also