The NavMeshAgentMovement ability will move the character along a Unity NavMesh. This ability will read the velocity from the NavMeshAgent and translate that into inputs that the Ultimate Character Controller can understand. This ability should be positioned higher than the Speed Change ability within the ability list.

Setup

  1. Select the + button in the ability list under the “Abilities” foldout of the Ultimate Character Locomotion component.
  2. Add the NavMeshAgent Movement ability. The NavMeshAgent component will automatically be added if it has not been already.
  3. Ensure the ability is positioned above the Speed Change ability. This will allow the Speed Change to change the NavMeshAgent’s speed.
  4. Ensure your scene has an active navigation mesh.

Speed

If you use root motion and adjust the speed on the NavMeshAgent component you’ll find that the speed parameter doesn’t change the character’s speed. This is because the animation is controlling the character’s speed rather than the NavMeshAgent. In order to change the speed of the character you should use the Speed Change ability which will then allow the correct animation to play based on the desired speed.

Set Destination

The NavMeshAgentMovement ability contains a SetDestination parameter which you can use to move the character using the NavMeshAgent.

using UnityEngine;
using Opsive.UltimateCharacterController.Character;
using Opsive.UltimateCharacterController.Character.Abilities;

public class MyObject : MonoBehaviour
{
    [Tooltip("The character that should start and stop the jump ability.")]
    [SerializeField] protected GameObject m_Character;
    [Tooltip("The NavMeshAgent destination.")]
    [SerializeField] protected Vector3 m_Destination;

    /// <summary>
    /// Sets the NavMeshAgentMovement destination.
    /// </summary>
    private void Start()
    {
        var characterLocomotion = m_Character.GetComponent<UltimateCharacterLocomotion>();
        var navMeshAgentMovement = characterLocomotion.GetAbility<NavMeshAgentMovement >();
        navMeshAgentMovement.SetDestination(m_Destination);
    }
}

Inspected Fields

Rotation Override

Specifies if the rotation should be overridden:

  • No Override: Does not override the rotation. Uses the NavMesh updateRotation property.
  • NavMesh: Forces the rotation according to the NavMesh path.
  • Character: Forces the rotation according to the character’s rotation.
Arrived Distance

The agent has arrived at the destination when the remaining distance is less than the arrived distance.

Manual Off Mesh Link Name

The name of the manual offmesh link that the character can traverse across.

Jump Across Manual Off Mesh Link

Should the jump ability be started on the manual offmesh link?