AbsAngle

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

Note: This feature is for ZScript only.

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

This article is issued from Zdoom. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.