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.

2D Panning via RTPC/Game Sync in Unity, per-object instance

0 votes

I'm working in Unity 5.2.1, Wwise 2015.1.2 on Unity's "Into the Space" Demo project (!/content/20749).  The game is a basic galaga clone, you control a player ship while enemy ships drop down the screen.


I have a space engine sound (Wwise pink noise generator, if it matters) I'm trying to pan based on the position an enemy ship is instantiated on the X-axis.

I've set up a "RedShipPanning" Game Parameter which takes the ship's X-axis coordinate on start (I'll post the code below), this has a min/max value of -6/6 and defaults to zero (based off Unity's coordinates).  This parameter modifies the 2D panning RTPC on the engine sound itself, and does so just fine for a single object on the screen at a time.


However when a 2nd red ship is instantiated, the existing RTPC's value changes to match with the new ship's X-axis coordinate instead of having the RTPC act on a per-object basis.  So a ship to the right 3/4 the way down the screen suddenly jumps to the left as a new ship appears on that side at the top of the screen.  Super annoying.  Am I confusing how RTPC's should actually behave?  It's like they're acting as a mix buss instead of an effect on a specific object.


Here is the Unity code:

// Use this for initialization
    void Start ()
        GetComponent<Rigidbody2D>().velocity = -1 * transform.up * speed;    //Enemy Ship Movement
        AkSoundEngine.SetRTPCValue ("RedShipPanning", transform.position.x); //Set Wwise's "RedShipPanning" RTPC value based on the ship's initial x-coordinate


I have also attempted to add an object ID to the SetRTPCValue code, and this hasn't changed anything.


A friend mentioned this might be an issue to the game object being cloned in Unity - but I'm unfamiliar with exactly how that process works and affects Wwise.


Halp!  Thanks :)
asked Oct 29, 2015 in General Discussion by Adam C. (230 points)

1 Answer

0 votes

FYI I solved my issue by RTFMing and paying closer attention to MonoDevelop's help dialogues.

AkSoundEngine.SetRTPCValue takes 3 arguments - 1) RTPC name, 2) Value you wish to set, 3) GameObject to set the RTPC on.

In my case, being within the "EnemyRed_Script.cs" file that instantiated the Red Ship game object - my code ended up like this:

AkSoundEngine.SetRTPCValue ("RedShipPanning", transform.position.x, gameObject);

KISS principle ya'll.


FYI: If you do not add a valid gameObject in the 3rd argument - the RTPC value defaults globally to ALL gameObjects of said type.  This will cause all sorts of bad wonk, and is what happened to me.

answered Nov 13, 2015 by Adam C. (230 points)