Corgi Engine  v8.8
MoreMountains.CorgiEngine.AIActionPatrol Class Reference

This Action will make the Character patrols until it (optionally) hits a wall or a hole. More...

Inheritance diagram for MoreMountains.CorgiEngine.AIActionPatrol:
MoreMountains.Tools.AIAction MoreMountains.CorgiEngine.AIActionPatrolWithinBounds

Public Member Functions

override void Initialization ()
 On init we grab all the components we'll need More...
 
override void PerformAction ()
 On PerformAction we patrol More...
 
override void OnExitState ()
 When exiting the state we reset 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

bool ChangeDirectionOnWall = true
 If set to true, the agent will change direction when hitting a wall. More...
 
bool AvoidFalling = false
 If set to true, the agent will try and avoid falling. More...
 
Vector3 HoleDetectionOffset = new Vector3(0, 0, 0)
 The offset the hole detection should take into account. More...
 
float HoleDetectionRaycastLength = 1f
 the length of the ray cast to detect holes More...
 
bool UseCustomLayermask = false
 Whether to use a custom layermask, or simply use the platform mask defined at the character level. More...
 
LayerMask ObstaclesLayermask = LayerManager.ObstaclesLayerMask
 if using a custom layer mask, the list of layers considered as obstacles by this AI More...
 
float ObstaclesDetectionRaycastLength = 0.5f
 the length of the horizontal raycast we should use to detect obstacles that may cause a direction change More...
 
Vector2 ObstaclesDetectionRaycastOrigin = new Vector2(0.5f, 0f)
 the origin of the raycast (if casting against the same layer this object is on, the origin should be outside its collider, typically in front of it) More...
 
bool ResetPositionOnDeath = true
 if this is true, the character will automatically return to its initial position on revive 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 Patrol ()
 This method initiates all the required checks and moves the character More...
 
virtual void CheckForWalls ()
 Checks for a wall and changes direction if it meets one More...
 
bool DetectObstaclesRegularLayermask ()
 Returns true if an obstacle is colliding with this AI, using its controller layer masks More...
 
bool DetectObstaclesCustomLayermask ()
 Returns true if an obstacle is in front of the character, using a custom layer mask More...
 
virtual void CheckForHoles ()
 Checks for holes More...
 
virtual void ChangeDirection ()
 Changes the current movement direction More...
 
virtual void OnRevive ()
 When reviving we make sure our directions are properly setup More...
 
virtual void OnEnable ()
 On enable we start listening for OnRevive events More...
 
virtual void OnDisable ()
 On disable we stop listening for OnRevive events More...
 
- Protected Member Functions inherited from MoreMountains.Tools.AIAction
virtual void Awake ()
 On Awake we grab our AIBrain More...
 

Protected Attributes

CorgiController _controller
 
Character _character
 
Health _health
 
CharacterHorizontalMovement _characterHorizontalMovement
 
Vector2 _direction
 
Vector2 _startPosition
 
Vector2 _initialDirection
 
Vector3 _initialScale
 
float _distanceToTarget
 
Vector2 _raycastOrigin
 
RaycastHit2D _raycastHit2D
 
Vector2 _obstacleDirection
 
- Protected Attributes inherited from MoreMountains.Tools.AIAction
bool _initialized
 
AIBrain _brain
 

Additional Inherited Members

- Public Types inherited from MoreMountains.Tools.AIAction
enum  InitializationModes { InitializationModes.EveryTime, InitializationModes.OnlyOnce }
 
- Properties inherited from MoreMountains.Tools.AIAction
virtual bool ActionInProgress [get, set]
 
virtual bool ShouldInitialize [get]
 

Detailed Description

This Action will make the Character patrols until it (optionally) hits a wall or a hole.

Member Function Documentation

◆ ChangeDirection()

virtual void MoreMountains.CorgiEngine.AIActionPatrol.ChangeDirection ( )
protectedvirtual

Changes the current movement direction

◆ CheckForHoles()

virtual void MoreMountains.CorgiEngine.AIActionPatrol.CheckForHoles ( )
protectedvirtual

Checks for holes

◆ CheckForWalls()

virtual void MoreMountains.CorgiEngine.AIActionPatrol.CheckForWalls ( )
protectedvirtual

Checks for a wall and changes direction if it meets one

◆ DetectObstaclesCustomLayermask()

bool MoreMountains.CorgiEngine.AIActionPatrol.DetectObstaclesCustomLayermask ( )
protected

Returns true if an obstacle is in front of the character, using a custom layer mask

Returns

◆ DetectObstaclesRegularLayermask()

bool MoreMountains.CorgiEngine.AIActionPatrol.DetectObstaclesRegularLayermask ( )
protected

Returns true if an obstacle is colliding with this AI, using its controller layer masks

Returns

◆ Initialization()

override void MoreMountains.CorgiEngine.AIActionPatrol.Initialization ( )
virtual

On init we grab all the components we'll need

