Nav3DAgent: Methods - Nav3D Doc

Docy Child

Nav3DAgent: Methods

As mentioned above, you should use the Nav3DAgent script as a component for your game object and access it via GetComponent() .

The following public methods have been implemented to operate with Nav3DAgent:

  • Applies the description for your agent.
				
					public void SetDescription(Nav3DAgentDescription _Description)
				
			
  • Begins agent movement to the target point.
				
					public void MoveTo(
Vector3                  _Point,
Action                   _OnReach           = null,
Action<PathfindingError> _OnPathfindingFail = null,
float?                   _ReachGap          = null)
				
			

Parameters:

    • Vector3 _Point – target point.
    • Action _OnReach – a callback that invokes on target point has reached.
    • Action<PathfindingError> _OnPathfindingFail – pathfinding failure callback.
    • float? _ReachGap – target point reach distance.
  • Starts agent movement through the set of points. Pathfinding performs sequentially from each point to the next one, therefore the resulting path passes through all given goal points
				
					public void MoveToPoints(
Vector3[]              _Points,
bool                     _Loop                = false,
bool                     _StartFromClosest    = false,
bool                     _SkipUnpassableGoals = false,
float?                   _ReachGap            = null,
Action<Vector3>  _OnGoalPointPassed           = null,
Action                   _OnFinished          = null,
Action<PathfindingError> _OnPathfindingFail   = null)

				
			

Parameters:

  • Vector3[] _Points – a goal points.
  • bool _Loop – whether loop movement through the points. If true, then the agent will move through the points infinitely, going to the first one every time he reaches the last one.
  • bool_StartFromClosest – whether to start movement from the nearest point, and not from the first one.
  • bool_SkipUnpassableGoals – whether any point to which pathfinding was failed will be skipped. If option is disabled, the pathfinding failure for any pair of points will cause pathfinding to be aborted and _OnFail callback to be invoked.
  • float? _ReachGap – distance to reach any goal point.
  • Action<Vector3> _OnGoalPointPassed – a callback that invokes when any of the goal points are passed.
  • Action _OnFinished – a callback that invokes when the last goal is reached. This callback will never invoke if _Loop = true.
  • Action<PathfindingError> _OnPathfindingFail – pathfinding failure callback.
  • Starts the following of the transform movable target.

				
					public void FollowTarget(
Transform                _Target,
bool                     _FollowContinuously,
float                    _TargetOffsetUpdate,
float                    _TargetReachDistance   = 0,
Action                   _OnReach               = null,
Action                   _OnFail                = null,
Action<PathfindingError> _OnPathfindingFail     = null)

				
			

Parameters:

    • Transform _Target – a target transform to follow.
    • bool _FollowContinuously – whether to follow the target infinitely. If true, the agent will never finish following and never call _OnReach. When the target is reached the agent will merely wait until it continues the movement.
    • float _TargetOffsetUpdate – minimum target position delta that causes path re-search.
    • float _TargetReachDistance – distance to target transform required to finish following and invoke _OnReach.
    • Action _OnReach – on target reach callback.
    • Action _OnFail – callback that invokes if the target was destroyed or switched to inactive condition at the scene.
    • Action<PathfindingError> _OnPathfindingFail – pathfinding failure callback.
  • Stops any previous command (MoveTo, MoveToPoints, FollowTarget).
				
					public void Stop()
				
			
  • Returns agents array within radius _Radius that satisfy the given predicate _Predicate.
				
					public Nav3DAgent[] GetAgentsInRadius(float _Radius, Predicate<Nav3DAgent> _Predicate = null)
				
			

Examples of using Nav3DAgent can be found in the demo scenes located in Nav3D/Demo.

Nav3DSphereShell

Represents a spherical shell that is perceived by other agents as an object to a...

Nav3DEvader

There is also a separate controller, whose behavior consists of just avoiding ne...

Nav3DAgentManager

This class implements several methods to get a list of all Nav3DAgents located i...

Nav3DPathTester

We implemented a useful component (Nav3DPathTester), which can be used while bui...

PathfindingResult

Contains the pathfinding data and time statistics. Time statistics: public TimeS...

Nav3DPath: Events

For the convenience of notification when the pathfinding finished, the following...

Agent log

Here you can copy the contents of the agent log to the clipboard by clicking the...

Debug drawing

In this section, you can visualize the agent and his nearest environment. This s...

Creating and configuring an agent description from code

All Nav3DAgentDescription parameters configured in the description inspector c...

Nav3DManager

Nav3DManager is a helper static class. Can be useful for checking whether Nav3D ...

Nav3DInitializer

To use Nav3D in playmode, you need to initialize it. The Nav3DInitializer compon...

Nav3DObstacleLoader

To use the possibility of pre-baking obstacles on the scene in editor mode and t...

Chat Icon Close Icon
en_USEnglish