0
Not a bug

Failed to create agent warning and other instantiate errors

Crispy 1 month ago in Game Creator updated by Marti (Lead Developer) 1 month ago 2

https://streamable.com/tibwt

This just happens with Instantiate from pool Action. It doesn't happen with Instantiate Action.

A weird behavior I found when using Instantiate from pool, was the prefab I'm instantiating gets toggled off the moment the first prefab is instantiated, but the clones work just fine. However, I have to make sure to enable the object in the prefab before running the game again. Image:

I also got some other errors and warnings. The NullReferenceException and Unexpected top level layout group popped out of nowhere.

The "Some objects were not cleaned up..." popped up after exiting play mode while using the Instantiate Action. This does not happen with Instantiate from pool.

Unity version:
2018.4.10f1
Game Creator version:
1.0.3

Answer

Answer
Not a bug

Okay, step by step. The prefab being disabled is by design. I was hoping this would not be noticed, but seems it didn't go as planned :-P The reason why it disables the prefab is that, when instantiating the first instance, the pool automatically generates 50 instances (by default, but this can be changed) and disables them.

If the prefab wasn't disabled, the 50 instances would be active for a single frame, hence calling On Start Triggers and any other initialization methods attached. To solve this, we disable the prefab, creating disabled instances and postponing their initialization to whenever it is required.

On the other hand, creating instances of Characters using the pool system is not something we had contemplated. We'll open a ticket and have a look at it.

About the warnings, I wouldn't worry too much. When a character is instantiated using the Pool system it gets instantiated at position (0,0,0), which might not have a NavMesh nearby (hence the error). But this is not game breaking, since when the character is properly used, it should be teleported to a correct navmesh location.

These warnings are from Unity and there's little I can do about them. Just mind that they do not affect the gameplay experience.


After setting up multiple spawners, I got the "Failed to create agent" warning while using the Instantiate Action.

Here is how I'm spawning:

Answer
Not a bug

Okay, step by step. The prefab being disabled is by design. I was hoping this would not be noticed, but seems it didn't go as planned :-P The reason why it disables the prefab is that, when instantiating the first instance, the pool automatically generates 50 instances (by default, but this can be changed) and disables them.

If the prefab wasn't disabled, the 50 instances would be active for a single frame, hence calling On Start Triggers and any other initialization methods attached. To solve this, we disable the prefab, creating disabled instances and postponing their initialization to whenever it is required.

On the other hand, creating instances of Characters using the pool system is not something we had contemplated. We'll open a ticket and have a look at it.

About the warnings, I wouldn't worry too much. When a character is instantiated using the Pool system it gets instantiated at position (0,0,0), which might not have a NavMesh nearby (hence the error). But this is not game breaking, since when the character is properly used, it should be teleported to a correct navmesh location.

These warnings are from Unity and there's little I can do about them. Just mind that they do not affect the gameplay experience.