Closed lukemadera closed 4 years ago
Hi @lukemadera,
You're in luck - as of the next release (tentatively being released next week), Academy will be a singleton instead of a MonoBehavior. These changes are already on the master
branch if you want to try them out.
Thanks for the prompt reply @chriselion and good to hear! I'm not quite sure what the answer to my question is though - so the suggested approach would then be to only have 1 academy for the entire game (rather than 1 per scene)? Performance wise I could see that getting quite heavy, unless we can activate / deactivate agents & brains at will. Or would there be a way to break things up?
On the current release: I think you'll need to only have one Academy in the master scene. When you disable the Agent it should remove the Agent from the Academy: https://github.com/Unity-Technologies/ml-agents/blob/0.13.1/UnitySDK/Assets/ML-Agents/Scripts/Agent.cs#L290-L303 And I believe this happens when you destroy the GameObject that the Agent is attached to.
On the master branch / upcoming release: You don't need to add an Academy to the scene anymore (and in fact, you can't). The removal code is roughly the same, and called from Agent.OnDisable
Thanks! Yeah I removed the 2nd academy I had in the 2nd scene and that seemed to fix things. The docs say "1 academy in the scene" so I assumed it was 1 per scene, not 1 per game; but it errors if there's 1 per scene. Thanks for the help!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Is your feature request related to a problem? Please describe. I receive this error:
I currently have 3 scenes - 1 master (always loaded) and 2 different levels that are dynamically loaded based on the character's position in the world. I only receive this issue sometimes and I suspect it may be related to having multiple scenes. The documentation says to only have 1 Academy per scene but does not mention anything about multiple scenes (which I believe is common for many games). Do I need 1 academy per scene? Or one total (in the Master Scene)? Currently I have 1 academy in the master scene, and 1 in Scene A (level 1). I think the issue is that a game object (agent) in Scene A is being destroyed but uses the Master Academy, so then the academy tries to environment step but can't get the (now destroyed) agent. So I need to either properly destroy the agent (how would I do that?) so the Academy knows not to look for it anymore OR attach the scene A agents to the scene A academy and have 1 academy per scene so the agents and academy are both destroyed at the same time.
Describe the solution you'd like A description in the docs of how to work with multiple scenes. Specifically:
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Related to https://github.com/Unity-Technologies/ml-agents/issues/1666