NavMeshAgent & UltimateCharacterLocomotion

GreedyVox

Active member
Hi Justin,

Needing help with warping a NavMeshAgent, first I will try and explain the situation, I have a server and client project with a procedural terrain using NavMeshComponents and baking the terrain chunks in real-time, on the server host, every agent spawning and working correctly doing their own thing, on the clients side when agents spawn they are stuck.

Before spawning agents on the server or clients, the location is sample for a correct position on the NavMeshSurface, this isn't such a biggie cause planning on warping agents to sync with the server, but that is also a problem, after warping an agent to a sampled sync point, will cause the UltimateCharacterLocomotion to reset the agent back to the previous point, but when using the SetPositionAndRotation will fix the agent from returning to the previous point, however the agent is stuck, have tests the agent warping on the server, with having the same results too.

Things that have seem to unstuck an agent, is by attacking or bumping a agent from its position, have also tried many other tests such as updatePosition, isStopped and disable components before warping an agent. Disabling the UltimateCharacterLocomotion on an agent through unity inspector when stuck, will show the agent gizmo walking around correctly to it's destination, while the agent prefab is stationary, after enabling the UltimateCharacterLocomotion again, the agent gizmo is sent straight back to the agent prefab location where it will remain stuck in place.

Screenshot from 2020-12-18 21-59-23.png

Hope this is explanation paints a good picture of the issues I'm having, have you any ideas how to fix? Included screenshots, the capsules are syncing points and agent destinations with arrows displaying the path, also the skeleton is walking on the spot and not moving.

Screenshot from 2020-12-18 21-58-18.png

Thanks mate, appreciate all your help!
 
So you're using the NavMeshComponents from Unity's github page? I haven't used that in awhile but it'll likely require some other type of integration since it's not the same as the built in navmesh components. This could explain the problems that you are having.
 
So you're using the NavMeshComponents from Unity's github page? I haven't used that in awhile but it'll likely require some other type of integration since it's not the same as the built in navmesh components. This could explain the problems that you are having.
Correct, using the github tool, however have tested with just a NavMeshAgent and eveything working, both Server and Client, it really seems like there is an issue NavMeshAgent & UltimateCharacterLocomotion, have run a debugger through the whole process, one thing I noticed was the InputVector was always returning default values instead of speed and direction.
 
Screenshot from 2020-12-18 23-25-03.pngScreenshot from 2020-12-18 23-23-49.pngScreenshot from 2020-12-18 23-22-32.png

Not sure if this is causing the problem, but applying move direction is always Vector3.zero even though the InputVector had values pass through for the controller.
 
Ran some more test just to confirm that the NavMeshSurface and NavMeshAgent working on both Server & Client, warping with no agent being stuck and path finding syncing between the Client & Server.

Screenshot from 2020-12-18 23-54-22.png

Everything is working perfect with this tests.

Will dig deeper into this issue, thinking it should work with UCC after test showing that once a agent has been unstuck on the Client, everything works, just warping and spawning on the Client not working using UCC.
 
So you're using the NavMeshComponents from Unity's github page? I haven't used that in awhile but it'll likely require some other type of integration since it's not the same as the built in navmesh components. This could explain the problems that you are having.
I went back to basic and preformed test using Unity NavMeshSurface and baked a basic plane in the scene, stripped down the Skeleton to bare bones components, then ran some tests with a Server Host, warping the NavMeshAgent around, unfortunately still getting stuck.

Quick question, preforming a straight forward agent warp should work yeah?
C#:
NavMeshAgent.Warp ()
My results of warping the agent is return to previous position instantly, but when setting the position for the agent, will stay at the warp position but is stuck in it's place.
C#:
UltimateCharacterLocomotion.SetPositionAndRotation()

Code for warping and setting position of the UCC.
C#:
if (NavMesh.SamplePosition (pos, out var hit, 10.0f, NavMesh.AllAreas)) {
    if (m_Agent.Warp (hit.position) && m_CharacterLocomotion != null) {
        m_CharacterLocomotion.SetPositionAndRotation (hit.position, transform.rotation, true);
    }
}

Screenshots of my settings, will keep on testing and debugging.

Screenshot from 2020-12-19 23-46-58.png
Screenshot from 2020-12-19 23-52-50.pngScreenshot from 2020-12-19 23-47-21.png
 
Last edited:
I went back to basic and preformed test using Unity NavMeshSurface and baked a basic plane in the scene, stripped down the Skeleton to bare bones components, then ran some tests with a Server Host, warping the NavMeshAgent around, unfortunately still getting stuck.
Finally I have managed to create a false positive, it’s a hack but it works, at lease now have finally an answer, at the end of the day, tells me my settings is not correct or my order of doing things is wrong.

C#:
if (NavMesh.SamplePosition (pos, out var hit, 1.0f, NavMesh.AllAreas)) {
    if (m_Agent.Warp (hit.position) && m_CharacterLocomotion != null) {
        m_CharacterLocomotion.SetPositionAndRotation (hit.position + 0.15f * Vector3.up,
                        Quaternion.LookRotation (Vector3.ProjectOnPlane (hit.position - m_Transform.position, m_CharacterLocomotion.Up)));
    }
}

Found out after warping the agent and setting it’s position and rotation the fall ability becomes inactive, so created a hack by lifting the agent position 15cm above the NavMesh to active the fall ability and wham bam thankyou ma'am, it worked.

C#:
+ 0.15f * Vector3.up

Tried activating the fall ability manually but without success, hoping someone might be able to help me out with my setting above this post, will keep on trying to set this right, I don't like hacks because most of the times it will cause more problems than it’s worth and also indicates of doing something wrong too.
 
Last edited:
Sorry for the journal style of writing for this post, wanted a history for future referencing, anyone else happens across this with a similar problem, the offset of the set position and rotation works well, been testing on server and clients without any more problems of agents getting stuck.
 
Top