Corgi Engine  v9.1
MoreMountains.CorgiEngine.AIWalk Class Reference

Add this component to a CorgiController2D and it will walk, turn back when it hits a wall, and try and avoid holes if you ask it to. More...

Inheritance diagram for MoreMountains.CorgiEngine.AIWalk:
MoreMountains.CorgiEngine.CorgiMonoBehaviour

Public Types

enum  WalkBehaviours { WalkBehaviours.Patrol, WalkBehaviours.MoveOnSight }
 The agent's possible walk behaviours : patrol will have it walk in random directions until a wall or hole is hit, MoveOnSight will make the agent move only when "seeing" a target. More...
 

Public Attributes

WalkBehaviours WalkBehaviour = WalkBehaviours.Patrol
 The agent's walk behaviour. More...
 
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...
 
float ViewDistance = 10f
 The maximum distance at which the AI can see the target. More...
 
float StopDistance = 1f
 the horizontal distance from its target at which the agent will stop moving. Between that distance and the walk distance, the agent will slow down progressively More...
 
Vector3 MoveOnSightRayOffset = new Vector3(0,0,0)
 The offset to apply to the raycast origin point (by default the position of the object) More...
 
LayerMask MoveOnSightLayer = LayerManager.PlayerLayerMask
 the layer mask to use to detect targets More...
 
LayerMask MoveOnSightObstaclesLayer = LayerManager.ObstaclesLayerMask
 the layer mask of the sight obstacles (usually platforms) More...
 
Vector3 ObstacleDetectionRayOffset = new Vector3(0,0,0)
 The offset to apply to the raycast origin point (by default the position of the object) More...
 
bool ResetPositionOnDeath = true
 if this is true, the character will automatically return to its initial position on revive More...
 

Protected Member Functions

virtual void Start ()
 Initialization More...
 
virtual void Initialization ()
 
virtual void Update ()
 Every frame, moves the agent and checks if it can shoot at the player. More...
 
virtual void CheckForWalls ()
 Checks for a wall and changes direction if it meets one More...
 
virtual void CheckForHoles ()
 Checks for holes More...
 
virtual void CheckForTarget ()
 Casts a ray (if needed) to see if a target is in sight. If yes, moves towards it. More...
 
virtual void ChangeDirection ()
 Changes the agent's direction and flips its transform More...
 
virtual void OnRevive ()
 
virtual void OnEnable ()
 When the player respawns, we reinstate this agent. More...
 
virtual void OnDisable ()
 

Protected Attributes

CorgiController _controller
 
Character _character
 
Health _health
 
CharacterHorizontalMovement _characterHorizontalMovement
 
Vector2 _direction
 
Vector2 _startPosition
 
Vector2 _initialDirection
 
Vector3 _initialScale
 
float _distanceToTarget
 
Vector2 _raycastOrigin
 
Vector2 _offset
 

Detailed Description

Add this component to a CorgiController2D and it will walk, turn back when it hits a wall, and try and avoid holes if you ask it to.

Member Enumeration Documentation

◆ WalkBehaviours

The agent's possible walk behaviours : patrol will have it walk in random directions until a wall or hole is hit, MoveOnSight will make the agent move only when "seeing" a target.

Enumerator
Patrol 
MoveOnSight 

Member Function Documentation

◆ ChangeDirection()

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

Changes the agent's direction and flips its transform

◆ CheckForHoles()

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

Checks for holes

◆ CheckForTarget()

virtual void MoreMountains.CorgiEngine.AIWalk.CheckForTarget ( )
protectedvirtual

Casts a ray (if needed) to see if a target is in sight. If yes, moves towards it.

◆ CheckForWalls()

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

Checks for a wall and changes direction if it meets one

◆ Initialization()

virtual void MoreMountains.CorgiEngine.AIWalk.Initialization ( )
protectedvirtual

◆ OnDisable()

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

◆ OnEnable()

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

When the player respawns, we reinstate this agent.

Parameters
checkpointCheckpoint.
playerPlayer.

◆ OnRevive()

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

◆ Start()

virtual void MoreMountains.CorgiEngine.AIWalk.Start ( )
protectedvirtual

Initialization

◆ Update()

virtual void MoreMountains.CorgiEngine.AIWalk.Update ( )
protectedvirtual

Every frame, moves the agent and checks if it can shoot at the player.

Member Data Documentation

◆ _character

Character MoreMountains.CorgiEngine.AIWalk._character
protected

◆ _characterHorizontalMovement

CharacterHorizontalMovement MoreMountains.CorgiEngine.AIWalk._characterHorizontalMovement
protected

◆ _controller

CorgiController MoreMountains.CorgiEngine.AIWalk._controller
protected

◆ _direction

Vector2 MoreMountains.CorgiEngine.AIWalk._direction
protected

◆ _distanceToTarget

float MoreMountains.CorgiEngine.AIWalk._distanceToTarget
protected

◆ _health

Health MoreMountains.CorgiEngine.AIWalk._health
protected

◆ _initialDirection

Vector2 MoreMountains.CorgiEngine.AIWalk._initialDirection
protected

◆ _initialScale

Vector3 MoreMountains.CorgiEngine.AIWalk._initialScale
protected

◆ _offset

Vector2 MoreMountains.CorgiEngine.AIWalk._offset
protected

◆ _raycastOrigin

Vector2 MoreMountains.CorgiEngine.AIWalk._raycastOrigin
protected

◆ _startPosition

Vector2 MoreMountains.CorgiEngine.AIWalk._startPosition
protected

◆ AvoidFalling

bool MoreMountains.CorgiEngine.AIWalk.AvoidFalling = false

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

◆ ChangeDirectionOnWall

bool MoreMountains.CorgiEngine.AIWalk.ChangeDirectionOnWall = true

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

◆ HoleDetectionOffset

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

The offset the hole detection should take into account.

◆ HoleDetectionRaycastLength

float MoreMountains.CorgiEngine.AIWalk.HoleDetectionRaycastLength =1f

the length of the ray cast to detect holes

◆ MoveOnSightLayer

LayerMask MoreMountains.CorgiEngine.AIWalk.MoveOnSightLayer = LayerManager.PlayerLayerMask

the layer mask to use to detect targets

◆ MoveOnSightObstaclesLayer

LayerMask MoreMountains.CorgiEngine.AIWalk.MoveOnSightObstaclesLayer = LayerManager.ObstaclesLayerMask

the layer mask of the sight obstacles (usually platforms)

◆ MoveOnSightRayOffset

Vector3 MoreMountains.CorgiEngine.AIWalk.MoveOnSightRayOffset = new Vector3(0,0,0)

The offset to apply to the raycast origin point (by default the position of the object)

◆ ObstacleDetectionRayOffset

Vector3 MoreMountains.CorgiEngine.AIWalk.ObstacleDetectionRayOffset = new Vector3(0,0,0)

The offset to apply to the raycast origin point (by default the position of the object)

◆ ResetPositionOnDeath

bool MoreMountains.CorgiEngine.AIWalk.ResetPositionOnDeath = true

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

◆ StopDistance

float MoreMountains.CorgiEngine.AIWalk.StopDistance = 1f

the horizontal distance from its target at which the agent will stop moving. Between that distance and the walk distance, the agent will slow down progressively

◆ ViewDistance

float MoreMountains.CorgiEngine.AIWalk.ViewDistance = 10f

The maximum distance at which the AI can see the target.

◆ WalkBehaviour

WalkBehaviours MoreMountains.CorgiEngine.AIWalk.WalkBehaviour = WalkBehaviours.Patrol

The agent's walk behaviour.


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