TopDown Engine  v3.6
MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid Class Reference

Requires a CharacterGridMovement ability. Makes the character move randomly in the grid, until it finds an obstacle in its path, in which case it'll pick a new direction at random Supports both 2D and 3D grids More...

Inheritance diagram for MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid:
MoreMountains.Tools.AIAction

Public Types

enum  Modes { Modes.TwoD, Modes.ThreeD }
 
- Public Types inherited from MoreMountains.Tools.AIAction
enum  InitializationModes { InitializationModes.EveryTime, InitializationModes.OnlyOnce }
 

Public Member Functions

override void Initialization ()
 On start we grab our character movement component and pick a random direction More...
 
override void PerformAction ()
 On PerformAction we move More...
 
override void OnExitState ()
 On exit state we stop our movement More...
 
- Public Member Functions inherited from MoreMountains.Tools.AIAction
virtual void OnEnterState ()
 Describes what happens when the brain enters the state this action is in. Meant to be overridden. More...
 

Public Attributes

Modes Mode = Modes.ThreeD
 
float MaximumDurationInADirection = 3f
 the maximum time a character can spend going in a direction without changing More...
 
LayerMask ObstacleLayerMask = LayerManager.ObstaclesLayerMask
 the layers the character will try to avoid More...
 
float ObstaclesDetectionDistance = 1f
 the minimum distance from the target this Character can reach. More...
 
float ObstaclesCheckFrequency = 1f
 the frequency (in seconds) at which to check for obstacles More...
 
Vector2 MinimumRandomDirection = new Vector2(-1f, -1f)
 the minimal random direction to randomize from More...
 
Vector2 MaximumRandomDirection = new Vector2(1f, 1f)
 the maximum random direction to randomize from More...
 
bool Avoid180 = true
 if this is true, the AI will avoid 180° turns if possible More...
 
- Public Attributes inherited from MoreMountains.Tools.AIAction
InitializationModes InitializationMode
 
string Label
 a label you can set to organize your AI Actions, not used by anything else More...
 

Protected Member Functions

virtual void Move ()
 Moves the character More...
 
virtual void CheckForObstacles ()
 Checks for obstacles by casting a ray More...
 
virtual void PickNewDirection ()
 Tests and picks a new direction to move towards More...
 
virtual void CheckForDuration ()
 Checks whether or not we should pick a new direction at random More...
 
- Protected Member Functions inherited from MoreMountains.Tools.AIAction
virtual void Awake ()
 On Awake we grab our AIBrain More...
 

Protected Attributes

CharacterGridMovement _characterGridMovement
 
TopDownController _topDownController
 
Vector2 _direction
 
Collider _collider
 
Collider2D _collider2D
 
float _lastObstacleDetectionTimestamp = 0f
 
float _lastDirectionChangeTimestamp = 0f
 
Vector3 _rayDirection
 
Vector2 _temp2DVector
 
Vector3 _temp3DVector
 
Vector2[] _raycastDirections2D
 
Vector3[] _raycastDirections3D
 
RaycastHit _hit
 
RaycastHit2D _hit2D
 
- Protected Attributes inherited from MoreMountains.Tools.AIAction
bool _initialized
 
AIBrain _brain
 

Additional Inherited Members

- Properties inherited from MoreMountains.Tools.AIAction
virtual bool ActionInProgress [get, set]
 
virtual bool ShouldInitialize [get]
 

Detailed Description

Requires a CharacterGridMovement ability. Makes the character move randomly in the grid, until it finds an obstacle in its path, in which case it'll pick a new direction at random Supports both 2D and 3D grids

Member Enumeration Documentation

◆ Modes

Enumerator
TwoD 
ThreeD 

Member Function Documentation

◆ CheckForDuration()

virtual void MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid.CheckForDuration ( )
protectedvirtual

Checks whether or not we should pick a new direction at random

◆ CheckForObstacles()

virtual void MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid.CheckForObstacles ( )
protectedvirtual

Checks for obstacles by casting a ray

◆ Initialization()

override void MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid.Initialization ( )
virtual

On start we grab our character movement component and pick a random direction

Reimplemented from MoreMountains.Tools.AIAction.

◆ Move()

virtual void MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid.Move ( )
protectedvirtual

Moves the character

◆ OnExitState()

override void MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid.OnExitState ( )
virtual

On exit state we stop our movement

Reimplemented from MoreMountains.Tools.AIAction.

◆ PerformAction()

override void MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid.PerformAction ( )
virtual

On PerformAction we move

Implements MoreMountains.Tools.AIAction.

◆ PickNewDirection()

virtual void MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid.PickNewDirection ( )
protectedvirtual

Tests and picks a new direction to move towards

Member Data Documentation

◆ _characterGridMovement

CharacterGridMovement MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid._characterGridMovement
protected

◆ _collider

Collider MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid._collider
protected

◆ _collider2D

Collider2D MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid._collider2D
protected

◆ _direction

Vector2 MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid._direction
protected

◆ _hit

RaycastHit MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid._hit
protected

◆ _hit2D

RaycastHit2D MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid._hit2D
protected

◆ _lastDirectionChangeTimestamp

float MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid._lastDirectionChangeTimestamp = 0f
protected

◆ _lastObstacleDetectionTimestamp

float MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid._lastObstacleDetectionTimestamp = 0f
protected

◆ _raycastDirections2D

Vector2 [] MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid._raycastDirections2D
protected

◆ _raycastDirections3D

Vector3 [] MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid._raycastDirections3D
protected

◆ _rayDirection

Vector3 MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid._rayDirection
protected

◆ _temp2DVector

Vector2 MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid._temp2DVector
protected

◆ _temp3DVector

Vector3 MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid._temp3DVector
protected

◆ _topDownController

TopDownController MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid._topDownController
protected

◆ Avoid180

bool MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid.Avoid180 = true

if this is true, the AI will avoid 180° turns if possible

◆ MaximumDurationInADirection

float MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid.MaximumDurationInADirection = 3f

the maximum time a character can spend going in a direction without changing

◆ MaximumRandomDirection

Vector2 MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid.MaximumRandomDirection = new Vector2(1f, 1f)

the maximum random direction to randomize from

◆ MinimumRandomDirection

Vector2 MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid.MinimumRandomDirection = new Vector2(-1f, -1f)

the minimal random direction to randomize from

◆ Mode

Modes MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid.Mode = Modes.ThreeD

◆ ObstacleLayerMask

LayerMask MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid.ObstacleLayerMask = LayerManager.ObstaclesLayerMask

the layers the character will try to avoid

◆ ObstaclesCheckFrequency

float MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid.ObstaclesCheckFrequency = 1f

the frequency (in seconds) at which to check for obstacles

◆ ObstaclesDetectionDistance

float MoreMountains.TopDownEngine.AIActionMoveRandomlyGrid.ObstaclesDetectionDistance = 1f

the minimum distance from the target this Character can reach.


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