Confirmed BUG: 2017.1.1p1+ Instantiate No Longer Spawns at Correct Position, Rotation b/c of Navmesh

When using this code:

(GameObject)Instantiate(Actors.ObjEnemy1, gameObject.transform.position, gameObject.transform.rotation);

This used to correctly spawn an actor (in this case ‘Enemy1’) at the current object (a spawner, which ‘gameObject’ is referring to) position and rotation.

After updating to Unity 2017.1.1 (p2) now it doesn’t do this, instead spawning at 0,0,0. No errors in the console. Does compile with incorrect behavior.

Any ideas how to fix this or a work-around?

-X

I think I’m working out that it’s spawning it at 0,0,0 and then trying to move it to the spawner’s location as fast as possible. If there’s level geometry in the way, it hits that and stops as close as possible. I think. It’s definitely not spawning just where the spawner is…

Need some help, guys. WTF. Is this a Unity bug?

I think I’ve isolated the engine bug: it’s the Navmesh.

If there’s no obstruction in the navmesh between 0,0,0 and the spawn point, it spawns correctly. If there is an obstruction and the navmesh is rebaked to account for this, they instantaneously appear only as far as they can go before the obstruction into the mesh from 0,0,0.

If the obstruction is placed but the navmesh is NOT rebaked (failing to take the obstruction into account), they spawn in the correct position.

This seems like a (new) bug in Unity…

It may be related to this from Patch 2017.1.1p1

Rolling back Editor to try to isolate further. I think the last version I had where this worked was Patch 2017.1.0p5

Yep, it may have been that.

Running it with 2017.1.1.f1 works fine. Problem disappears. So anything from Patch 2017.1.1p1 forward breaks this. My guess is, it’s the fix to 935105. It’s a bug with Unity Navmesh.

Unity? Any advice?

1 Like

This bug appears to be fixed in Unity 2017.2.0p1 :slight_smile:

1 Like