Forum rules - please read before posting.

Sound with Constant ID Issue

Working with AC 1.50i and Unity 5.3.2f1. I've been having some issues with sounds with constant IDs. When the sounds are played during game play, they are being duplicated in the scene with new IDs and sometimes missing the sound (script) component. This is causing the game to freeze. The sounds are in the top of the hierarchy and not in the "sounds" folder in the scenes, and they are all synced to their prefabs in the project folder. Sometimes my ActionLists on play are also loosing connection to the sounds for some reason (even if the action is not running, happens instantly on play). I've tried changing the constant IDs to manual and automatic, tried referencing the prefabs in project over the sounds in the scene, all sounds are set up properly. 

I am getting this error, which is probably the culprit but I'm not sure how to fix it:

InvalidOperationException: This cannot be used during play mode.
AC.UnityVersionHandler.CustomSetDirty (UnityEngine.Object _target, Boolean force) (at Assets/AdventureCreator/Scripts/Static/UnityVersionHandler.cs:410)
AC.ConstantID.SetNewID () (at Assets/AdventureCreator/Scripts/Save system/ConstantID.cs:172)
AC.ConstantID.CheckForDuplicateIDs () (at Assets/AdventureCreator/Scripts/Save system/ConstantID.cs:186)
AC.ConstantID.Update () (at Assets/AdventureCreator/Scripts/Save system/ConstantID.cs:136)


An additional note worth mentioning: When this problem first started cropping up I noticed that I bunch of sound effects that were previously working fine were now not playing at all. Upon further inspection, I figured out that all of their settings were changed on their own. They now had constant IDs and were set as looping "Music" instead of SFX, even though I did not change these settings and never gave them constant IDs. I reverted all of those back to sfx and haven't had any issue with them changing since that. Though the issue above still persists. 

Any help or insight is greatly appreciated! 

Comments

  • The error is unrelated, but a fix for it will be included in v1.51.

    It's important to separate any bugs you're encountering from AC's intended behaviour: if you reference any scene-based object (e.g. a Sound) from an ActionList asset file, then the Action's field will not always show the scene object (because, for example, a different scene is loaded).

    This is why Constant ID numbers exist: they are AC's way of allowing asset files to keep track of scene objects.  The only thing you need to be mindful of is the recorded Constant ID number beaneath the field in the Action - when the Action runs (again, in an ActionList asset), it will look for any scene object flagged with the matching Constant ID number.  Therefore, be careful not to change ID numbers manually, otherwise there'll be a mismatch and the Action may not be able to find it.

    To fix the duplicating sound / game crashing bug, I will need you to provide a list of steps that reproduce this error when followed.

    Your final mention of your Sound objects being given Constant ID numbers and set to Music sounds like you updated the original Sound prefab (in /Assets/AdventureCreator/Prefabs).  Because of how Unity works, this can happen if you click on "Apply" a the top of a scene-Sound's Inspector.  Be careful not to do this, as it will affect the root prefab (which you can override, however, by dragging your scene-Sound object into a new folder in your Project window, to make a new prefab).
  • edited March 2016
    The reason why I thought that error was related is because it gets thrown when the duplicate sound is made. 

    Steps to reproduce: 

    1) Create 3 scenes: room, hall, elevator

    2) Create global variable, fromHall

    3) In room scene, create a new sound, add music track to it/AudioClip, set it as "Music", play when pause, play across scenes and give it a constant ID. Drag into project file to create prefab, make sure IDs match. Move sound to top of Hierarchy. 

    4) In room scene, create a new interaction that starts music

    5) In room scene's opening cutscene, check variable "fromHall", if it's false, run interaction that turns on music, if true do nothing 

    6) In room scene, create a new sound, add AudioClip, keep as "SFX", set to play across scenes, give constant ID. Create prefab in project, make sure IDs match. Move sound to top of Hierarchy. 

    7) Create a hotspot in room, to play interaction that plays door SFX and loads the hall scene. 

    8) In the hall scene, add door SFX prefab to scenes hierarchy (top)

    9) In hall scene, create a hotspot that runs interaction that plays door SFX, sets fromHall to true and loads room scene 

    10) In hall scene, create a new sound, add AudioClip for elevatorEnter, keep as "SFX", make play across scenes and play when game is paused, add constant ID. Prefab it, check IDs. 

    11) In hall scene, create a hotspot that runs interaction that plays elevatorEnter sound and loads elevator scene

    12) Play from room scene  (music starts)

    13) Enter hall scene

    14) Enter room scene

    15) Enter hall scene (Now you'll see that elevatorEnter has been duplicated with different ID and the above error is thrown. This will happen every time you go into the room then come back to the hall, adding more dups and repeat errors) 

    16) Also, after going back and forth between room and hall a few times (doesn't happen the first few times) the music will eventually be duplicated in the room scene and stop running (similar to the elevator sound)

    17) In the hall, now attempt to enter the elevator, game stops (can't control character, but can still access menus) and new error is thrown: 
  • NullReferenceException: Object reference not set to an instance of an object
    AC.Sound.Play (Boolean loop) (at Assets/AdventureCreator/Scripts/Logic/Sound.cs:290)
    AC.ActionSound.Run () (at Assets/AdventureCreator/Scripts/Actions/ActionSound.cs:95)
    AC.ActionList+<RunAction>c__Iterator2.MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:289)
    UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
  • Oh, the sound prefab was changed btw, thanks for pointing that out! Not sure how it happened but I just reimported the original prefab again just to be safe. 
  • Thank you for the detailed steps.  I shall follow them and fix what I find for v1.51.
  • Awesome, thanks!
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.