Forum rules - please read before posting.

AC Sound issues

Hello again.

I am having some issues with AC sound. I set up several sounds using the Sound script with Audio Source.

I am using some code to manage which sound to play with what intensity:
x.audio.ChangeRelativeVolume(0f);
x.audio.Play(true);

My issue is following: When I enter play mode from another scene and switch to this one with sounds, they won't work/play. But if I start Play mode from this scene everything works fine. 
I first thought that Unity has a bug so I set up a PlayOnAwak sound but this one works fine.

Am I doing something wrong? Thanks for any help in advance!

Comments

  • What do "x" and "audio" refer to?  And what are your Unity/AC version numbers?

    Setting a relative volume to "0" will mute it - so unless that's just an example code you're posting I wouldn't expect to hear anything even if the sound itself is technically playing.

    At what point does your script play the sound?  When the scene begins?

    Also note that the Play On Awake option isn't recommended, since it kicks in before AC has a chance to set the correct volume based on the game's Options (SFX volume, etc).

    To have a sound play when the scene begins, with a given relative volume, it's recommend to use the Sound: Change volume and Sound: Play Actions in your scene's OnStart cutscene.
  • edited July 2018
    x is an object that hold a Sound field. I did set it to 0 in Awake and later on to 1 when needed(Update checks for something and sets it to 1 when true). I'm pretty sure the code is not the issue since it works as it should when I start from this scene, butt as said, when I come to this scene from another one in Play mode, it won't work.

    I can't use Actions here since I need the Update function and set volumes accordingly. 

    I also checked in code if .Play gets called on Awake, and it does, so I really have no other idea. 

    What other information would you need to have more insight on this issue?

    PS. Unity version is 2018.1.6f1, AC: 1.63.2(latest)

    Edit: I first had that code snippet in Awake() but I now put it in Start() because I thought that AC isn't initialized in Awake yet.  Sadly, no changes.
    Also, Play on Awake is off for all Sound objects
  • Without seeing the exact code, I can't do much more than speculate.  The "Relative volume" slider in the Inspector should update according to what you set it - does it appear correct?

    I'm not understanding why you'd want to play it at zero volume in the first place, though.  If you can explain the intention, and share the actual script you're running (simplified to just show the issue if its complex), I can reply better.
  • The relative volume is indeed 0 or 1 as it should be. I now found out, that the Volume sliders in Audio source for each object is behaving erratic. Their values are 0.8999992 for the one with relative vol: 1 and 9.809089e-45 for those with relative volume 0. Either I am not using ChangeRelativeVolume() correctly or it has a bug. 

    Maybe another clue: those sounds are played for a few frames at the beginning, probably because ChangeRelativeVolume(0f) doesn't kick in right away after .Play(). 
    Now when I enter this scene from another one, this doesn't happen. 
  • It works now, although I have no clue why. I removed RememberSound from all sound objects. I don't know why it would prevent the sound to play, tho.
  • The RememberSound component stores, and restores, the relative volume.  When you load the scene from another, it's data will be loaded and overwritten.

    If you're calling your code in Awake(), then that's likely occuring before the RememberSound has a chance to kick in - meaning your volume change is immediately changed by it afterwards.  You may have luck moving it to Start(), and possible by affecting your own script's Script Execution Order value.
  • I was thinking of the same and moves it to Start() a while back with no succes. But as stated above, I resolved this issue by removing RememberSound. 
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.