Skip to content

Crash after reloading the scene #1510

@13Flo

Description

@13Flo

Getting the following error since I migrated to 0.6. It happens when reloading the scene with SceneManager.LoadScene in Play mode (using my test scene basically). This was not happening with 0.5

ArgumentException: An item with the same key has already been added. Key: OpponentAI (OpponentAI) System.Collections.Generic.Dictionary2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at :0)
System.Collections.Generic.Dictionary2[TKey,TValue].Add (TKey key, TValue value) (at <ac823e2bb42b41bda67924a45a0173c3>:0) MLAgents.Brain.SendState (MLAgents.Agent agent, MLAgents.AgentInfo info) (at Assets/ML-Agents/Scripts/Brain.cs:56) MLAgents.Agent.SendInfoToBrain () (at Assets/ML-Agents/Scripts/Agent.cs:619) MLAgents.Agent.SendInfo () (at Assets/ML-Agents/Scripts/Agent.cs:984) MLAgents.Academy.EnvironmentStep () (at Assets/ML-Agents/Scripts/Academy.cs:583) MLAgents.Academy.FixedUpdate () (at Assets/ML-Agents/Scripts/Academy.cs:611)

It seems related to line 56 in Brain.cs:
agentInfos.Add(agent, info);

I tried to add a ContainsKey() check and the error went away but the agent is then not taking any action.

Any idea?

Metadata

Metadata

Labels

bugIssue describes a potential bug in ml-agents.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions