AbsAngle

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

Actor

native clearscope static double absangle(double ang1, double ang2)

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

  • ang1: The first angle to be compared.
  • ang2: 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