AI character not moving

Shadowing

Member
When I use NavMeshAgent.destination = position. I can see the NavMeshAgent moving but with out the character with it.

So I then use m_NavMeshAgentMovement.SetDestination(position);
and the character doesnt move or the navmesh agent.






I set up a test scene and got the same issue.



 
Last edited:
I'm not sure about the first issue, but the destination you set of (0, 0, 100) is almost certainly off of your navmesh. I wouldn't expect the agent to move under those conditions. As a small aside, abilities are prioritized, so I'd move your Nav Mesh Agent Movement ability down to a lower priority. It should not preempt your character's death, certainly.
 
That was a good catch. didnt think about that position being off the nav mesh lol. Anyways i moved him to the middle of the map and changed it from 100 to 5. Issue remains. The navMeshAgent shakes as if he is trying to move.

Also tried demo character Nolan same issue.
 
Last edited:
You should use NavMeshAgentMovement.SetDestination, it won't know that you changed the position if you set the position directly. You are setting the destination every frame, maybe that is causing some problems?

In version 3 the split screen zone uses the NavMeshAgent to move but it looks like you are on version 2. I really do recommend updating since we will no longer be supporting version 2 soon.
 
ya. I tried it inside update and inside Start. I even put a Debug inside NavMeshAgentMovement.SetDestination. everything trips the ability runs but yet character doesnt move. Used my character and Nolan demo character.

Ya im on version 2.
I can't afford to update to version 3. I need a version that won't receive new features. Can't afford new bug etc.. Going for production finally. Plus everything works great just this problem :( I dont see any game engine updates taking place that will make it where i can't update the controller my self. Just some mild api depreciations.

I can try a new project I guess. Im pretty sure its gonna be the same result. I'm using pretty much 100 percent of the controller now. Thats how good UCC2 is. I didnt have to make any changes to it finally.
The error must be in the ability after it starts then idk.
 
Wish there was an AI using NavMeshAgentMovement on the demo.
Or is there? I havn't really looked the entire demo over. Maybe there i a AI unit out side the building?
When using NavMeshAGentMovement the character NavMeshAgent shakes back and forth as if its trying to move. Its like something has a hold on it.
 
This line trips. For my understanding of the ability thats the last line that moves its position.
m_CharacterLocomotion.MoveDirection = m_Transform.TransformDirection(moveDirection);

Code:
        public override void ApplyPosition()
        {
            if (m_NavMeshAgent.remainingDistance < m_NavMeshAgent.stoppingDistance) {
                // Prevent the character from jittering back and forth to land precisely on the target.
                var direction = m_Transform.InverseTransformPoint(m_NavMeshAgent.destination);
                var moveDirection = m_Transform.InverseTransformDirection(m_CharacterLocomotion.MoveDirection);
                if (Mathf.Abs(moveDirection.x) > Mathf.Abs(direction.x)) {
                    moveDirection.x = direction.x;
                }
                if (Mathf.Abs(moveDirection.z) > Mathf.Abs(direction.z)) {
                    moveDirection.z = direction.z;
                }

                Debug.Log("Move Character");
                m_CharacterLocomotion.MoveDirection = m_Transform.TransformDirection(moveDirection);
            }
        }
 
In version 2 we don't have a demo of the NavMeshAgent. You are right in that the MoveDirection call is what actually moves the character.
 
Alright
I created a new project. Installed UCC2 2.4.9
Load Demo make Nolan a prefab
In a new scene. created a terrain then go bake navigation
Setup Scene and Game with UCC2 wizard
Drag Nolan into the map at Vector3(400,0,400)

Attached this script to Nolan and assign its components in the inspector.
Hit play. Character doesnt move remains at x400, z400

Code:
using Opsive.UltimateCharacterController.Character;
using Opsive.UltimateCharacterController.Character.Abilities.AI;
using UnityEngine;
using UnityEngine.AI;

public class AITest : MonoBehaviour
{

    public UltimateCharacterLocomotion utimateCharacterLocomotion;
    public NavMeshAgent navMeshAgent;
    NavMeshAgentMovement m_NavMeshAgentMovement;

    private void Start() {
      m_NavMeshAgentMovement = utimateCharacterLocomotion.GetAbility<NavMeshAgentMovement>();

      m_NavMeshAgentMovement.SetDestination(new Vector3(0,0,5));

    }

}




I tried some other ideas disabling Input and Locomotion handler.
I noticed that CharacterIK and CharacterFootEffects disable when entering runtime. not sure why.
 
Unfortunately I am not sure what is going on. I no longer have a v2 project easily accessible and have been answering v2 questions from memory.

v3 is getting to be extremely stable and has a lot of fixes from v2 so I really do recommend upgrading.
 
Top