Forum rules - please read before posting.

Playing Audio from prefab (in Project)?

Hello Chris, I want to play audio file that has 3 scripts inside prefab, 1 is Audio source, 2 is Sound (script) and 3. is Constant ID( I first place audio in empty game object and then place scripts and create prefab from it and now its in project), i wanna play that prefab from project and not from scene, when i play scene and watch actionlist behaviour it delete sound object from that field, but when that exact same prefab is in scene than it play normaly.

Small hack i did is that i create Add/Remove Object Node brefore and set "Add" and place thaht prefab, so basically he add that prefab in scene and then play it and then its all good, but that s not solution... so... did i miss something? 

Simillar thing was with Play Across the scenes so i got that about ConstantID script but i wonder why is that i cant play prefab from Project even if he has Constant ID script and its set to automatic and Retain in prefab is enabled.

Tnx Chris

Comments

  • edited October 2015
    I think i have achieved this by:

    creating object called music, added the relevant scripts as you mentioned.

    dragged that object into prefab folder to create a prefab of it.

    object in scene can now be deleted as have a prefab created

    In an interaction/cutscene = audio > play - thendrag the prefab from the folder

    I  think it will then use that prefab to play a sound.
  • edited October 2015
    What you're trying to do goes against the way it's designed to work.  A Sound object must be in the scene before it can be played.

    However in v1.49, I'll update the "Sound: Play" Action so that if you assign an AudioClip but no Sound object, then it'll play from the "Default sound" object as set in the Scene Manager.

    It'll be best used for short sound effects, so no music - otherwise continue to add it using "Object: Add or remove", or simply keep it in the scene at all times.
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.