BomberUnits
...a Unity learning project
WorldDirExtensions Class Reference

Unity coordinate System: posZ = 0, posX = 90 -> clockwise, beginning with forward. More...

+ Collaboration diagram for WorldDirExtensions:

Static Public Member Functions

static Vector3 ToUnitVector (this WorldDir dir)
 
static WorldDir TrySnapFromAngle (float worldAngle, float snapTolerance=45f)
 Takes an angle in the x-z-plane (0 to 360 deg) and tries to snap it to a WorldDir. More...
 

Static Public Attributes

static readonly WorldDir [] all4Dirs = { WorldDir.posZ, WorldDir.posX, WorldDir.negZ, WorldDir.negX }
 

Detailed Description

Unity coordinate System: posZ = 0, posX = 90 -> clockwise, beginning with forward.

Definition at line 13 of file WorldDir.cs.

Member Function Documentation

◆ TrySnapFromAngle()

static WorldDir TrySnapFromAngle ( float  worldAngle,
float  snapTolerance = 45f 
)
inlinestatic

Takes an angle in the x-z-plane (0 to 360 deg) and tries to snap it to a WorldDir.

The tolerance in degrees (0 to 45) lets the snap fail if the world angle is farther away from any worldDir than the given tolerance. Fails are signaled via the INVALID value of the WorldDir enum!

Todo:
: Add unit tests for this one!

Definition at line 27 of file WorldDir.cs.


The documentation for this class was generated from the following file: