TopDown Engine v4.5
Loading...
Searching...
No Matches
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 { TwoD , ThreeD }
Public Types inherited from MoreMountains.Tools.AIAction
enum  InitializationModes { EveryTime , OnlyOnce }

Public Member Functions

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

Public Attributes

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

Protected Member Functions

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

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

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 ( )

On PerformAction we move.

◆ 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: