Forum rules - please read before posting.

Crash when going from scene without player

Got another crash bug in 1.71.2 when I go from a scene without a Player present to a scene with a local Player:

InvalidOperationException: Collection was modified; enumeration operation may not execute.
System.Collections.Generic.HashSet`1+Enumerator[T].MoveNext () (at :0)
AC.Sound.OnInitialiseScene () (at Assets/AdventureCreator/Scripts/Logic/Sound.cs:578)
AC.EventManager.Call_OnInitialiseScene () (at Assets/AdventureCreator/Scripts/Managers/EventManager.cs:1641)
AC.SaveSystem.InitAfterLoad () (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:608)
AC.MultiSceneChecker.Start () (at Assets/AdventureCreator/Scripts/Game engine/MultiSceneChecker.cs:63)

I have a scene without any players present. When switching to another scene with a local player present, the game crashes with an InvalidOperationException.

A basic workaround is of course to just add a player at an invisible place in the scene, but this did not happen in 1.70.

Comments

  • I'll attempt a recreation. What Sound components are present in the scene?

  • There are some Sound effects in both scenes, some prefabs and some scene sound effects. The player also has Footsteps sounds and a remember Footstep Sounds component. Both scenes have Ambient sounds as well.

  • Find line 578 in Sound.cs:

    foreach (Sound otherSound in KickStarter.stateHandler.Sounds)
    

    Replace it with:

    System.Collections.Generic.List<Sound> list = new System.Collections.Generic.List<Sound>(KickStarter.stateHandler.Sounds);
    foreach (Sound otherSound in list)
    

    Does that fix it?

  • The game does not crash, but I get another error. While the game doesn't crash, it was supposed to start a cutscene based on if the previous scene was this player-less scene. It appears to just disregard the OnStart actionlist when this new error occurs:

    MissingReferenceException: The object of type 'Sound' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    UnityEngine.Component.GetComponent[T] () (at C:/buildslave/unity/build/Runtime/Export/Component.bindings.cs:42)
    AC.Sound.get_audioSource () (at Assets/AdventureCreator/Scripts/Logic/Sound.cs:697)
    AC.Sound.OnInitialiseScene () (at Assets/AdventureCreator/Scripts/Logic/Sound.cs:568)
    AC.EventManager.Call_OnInitialiseScene () (at Assets/AdventureCreator/Scripts/Managers/EventManager.cs:1641)
    AC.SaveSystem.InitAfterLoad () (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:608)
    AC.MultiSceneChecker.Start () (at Assets/AdventureCreator/Scripts/Game engine/MultiSceneChecker.cs:63)

  • This isn't an issue I can recreate, and it may be something that's very unique to your setup.

    Can you PM me a test package that causes it to occur?

  • I will try, but there are so many dependencies and missing plugins/packages when exporting a unity package. I'll PM you a couple of scenes, sacrifice a goat and pray to the Unity gods that you can get them running :smile:

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.