Reimplemented from MoreMountains.Tools.AIAction.

Reimplemented in MoreMountains.CorgiEngine.AIActionPatrolWithinBounds.

◆ OnDisable()

virtual void MoreMountains.CorgiEngine.AIActionPatrol.OnDisable ( )
protectedvirtual

On disable we stop listening for OnRevive events

◆ OnEnable()

virtual void MoreMountains.CorgiEngine.AIActionPatrol.OnEnable ( )
protectedvirtual

On enable we start listening for OnRevive events

◆ OnExitState()

override void MoreMountains.CorgiEngine.AIActionPatrol.OnExitState ( )
virtual

When exiting the state we reset our movement

Reimplemented from MoreMountains.Tools.AIAction.

Reimplemented in MoreMountains.CorgiEngine.AIActionPatrolWithinBounds.

◆ OnRevive()

virtual void MoreMountains.CorgiEngine.AIActionPatrol.OnRevive ( )
protectedvirtual

When reviving we make sure our directions are properly setup

◆ Patrol()

virtual void MoreMountains.CorgiEngine.AIActionPatrol.Patrol ( )
protectedvirtual

This method initiates all the required checks and moves the character

Reimplemented in MoreMountains.CorgiEngine.AIActionPatrolWithinBounds.

◆ PerformAction()

override void MoreMountains.CorgiEngine.AIActionPatrol.PerformAction ( )
virtual

On PerformAction we patrol

Implements MoreMountains.Tools.AIAction.

Member Data Documentation

◆ _character

Character MoreMountains.CorgiEngine.AIActionPatrol._character
protected

◆ _characterHorizontalMovement

CharacterHorizontalMovement MoreMountains.CorgiEngine.AIActionPatrol._characterHorizontalMovement
protected

◆ _controller

CorgiController MoreMountains.CorgiEngine.AIActionPatrol._controller
protected

◆ _direction

Vector2 MoreMountains.CorgiEngine.AIActionPatrol._direction
protected

◆ _distanceToTarget

float MoreMountains.CorgiEngine.AIActionPatrol._distanceToTarget
protected

◆ _health

Health MoreMountains.CorgiEngine.AIActionPatrol._health
protected

◆ _initialDirection

Vector2 MoreMountains.CorgiEngine.AIActionPatrol._initialDirection
protected

◆ _initialScale

Vector3 MoreMountains.CorgiEngine.AIActionPatrol._initialScale
protected

◆ _obstacleDirection

Vector2 MoreMountains.CorgiEngine.AIActionPatrol._obstacleDirection
protected

◆ _raycastHit2D

RaycastHit2D MoreMountains.CorgiEngine.AIActionPatrol._raycastHit2D
protected

◆ _raycastOrigin

Vector2 MoreMountains.CorgiEngine.AIActionPatrol._raycastOrigin
protected

◆ _startPosition

Vector2 MoreMountains.CorgiEngine.AIActionPatrol._startPosition
protected

◆ AvoidFalling

bool MoreMountains.CorgiEngine.AIActionPatrol.AvoidFalling = false

If set to true, the agent will try and avoid falling.

◆ ChangeDirectionOnWall

bool MoreMountains.CorgiEngine.AIActionPatrol.ChangeDirectionOnWall = true

If set to true, the agent will change direction when hitting a wall.

◆ HoleDetectionOffset

Vector3 MoreMountains.CorgiEngine.AIActionPatrol.HoleDetectionOffset = new Vector3(0, 0, 0)

The offset the hole detection should take into account.

◆ HoleDetectionRaycastLength

float MoreMountains.CorgiEngine.AIActionPatrol.HoleDetectionRaycastLength = 1f

the length of the ray cast to detect holes

◆ ObstaclesDetectionRaycastLength

float MoreMountains.CorgiEngine.AIActionPatrol.ObstaclesDetectionRaycastLength = 0.5f

the length of the horizontal raycast we should use to detect obstacles that may cause a direction change

◆ ObstaclesDetectionRaycastOrigin

Vector2 MoreMountains.CorgiEngine.AIActionPatrol.ObstaclesDetectionRaycastOrigin = new Vector2(0.5f, 0f)

the origin of the raycast (if casting against the same layer this object is on, the origin should be outside its collider, typically in front of it)

◆ ObstaclesLayermask

LayerMask MoreMountains.CorgiEngine.AIActionPatrol.ObstaclesLayermask = LayerManager.ObstaclesLayerMask

if using a custom layer mask, the list of layers considered as obstacles by this AI

◆ ResetPositionOnDeath

bool MoreMountains.CorgiEngine.AIActionPatrol.ResetPositionOnDeath = true

if this is true, the character will automatically return to its initial position on revive

◆ UseCustomLayermask

bool MoreMountains.CorgiEngine.AIActionPatrol.UseCustomLayermask = false

Whether to use a custom layermask, or simply use the platform mask defined at the character level.


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