May 20, 2017 at 12:52 #20775CrytivoGamesParticipant
I’m using LoadBalancerComponent in my scene. At runtime I’m starting AIs and they work perfectly. LoadBalancerComponent shows exact number of running AIs.
Now, if I run/stop the scene then everything is smooth and LoadBalancerComponent shows 0 AIs at start. But, if I do following steps (see a bit below), then LoadBalancerComponent will show that it has some AIs running already, although I have not started any yet.
1 – Start scene.
2 – At runtime start few AIs
3 – reload same scene using SceneManager.LoadSceneAsync
Apparently there are some persistent data that is not cleared on scene load. Am I doing something wrong? What should I do to stop all AIs at once?
Thanks.May 22, 2017 at 10:26 #20791RamiKeymaster
Thanks for your post.
The load balancers are not automatically cleared on scene loads. Assuming that you are using the default LoadBalancedUtilityAIClient through the default UtilityAIComponent, they should unregister themselves OnDisable.
However, I’m not entirely sure how Unity manages the life cycle of game objects in a scene that is asynchronously reloaded, i.e. whether OnDisable is called on all game objects in that scene.
You could try simply iterating through all UtilityAIComponents and call Stop() on them, or disable them as that calls Stop() too.May 22, 2017 at 10:57 #20794CrytivoGamesParticipant
We don’t use UtilityAIComponent. We start our AIs via LoadBalancedUtilityAIClient. We do something like:C#12_aiClient = new LoadBalancedUtilityAIClient(AINameMap.AIName, this);_aiClient.Start();
A method like “AIManager.StopAllAIs” (or similar) would be handy. Of course I could try and register a list of all current AIs and then iterate it, but it seems like a hack to me.
You must be logged in to reply to this topic.