AgentController
A component for controlling agents (objects moved by NavMesh).
It controls the NavMeshAgent for movement that involves route search, and is responsible for passing the speed of the movement result to the parameters of Animator.
How to create
+ button in Hierarchy window
- Right-click on the Hierarchy or click the + button.
- Select “Arbor > AgentController” from the menu.
If created this way, the NavMeshAgent component will also be added.
Inspector window “Add Component” button
- Select the GameObject you want to add.
- Click the “Add Component” button in the Inspector.
- From the Component selection window, select “Arbor > Navigation > AgentController”.
Setting method
Reference settings
- Set the NavMeshAgent to be controlled in the Agent field.
- Set the Animator to be controlled in the Animator field.
Motion settings
Set to pass the value related to movement to the parameter of Animator.
The items that need to be set differ depending on how the AnimatorController is built.
This is an overview of various settings.
See AgentController in the Inspector reference for more information on the values.
Moving
Set a bool parameter that will be true if the agent is moving.
The judgment of moving is made by NavMeshAgent.velocity.magnitude > Moving Speed Threshold
.
Speed
Set the float parameter to pass the speed of movement.
The changed value is set according to the setting of Speed Type
.
Movement
Set when performing motion blending according to the moving direction.
The value changed according to the setting of Movement Type
is set.
Specifies which parameter to set each component of the resulting vector.
- Movement X
A float parameter that sets the X component. - Movement Y
A float parameter that sets the Y component. - Movement Z
A float parameter that sets the Z component.
Turn
Set the parameters to turn in the direction of movement.
Calculate the value from the movement speed according to Turn Type
.
Sample Position
Set whether to adjust the movement destination on NavMesh when moving using AgentMoveToPosition etc.
If Sample Position Enabled
is enabled, the position on the NavMesh will be adjusted within the radius of Sample Position Distance
centered on the destination position.
If there is no valid NavMesh position within the radius of Sample Position Distance
, the movement will fail and AgentMoveToPosition etc., it will transition to Cant Move
.
Traverse Off Mesh Link
Set how to pass through OffMeshLink(or NavMeshLink).
Please refer to OffMeshLinkSettings if you want to set the passage method individually for the manually placed OffMeshLink.
- Enable Traverse Off Mesh Link
The Agent Controller controls the passage of OffMeshLink.
If enabled, the NavMeshAgent‘s Auto Traverse Off Mesh Link must be disabled.
Jump Across
This is the setting when passing through the automatically placed Jump Across OffMeshLink.
This setting is also used if the manually placed OffMeshLink does not have an OffMeshLinkSettings component.
See Travarse Data for more information.
Drop Down
This is the setting when passing through the automatically placed Drop Down Off Mesh Link.
See Travarse Data for more information.
Traverse Data
- Set the Bool type parameter name of Animator that becomes true while passing in the Parameter field.
- Set the speed of rotation in the passing direction in the Angular Speed field.
- Set the jump height in the Jump Height field.
If 0 is specified, it will move linearly without becoming a parabolic trajectory. - Set the minimum moving speed in the Min Speed field.
Use the faster one compared to NavMeshAgent.speed - In the Start Wait field, set the wait method from the completion of rotation in the passing direction to the start of movement.
See Traverse Wait Data for more information. - In the End Wait field, set the wait method from the completion of the move to the switch to the move by NavMesh.
See Traverse Wait Data for more information.
Traverse Wait Data
- Set the wait method in the Type field.
- None
- Don't wait
- Time
- Wait for the passage of time
- Animation Event
- Wait for the Animation Event.
- Set the waiting time (seconds) in the Time field. (Only when Type is set to Time)
- Set the character string to be passed to AnimationEvent in the Event Name field. (Only when Type is set to AnimationEvent)
If you set Animation Event to Type, you need to set the event to Animation.
This section describes how to set it when a model such as FBX contains animation.
- Select a model
- Select the Animation tab
- Select the relevant animation
- Open the Events fold
- Move to the timing to call the playhead in the preview pane
- Click the button
- Set
TriggerEvent
in the Function field - Set a string with the same name as Event Name in the String field.
- Click the Apply button
For more information on AnimationEvent, see Unity - Manual: Events.
For information on how to edit AnimationClip events that are not included in the model, see Unity - Manual: Using Animation Events.
For event notification, AnimationTriggerEventReceiver is used internally.
If there is no AnimationTriggerEventReceiver in the GameObject of Animator at runtime, it will be added automatically.
If you want to avoid the running AddComponent, it is a good idea to add it in advance.