World Default GameObject Injection World is null

  • A* version: 5.2.5
  • Unity version: 2022.3.50

What could this be from? I’m not doing other Entity/ECS stuff besides RVO FollowerEntity

Exception: World.DefaultGameObjectInjectionWorld is null. Has the world been destroyed?
Pathfinding.FollowerEntity.CreateEntity (Unity.Mathematics.float3 position, Unity.Mathematics.quaternion rotation, System.Single scale, Pathfinding.ECS.AgentCylinderShape& shape, Pathfinding.ECS.MovementSettings& movement, Pathfinding.ECS.AutoRepathPolicy& autoRepath, Pathfinding.ECS.ManagedState managedState, Pathfinding.OrientationMode orientation, Pathfinding.ECS.MovementPlaneSource movementPlaneSource, System.Boolean updatePosition, System.Boolean updateRotation, UnityEngine.PhysicsScene physicsScene) (at ./Packages/com.arongranberg.astar/Core/AI/FollowerEntity.cs:381)
Pathfinding.FollowerEntity.OnEnable () (at ./Packages/com.arongranberg.astar/Core/AI/FollowerEntity.cs:283)
UnityEngine.Object:Instantiate(GameObject, Vector3, Quaternion)

At some point I do delete the A* Component though and recreate it from a prefab.

Is your Entities package updated as well? Do you ever see this error if you don’t recreate the component? Also when you say A* Component, are you referring to AstarPath, with all your graph settings?

1 Like

I was on 1.2.3 which I’ve now updated to 1.3.8. The problem still exists.

Also when you say A* Component, are you referring to AstarPath, with all your graph settings?

Yes, AstarPath. I delete in two scenarios.

  1. When changing scenes. I have single scenes, not additive.
  2. When I return to my MainMenu, I delete AstarPath and basically everything except for some whitelisted stuff.

Do you ever see this error if you don’t recreate the component?

This is a good question. Specifically I now notice I only see it when I return to the MainMenu first. So I suspect I’m interfering with the A* system somehow, aside from AstarPath, which can seemingly be destroyed without problem between scenes.

Objects I destroy when returning to Main Menu includes “Batch Helper” which I see is created in BatchedEvents.CreateInstance. It’s a hidden DDOL gameobject, which explains why I haven’t seen it before. There’s also a mysterious “New Game Object” - some unknown gameobject created somewhere.

I’ll add “Batch Helper” to my whitelist so it’s not destroyed… and… retesting… nope.
Whitelisting “New Game Object” - and that fixed it.

It works! Thanks for your help!

Suggestion: if Astar critically depends on the Batch Helper gameobject, perhaps it needs a component to throw an exception when it’s destroyed, so it’s not a silent error manifesting more mysteriously later.

If the “New Game Object” is from the Astar package and not from Entities itself, then should be named and similarly treated. Fwiw, I cannot find when it’s created when I search the Entire Solution for either new GameObject(), or DontDestroyOnLoad(go), or “New Game Object”.

That indicates that Unity’s ECS world is not set up yet. Probably happens if your code runs before Unity’s world initialization systems. I’m not quite sure exactly when they run. But definitely on the first frame of the game, and probably on the same frame as you load a new scene.

Not destroying the batch helper is good :slight_smile:
I have no idea what that “New Game Object” is, though. To my knowledge it isn’t created by any part of the pathfinding system.