PathManager is both a helper class for building pathfinding within the UnityEditor and a utility class for accessing path-based movement in RAIN. More...
Public Member Functions | |
PathManager () | |
Default constructor. | |
void | ReInit (Agent agent) |
ReInit reinitializes the path manager to include any changed public variables, added files, etc. | |
void | CreateMoveLookTargets () |
Ensure that the moveTarget and lookTarget variables are not null. If they are null, create new objects, otherwise do nothing. | |
void | Awake () |
Awake is the Unity event handler for component activation. | |
bool | MoveTo (Agent agent, float deltaTime, Vector3 position) |
MoveTo will set the moveTarget to be a Vector target to the specified position, then call Move. | |
bool | Move (Agent agent, float deltaTime) |
Execute the move step - proceeding to the moveTarget based on the current path setup. | |
bool | GetPathToMoveTarget (Agent agent, float deltaTime, out PathBase path) |
Attempt to create a path from the agent to the current moveTarget. This method may work across multiple calls, only performing part of the pathfind during each call. | |
bool | LookAt (Agent agent, float deltaTime, Vector3 position) |
Set the lookTarget to a particular position and then Look at it. | |
bool | Look (Agent agent, float deltaTime) |
Execute the look step - turn to face the looktarget. | |
void | Avoid (Agent agent, float deltaTime) |
Execute the avoid step - perform obstacle avoidance movement. Note that this is called by Move automatically if obstacle avoidance is enabled. | |
void | LoadWaypointGraphFromFile (string filename, bool replaceExistingGraph) |
Set the waypointFilename to the specified filename, then load the graph. If a waypointgraph has already been loaded and replaceExistingGraph is false, this will do nothing The graph will be stored in the shared graph array for sharing with other AI. | |
void | LoadWaypointGraphFromCollection (GameObject collection, bool replaceExistingGraph) |
Load the waypointPathGraph from the named waypoint collection. If a graph is already loaded and replaceExistingGraph is false, this will do nothing. | |
void | LoadNavigationGridGraphFromFile (string filename, bool replaceExistingGraph) |
Load the gridPathGraph from a file. The graph will be stored in the shared graph array for sharing with other AI. | |
bool | SaveWaypointGraph () |
SaveWaypointGraph saves all waypoints and connections from the WaypointCollection into a waypoint file. | |
PathManager () | |
Default constructor. | |
void | ReInit () |
ReInit reinitializes the path manager to include any changed public variables, added files, etc. | |
void | Awake () |
Awake is the Unity event handler for component activation. | |
void | OnDrawGizmos () |
If we are drawing gizmos, attempt to draw the graph wireframe for any loaded recast quad field. | |
void | MoveTo (Agent agent, float deltaTime, Vector3 position) |
void | LookAt (Agent agent, float deltaTime, Vector3 position) |
void | Avoid (Agent agent, float deltaTime) |
bool | SaveWaypointGraph () |
SaveWaypointGraph saves all waypoints and connections from the WaypointCollection into a waypoint file. | |
bool | LoadQuadFieldPathGraph () |
Load the quad field path graph defined in the navmeshFilename. | |
bool | SaveQuadFieldGraph () |
SaveQuadFieldGraph saves a navigation graph associated with the entire level. | |
void | GenerateNavigationGraphForWaypoint (string filename, Waypoint wp) |
GenerateNavigationGraphForWaypoint generates a local navigation mesh between the waypoint and its neighbors. | |
Static Public Member Functions | |
static void | ClearSharedGraphs () |
Clear out all shared graphs so that the next request for a path graph will require a reload. | |
static PathGraph | RetrieveGraph (string filename) |
Retrieve a pathgraph based on a filename. Use this method to obtain a shared graph instead of loading a new one. | |
static void | StoreGraph (string filename, PathGraph pg) |
Store a loaded pathgraph for sharing. | |
static void | ReplaceGraph (string filename, PathGraph pg) |
Replace a shared graph with a new one. | |
Public Attributes | |
float | closeEnoughDistance = 0.1f |
How close should path following get before it considers itself "close enough" to stop moving. | |
float | closeEnoughAngle = 5f |
How close does orientation/facing behavior need to get before it considers itself "close enough" to stop turning. | |
float | faceBeforeMoveAngle = 90f |
How close do we have to be facing before we start moving. If we are at less than this angle, we will turn in place before moving. | |
bool | avoidObstacles = true |
avoidObstacles causes obstacle avoidance to be turned on. This works in conjunction with an obstacle avoidance sensor, which must be attached to the AI in order for avoidance to function correctly | |
float | avoidRadius = 0.5f |
avoidRadius defines the distance to avoid obstacles by | |
float | avoidanceSmoothingTime = 0.3f |
The amount of time to use as "memory" when smoothing obstacle avoidance. Too large a number will create strange wandering. To small a number will lead to jitter. | |
float | avoidanceChecksPerSecond = 30.0f |
Number of times per second collisions are checked for avoidance. | |
float | avoidanceStrength = 2.0f |
Avoidance Strength represents how much weight can be given to perpendicular avoidance vs forward movement. Example: 2.0 represents 2 parts avoidance (max) , one part forward. | |
bool | useNavigationGrid = false |
Should the AI attempt to use a navigation grid for determining walkable areas during pathfinding. | |
int | maxPathFindStepsPerFrame = 100 |
Number of pathfinding steps allowed per frame. Lower # means pathfinding could take longer, but will consume less processing per AI per frame. | |
string | navgridFilename |
Filename of the Navigation Grid when generating a mesh for the entire scene. | |
bool | useWaypointFile = false |
Should the AI attempt to use waypoint information from a file for movement around the scene. | |
string | waypointFilename |
Filename of the Waypoint navigation file. The file is loaded at runtime to define the Waypoint graph. | |
bool | useWaypointCollection = true |
Should the AI attempt to use an attached waypoint collection to move. | |
GameObject | waypointCollection |
waypointCollection is the GameObject parent of a collection of Waypoints that are managed by this PathManager | |
MoveLookTarget | moveTarget |
moveTarget is the object or position that we want to move to | |
MoveLookTarget | lookTarget |
lookTarget is the object or position that we want to look at | |
bool | allow3DLook = true |
Should the look behavior allow full axis freedom. | |
WaypointPathGraph | waypointPathGraph = null |
waypointPathGraph is the path graph used for Waypoint based pathfinding. This is usually set up automatically during the InitializeMovement call. | |
NavGridMultiRegionGraph | gridPathGraph = null |
gridPathGraph is the path graph used for Nav Grid pathfinding. This is usually set up automatically during the InitializeMovement call | |
float | minWaypointGraphRadius = 10.0f |
Minimum radius for generating recast graphs around a waypoint. Note that graphs are generated based on axis-aligned coordinates and not spheres, so this becomes a minimum square radius. | |
float | pathNodeYTolerance = 2.0f |
Pathgraph operations that determine the position of an object on the graph require a tolerance in the vertical (Y) axis to cull out high and low points, for example on overhands or under a bridge. pathNodeYTolerance defines how much higher or lower a graph node can be from the AI to be considered. | |
bool | showGraphWireframe = false |
showGraphWireFrame is used in the Unity Editor to toggle the wireframe visualization of the navigation graph | |
string | navmeshFilename |
Filename of the Navigation Mesh when generating a mesh for the entire level. | |
string[] | recastTagsToIgnore |
bool[] | recastLayerWhitelist = null |
recastLayerWhitelist is an array[32] of layer flags indicating whether the layer should be included in recast processing. If a layer is marked false, any colliders belonging to that layer are immediately culled from the processing list | |
bool | advancedMode = false |
advancedMode is an Editor toggle defining whether advanced Recast options are displayed | |
float | cellSize = 0.50f |
cellSize defines the cell unit size for rasterization during recast processing | |
float | stepUpHeight = 1.0f |
stepUpHeight defines the max vertical distance between neighboring spans in recast processing to allow the spans to remain as walkable neighbors | |
float | characterHeight = 2.0f |
characterHeight defines the minimum gap distance between overlapping spans in recast processing to allow the bottom span to remain walkable | |
float | characterWidth = 1.0f |
characterWidth defines a diameter around the character defining the space required for obstacle avoidance | |
float | maxHeightAlwaysWalkable = 0f |
maxHeightAlwaysWalkable defines a baseline height, under which spans are automatically marked walkable. This is a fixed span height irrespective of neighbors. It is primarily used to cull spikes in uneven terrain. Most users will want to leave this value set to 0 | |
float | maxSpanHeight = 0f |
maxSpanHeight defines the maximum height of any span, above which the span is considered unwalkable. This is a case-specific culling step used to eliminate high areas, for instance on castle walls. Most users will want to leave this value set to 0 | |
float | levelFloor = -100.0f |
levelFloor defines the lowest vertical position that will be considered allowable for recast processing. This is used to eliminate extra processing in low areas, and to cull items like skyboxes. This should be set below the minimum walkable position in the scene. | |
float | levelCeiling = 100.0f |
levelCeiling defines the highest vertical position that will be considered allowable for recast processing. This is used to eliminate extra processing in high areas, and to cull items like skyboxes. This should be set above the maximum walkable position in the scene. | |
float | maxWalkSlopeAngle = 45f |
maxWalkSlopeAngle determines the maximum angle that an AI can walk. Recast processing uses this value to cull steep geometry. | |
bool | useAllLevelGeometry = false |
useAllLevelGeometry causes recast processing to include level geometry in addition to colliders and terrain. This value will normally be false, but may be activated when extra detail processing is required. | |
bool | useColliders = true |
useColliders causes recast processing to include colliders in addition to level geometry and terrain. This value will normally be true. | |
bool | useTerrain = true |
useTerrain causes recast processing to include terrain colliders in addition to level geometry and object colliders. This value may be true or false depending on how ground is setup. |
PathManager is both a helper class for building pathfinding within the UnityEditor and a utility class for accessing path-based movement in RAIN.
RAIN.Path.PathManager.PathManager | ( | ) |
Default constructor.
RAIN.Path.PathManager.PathManager | ( | ) |
Default constructor.
void RAIN.Path.PathManager.Avoid | ( | Agent | agent, |
float | deltaTime | ||
) |
Execute the avoid step - perform obstacle avoidance movement. Note that this is called by Move automatically if obstacle avoidance is enabled.
agent | AI Agent |
deltaTime | Time step |
void RAIN.Path.PathManager.Awake | ( | ) |
Awake is the Unity event handler for component activation.
void RAIN.Path.PathManager.Awake | ( | ) |
Awake is the Unity event handler for component activation.
static void RAIN.Path.PathManager.ClearSharedGraphs | ( | ) | [static] |
Clear out all shared graphs so that the next request for a path graph will require a reload.
void RAIN.Path.PathManager.CreateMoveLookTargets | ( | ) |
Ensure that the moveTarget and lookTarget variables are not null. If they are null, create new objects, otherwise do nothing.
void RAIN.Path.PathManager.GenerateNavigationGraphForWaypoint | ( | string | filename, |
Waypoint | wp | ||
) |
GenerateNavigationGraphForWaypoint generates a local navigation mesh between the waypoint and its neighbors.
filename | the name of the file to write results into |
wp | the waypoint to generate a graph around |
Attempt to create a path from the agent to the current moveTarget. This method may work across multiple calls, only performing part of the pathfind during each call.
agent | The AI Agent |
deltaTime | Time step in seconds |
path | An out variable that will contain the path upon completion. |
void RAIN.Path.PathManager.LoadNavigationGridGraphFromFile | ( | string | filename, |
bool | replaceExistingGraph | ||
) |
Load the gridPathGraph from a file. The graph will be stored in the shared graph array for sharing with other AI.
filename | The grid graph filename to load, with no path or file extension |
replaceExistingGraph | if true, a new graph will be loaded. If the load fails, the current graph will not be replaced. |
bool RAIN.Path.PathManager.LoadQuadFieldPathGraph | ( | ) |
Load the quad field path graph defined in the navmeshFilename.
void RAIN.Path.PathManager.LoadWaypointGraphFromCollection | ( | GameObject | collection, |
bool | replaceExistingGraph | ||
) |
Load the waypointPathGraph from the named waypoint collection. If a graph is already loaded and replaceExistingGraph is false, this will do nothing.
collection | A GameObject whose children are Waypoint objects |
replaceExistingGraph | if true, any existing graph will be overwritten |
void RAIN.Path.PathManager.LoadWaypointGraphFromFile | ( | string | filename, |
bool | replaceExistingGraph | ||
) |
Set the waypointFilename to the specified filename, then load the graph. If a waypointgraph has already been loaded and replaceExistingGraph is false, this will do nothing The graph will be stored in the shared graph array for sharing with other AI.
filename | The waypoint graph filename to load, with no path or file extension |
replaceExistingGraph | if true, a new graph will always be loaded. |
bool RAIN.Path.PathManager.Look | ( | Agent | agent, |
float | deltaTime | ||
) |
Execute the look step - turn to face the looktarget.
agent | AI Agent |
deltaTime | Time step |
bool RAIN.Path.PathManager.LookAt | ( | Agent | agent, |
float | deltaTime, | ||
Vector3 | position | ||
) |
Set the lookTarget to a particular position and then Look at it.
agent | AI Agent |
deltaTime | Time step |
position | Vector3 position to look at |
bool RAIN.Path.PathManager.Move | ( | Agent | agent, |
float | deltaTime | ||
) |
Execute the move step - proceeding to the moveTarget based on the current path setup.
agent | AI Agent |
deltaTime | Time step |
bool RAIN.Path.PathManager.MoveTo | ( | Agent | agent, |
float | deltaTime, | ||
Vector3 | position | ||
) |
MoveTo will set the moveTarget to be a Vector target to the specified position, then call Move.
agent | The AI Agent |
deltaTime | Time step in seconds |
position | The Vector3 position to move toward |
void RAIN.Path.PathManager.OnDrawGizmos | ( | ) |
If we are drawing gizmos, attempt to draw the graph wireframe for any loaded recast quad field.
void RAIN.Path.PathManager.ReInit | ( | Agent | agent | ) |
ReInit reinitializes the path manager to include any changed public variables, added files, etc.
void RAIN.Path.PathManager.ReInit | ( | ) |
ReInit reinitializes the path manager to include any changed public variables, added files, etc.
static void RAIN.Path.PathManager.ReplaceGraph | ( | string | filename, |
PathGraph | pg | ||
) | [static] |
Replace a shared graph with a new one.
filename | The graph filename to replace, with no path or file extension |
pg | The PathGraph to store |
static PathGraph RAIN.Path.PathManager.RetrieveGraph | ( | string | filename | ) | [static] |
Retrieve a pathgraph based on a filename. Use this method to obtain a shared graph instead of loading a new one.
filename | The graph filename to retrieve, with no path or file extension |
bool RAIN.Path.PathManager.SaveQuadFieldGraph | ( | ) |
SaveQuadFieldGraph saves a navigation graph associated with the entire level.
bool RAIN.Path.PathManager.SaveWaypointGraph | ( | ) |
SaveWaypointGraph saves all waypoints and connections from the WaypointCollection into a waypoint file.
bool RAIN.Path.PathManager.SaveWaypointGraph | ( | ) |
SaveWaypointGraph saves all waypoints and connections from the WaypointCollection into a waypoint file.
static void RAIN.Path.PathManager.StoreGraph | ( | string | filename, |
PathGraph | pg | ||
) | [static] |
Store a loaded pathgraph for sharing.
filename | The graph filename to store, with no path or file extension |
pg | The PathGraph to store |
bool RAIN.Path.PathManager.advancedMode = false |
advancedMode is an Editor toggle defining whether advanced Recast options are displayed
bool RAIN.Path.PathManager.allow3DLook = true |
Should the look behavior allow full axis freedom.
float RAIN::Path.PathManager::avoidanceChecksPerSecond = 30.0f |
Number of times per second collisions are checked for avoidance.
float RAIN::Path.PathManager::avoidanceSmoothingTime = 0.3f |
The amount of time to use as "memory" when smoothing obstacle avoidance. Too large a number will create strange wandering. To small a number will lead to jitter.
float RAIN::Path.PathManager::avoidanceStrength = 2.0f |
Avoidance Strength represents how much weight can be given to perpendicular avoidance vs forward movement. Example: 2.0 represents 2 parts avoidance (max) , one part forward.
bool RAIN::Path.PathManager::avoidObstacles = true |
avoidObstacles causes obstacle avoidance to be turned on. This works in conjunction with an obstacle avoidance sensor, which must be attached to the AI in order for avoidance to function correctly
float RAIN.Path.PathManager.avoidRadius = 0.5f |
avoidRadius defines the distance to avoid obstacles by
float RAIN.Path.PathManager.cellSize = 0.50f |
cellSize defines the cell unit size for rasterization during recast processing
float RAIN.Path.PathManager.characterHeight = 2.0f |
characterHeight defines the minimum gap distance between overlapping spans in recast processing to allow the bottom span to remain walkable
float RAIN.Path.PathManager.characterWidth = 1.0f |
characterWidth defines a diameter around the character defining the space required for obstacle avoidance
float RAIN.Path.PathManager.closeEnoughAngle = 5f |
How close does orientation/facing behavior need to get before it considers itself "close enough" to stop turning.
float RAIN::Path.PathManager::closeEnoughDistance = 0.1f |
How close should path following get before it considers itself "close enough" to stop moving.
float RAIN.Path.PathManager.faceBeforeMoveAngle = 90f |
How close do we have to be facing before we start moving. If we are at less than this angle, we will turn in place before moving.
gridPathGraph is the path graph used for Nav Grid pathfinding. This is usually set up automatically during the InitializeMovement call
float RAIN.Path.PathManager.levelCeiling = 100.0f |
levelCeiling defines the highest vertical position that will be considered allowable for recast processing. This is used to eliminate extra processing in high areas, and to cull items like skyboxes. This should be set above the maximum walkable position in the scene.
float RAIN.Path.PathManager.levelFloor = -100.0f |
levelFloor defines the lowest vertical position that will be considered allowable for recast processing. This is used to eliminate extra processing in low areas, and to cull items like skyboxes. This should be set below the minimum walkable position in the scene.
lookTarget is the object or position that we want to look at
maxHeightAlwaysWalkable defines a baseline height, under which spans are automatically marked walkable. This is a fixed span height irrespective of neighbors. It is primarily used to cull spikes in uneven terrain. Most users will want to leave this value set to 0
Number of pathfinding steps allowed per frame. Lower # means pathfinding could take longer, but will consume less processing per AI per frame.
float RAIN.Path.PathManager.maxSpanHeight = 0f |
maxSpanHeight defines the maximum height of any span, above which the span is considered unwalkable. This is a case-specific culling step used to eliminate high areas, for instance on castle walls. Most users will want to leave this value set to 0
float RAIN.Path.PathManager.maxWalkSlopeAngle = 45f |
maxWalkSlopeAngle determines the maximum angle that an AI can walk. Recast processing uses this value to cull steep geometry.
float RAIN.Path.PathManager.minWaypointGraphRadius = 10.0f |
Minimum radius for generating recast graphs around a waypoint. Note that graphs are generated based on axis-aligned coordinates and not spheres, so this becomes a minimum square radius.
moveTarget is the object or position that we want to move to
Filename of the Navigation Grid when generating a mesh for the entire scene.
Filename of the Navigation Mesh when generating a mesh for the entire level.
float RAIN.Path.PathManager.pathNodeYTolerance = 2.0f |
Pathgraph operations that determine the position of an object on the graph require a tolerance in the vertical (Y) axis to cull out high and low points, for example on overhands or under a bridge. pathNodeYTolerance defines how much higher or lower a graph node can be from the AI to be considered.
bool [] RAIN.Path.PathManager.recastLayerWhitelist = null |
recastLayerWhitelist is an array[32] of layer flags indicating whether the layer should be included in recast processing. If a layer is marked false, any colliders belonging to that layer are immediately culled from the processing list
bool RAIN.Path.PathManager.showGraphWireframe = false |
showGraphWireFrame is used in the Unity Editor to toggle the wireframe visualization of the navigation graph
float RAIN.Path.PathManager.stepUpHeight = 1.0f |
stepUpHeight defines the max vertical distance between neighboring spans in recast processing to allow the spans to remain as walkable neighbors
bool RAIN.Path.PathManager.useAllLevelGeometry = false |
useAllLevelGeometry causes recast processing to include level geometry in addition to colliders and terrain. This value will normally be false, but may be activated when extra detail processing is required.
bool RAIN.Path.PathManager.useColliders = true |
useColliders causes recast processing to include colliders in addition to level geometry and terrain. This value will normally be true.
bool RAIN.Path.PathManager.useNavigationGrid = false |
Should the AI attempt to use a navigation grid for determining walkable areas during pathfinding.
bool RAIN.Path.PathManager.useTerrain = true |
useTerrain causes recast processing to include terrain colliders in addition to level geometry and object colliders. This value may be true or false depending on how ground is setup.
bool RAIN.Path.PathManager.useWaypointCollection = true |
Should the AI attempt to use an attached waypoint collection to move.
bool RAIN.Path.PathManager.useWaypointFile = false |
Should the AI attempt to use waypoint information from a file for movement around the scene.
GameObject RAIN::Path.PathManager::waypointCollection |
waypointCollection is the GameObject parent of a collection of Waypoints that are managed by this PathManager
waypointPathGraph is the path graph used for Waypoint based pathfinding. This is usually set up automatically during the InitializeMovement call.