navmesh agent not working after update to 2017.1
my navmesh agent won't move after i updated unity from 5.6 to 2017.1 i dont get an error or something it just wont move.
this is all i have in that script.
public void Start() {
agent = GetComponent<NavMeshAgent> ();
}
public void Update() {
agent.SetDestination (nextpos);
}
thanks.
btw, all it does is rotate in circles really slow even though my angular speed is 420
Did you find an answer to this. I am having the same problem here on 2017.1p1.
Answer by vgofaizen · Nov 13, 2017 at 02:11 AM
I started getting the same warning on dynamically instantiated prefabs after updating to 2017.2.0f3. I worked around this bug by disabling the NavMeshAgent on my prefab and setting its enabled flag to true within the Start function of the prefab.
This worked for me, thanks. Also on 2017.2.0f3.
Though it's an annoying workaround to need to implement, so I hope it gets fixed soon.
Here's my code (JS, but simple enough to convert to C#):
var nav$$anonymous$$eshHit : UnityEngine.AI.Nav$$anonymous$$eshHit;
UnityEngine.AI.Nav$$anonymous$$esh.SamplePosition(rPos, nav$$anonymous$$eshHit, 1f, UnityEngine.AI.Nav$$anonymous$$esh.AllAreas);
var npcObject : GameObject = Instantiate(npcPrefab, nav$$anonymous$$eshHit.position, rRot);
var nma : UnityEngine.AI.Nav$$anonymous$$eshAgent = npcObject.GetComponent(UnityEngine.AI.Nav$$anonymous$$eshAgent);
nma.enabled = true;
nma.Warp(nav$$anonymous$$eshHit.position);
Note that rPos and rRot are the predefined spawn position and rotation Vector3 values for the Instantiated prefab which has a disabled Nav$$anonymous$$eshAgent component attached.
Answer by retraffic · Sep 14, 2017 at 07:18 AM
I have the same problem, however, I'm getting a lot of warnings "Failed to create agent because it is not close enough to the NavMesh" that I didn't get before.
Answer by Baraff · Sep 14, 2017 at 10:20 AM
My problem showed no errors at all but the navmesh agents that work correctly under any other version of Unity, including 2017.1.0p5 just simply stopped working. They would no longer move to correct targets and often would run around in circles. It actually turned out that they always said they were not attached to a navmesh. Baking the navmesh again made no difference. I gave up and simply went back to 2017.1.0p5 where they work fine. I guess Unity will fix it at some point.
I've made some progress with my problem. It turned out only a few agents were too far away, but the others still didn't work.
I played around with the Obstacle Avoidance radius and as soon as it's equal or larger that 0.25 they worked again. $$anonymous$$ine were all set to lower though, so setting the angle on all agents to 0.25 fixed my problems.