Audiokinetic's Community Q&A is the forum where users can ask and answer questions within the Wwise and Strata communities. If you would like to get an answer from Audiokinetic's Technical support team, make sure you use the Support Tickets page.

0 votes
Problem with silence in interactive music using switches in Unity

Nice to meet you.
I would like to use Wwise's Switch on an enemy object in Unity to switch songs.

I have attached a Collider to the Enemy object, and InTrigger to switch the Switch when the Player object gets in range.
However, when the Player enters the range, the song switches, but when the Player goes out of range, the song is silent.

EventName is BGM and SwitchGroup is Field, switch is Nomal_Field and Enemy_Field.
To explain with switches, I want Unity to switch to Nomal_Field when playing, Enemy_Field when in range of an enemy, and Nomal_Field when out of range of an enemy.

The current situation is as follows
Unity version:2022.3.35f1
Wwise Version:2023.1.5.8522

WwiseGlobal
AkEvent→Trigger On:Start, Name:BGM
AkSwitch→Trigger On:Start, Name;Field/Nomal_Field
AkGameObj→Attenuation Scaling Factor:1, Only Use DefaulListeners is checked

Enemy Objects
WwiseSwitch.cs

using System.Collections;.
Generic; using System.Collections.
Generic; using UnityEngine; using UnityEngine.

public class WwiseSwitch : MonoBehaviour
{
    public GameObject SwitchGameobject; public string EnemyFieldSwitchName = EnemyFieldSwitchName
    public string EnemyFieldSwitchName = “Enemy_Field”;
    public string NormalFieldSwitchName = “Normal_Field”;

    // Start is called before the first frame update
    void Start()
    {
       
    }

    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == “Player”)
        {
            
            AkSoundEngine.SetSwitch(“Field”, EnemyFieldSwitchName, SwitchGameobject); }
           
        }
    }

    private void OnTriggerExit(Collider other)
    {
        if (other.tag == “Player”)
        {
            AkSoundEngine.SetSwitch(“Field”, NormalFieldSwitchName, SwitchGameobject); }
           
        }
    }
}

Anything I'm missing, please ask.
Thank you in advance for your response.
in General Discussion by 遥大 本間 (100 points)

Please sign-in or register to answer this question.

...