- Home /
Are CharacterControllers and NavMeshAgents meant to work together? If so, how?
Currently making a game for the 7DFPS which requires pathfinding and a fast, responsive player character controller.
Running navMeshAgents on the enemy characters seems to cause them to run to and OVERLAP the player character, unless I also use a NavMeshAgent on the PC, as detailed here: http://answers.unity3d.com/questions/247770/how-do-i-stop-an-enemy-navmeshagent-from-intersect.html
However, this introduces a number of new navigation problems - the player can no longer jump, the player cannot enter thin areas of the map and the player often gets stuck on steps. In addition, there is now significant lag between the player pressing a direction key and their avatar responding.
How should I create an FPS avatar for the player which allows me to use the navMesh feature of 3.5-4.2 (enemy characters collide with player, enemy characters navigate map, player character can jump and pass through narrow areas)?
--Rev
Answer by Reverend-Speed · Aug 19, 2013 at 07:51 PM
To answer my own question, write a script which sets
updatePosition = false;
and
updateRotation = false;
in the navMeshAgent and job done - everything will work perfectly smoothly.
Many thanks to tylo for this solution!
--Rev
Can you please elaborate on this solution as I'm trying to solve the same jumping problem- Do you include that in a script attached to the agent? I would greatly appreciate any guidance- thanks!
Hey @mdotstrange, I have spent a bit of time trying to do what he said, It was a bit confusing but here is a dirty version of it. It sufices enough to reenable the jumping
using UnityEngine; using System.Collections;
public class NavAgentPatch : $$anonymous$$onoBehaviour { public Nav$$anonymous$$eshAgent agent { get; private set; } // Use this for initialization void Start () { agent = GetComponentInChildren ();
agent.updatePosition = false;
agent.updateRotation = false;
}
}
Attach this to the play who has the navagent and character controller and it will make your jumping work again.
Answer by Doh09 · Sep 09, 2017 at 05:47 PM
I suspect using a NavMeshObstacle on the player would also work, didn't test it though.
Your answer
Follow this Question
Related Questions
How to make AICharacterController able to walk on walls and ceilings? 0 Answers
Navmesh Agent Custom Controller 0 Answers
Player "teleports" on top of NavMeshAgent collider if the Agent is too close 4 Answers
NavMeshAgent Calculate Jump Trajectory 1 Answer
How to jump using a CharacterController and NavMeshAgent 0 Answers