Wwise Authoring is currently not compatible with macOS Catalina. We recommend that you remain on the current version of your operating system until further notice.

Community Q&A

Where Wwise users help each other out!

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

[Unity] RTPC.SetGlobalValue not working [closed]

0 votes

I created a fresh LWRP project in unity 2019.2.5f1 and integrated the latest version of Wwise and linked with an existing Wwise project.

The Wwise project has an Ambience Event, with two RTPCs.

The Event works fine on its own, but I simply cannot affect the RTPCs using the .SetGlobalValue() function.

The .SetValue() function works fine and I can tweak both RTPCs perfectly normally! But I need to be able to set this RTPC globally.

Thanks for any help!

closed with the note: Both parameters were using the "Distance" built-in parameter.
asked Nov 4 in General Discussion by E V. (110 points)
closed Nov 5 by Mads Maretty S. (Audiokinetic)

1 Answer

+1 vote
Hey E V,

In what order do you use the .SetGlobalValue and .SetValue functions?
I'm asking because if you use .SetValue() function on an RTPC, then that value will override whatever global value you set afterwards.
There's more about that here: https://www.audiokinetic.com/courses/wwise301/?source=wwise301&id=Game_Parameters#read

Does this help?
answered Nov 4 by Mads Maretty S. (Audiokinetic) (1,600 points)
Hey Mads, sorry but it doesn't really help
I use the functions exclusively:
When trying to use one, I *replace* the other with it (and change whatever should be between the parentheses of course)

I've since tried printing both the global RTPC value, and RTPC value of the gameObject (the "local" one) when trying out the .SetGlobalValue function. Only the "Global" value is updated, and the local one stays at default.

I don't know if this is normal or not, but I'd expect changing the Global value to change the "Local" one as well ?

Thanks
Hmm replace? Did you set and get the value inside the same function, like this?

RTPC1.SetValue(gameObject, 42f);
print("RTPC value: "+RTPC1.GetValue(gameObject));

If so, the system may not have had time to set the RTPC. So if you have it designed anything like this...

RTPC1.SetValue(gameObject, 42f);
print("RTPC value: "+RTPC1.GetValue(gameObject));
RTPC2.SetGlobalValue(RTPC1.GetValue(gameObject));

... you'll end up setting the second RTPC, to the default number of RTPC1.

Maybe for testing, try to make a coroutine like this and see if that works.

    private void Start()
    {
        StartCoroutine(SomeCoroutine());
    }
    IEnumerator SomeCoroutine()
    {
        RTPC1.SetValue(gameObject, 42f);
        print("RTPC1 value not yet applied: " + RTPC1.GetValue(gameObject));
        yield return new WaitForEndOfFrame();
        print("RTPC1 value: " + RTPC1.GetValue(gameObject));
        RTPC2.SetGlobalValue(RTPC1.GetValue(gameObject));
        print("RTPC2 value not yet applied: " + RTPC2.GetGlobalValue());
        yield return new WaitForEndOfFrame();
        print("RTPC12 value: " + RTPC2.GetGlobalValue());
    }

Let me know if that's the issue :)
To clarify, he's what I have :

void Update()
    {
        LocalViability.SetValue(gameObject, LocalViabilityInt);
        BorderDistance.SetGlobalValue(BorderDistanceInt);

        print("BorderDistance RTPC Global : " + BorderDistance.GetGlobalValue());
        print("BorderDistance RTPC Local : " + BorderDistance.GetValue(gameObject));
    }

LocalViability is my first RTPC, and BorderDistance is my second one

LocalViabilityInt and BorderDistanceInt are two integers (I have tried with floats as well) that I change in the inspector during playtime.

Here, LocalViability is affected normally from the change, but BorderDistance is completely unaffected. I can switch the RTPCs around and then LocalViability doesn't work, and BorderDistance does, so I'm pretty sure it's a bug related to the function or to the way I'm using it.

I tried your code with this in the coroutine :

IEnumerator SomeCoroutine()
    {
        BorderDistance.SetGlobalValue(50);
        print("BorderDistance value not yet applied: " + BorderDistance.GetGlobalValue());
        yield return new WaitForEndOfFrame();
        print("BorderDistance Global value: " + BorderDistance.GetGlobalValue());
        print("BorderDistance Local value: " + BorderDistance.GetValue(gameObject));

    }

It shows
"BorderDistance value not yet applied: 0"
then
"BorderDistance Global value: 50"
and then
"BorderDistance Local value: 3.53334"

So the event's sound still isn't affected at all, and I have no clue where it gets this 3.53334 value from. Do I need to do something first to my AkAmbient for it to intake the GlobalValue for its RTPC ?

Again, thanks a lot for your help :)
I just tried to copy paste your code into WAG, and it works as it should and I get the BorderDistanceInt value in both prints.

This, and because of that strange 3.53334 value, it leads me to suspect that there's something else controlling that RTPC also. Did you change any of the RTPC settings in Wwise? If not, I would start looking for other RTPC being set somewhere else. Try right clicking > find references on the Ak.Wwise."RTPC" end of the property to find all places where it's used. Or at least all places with Wwise-types.

Your code looks good, so if this doesn't work I would start small by making a new game object, add the code to that one, and slowly replace things on that new game object until you get the same problem.
I don't think I changed any RTPC settings within Wwise, but I'm not sure how I would know if I did.

Outside of the Wwise integrated functions, ".SetValue()" is used only within this script. Same goes for ".SetGlobalValue()", and I have not modified the Wwise functions in any way.

Finding all references for RTPC gives me two results for my script, as well as in AkRTPCPlayable.cs, AkRTPCTrack.cs, AkWwiseTypeMigration.cs, and RTPCDrawer.cs, all of which are Wwise provided scripts.

You mentionned WAG, I don't really know what it is, but maybe my Wwise integration is faulty?

This script is already on an empty game object meant only for playing this event, so there's nothing to add to it beside this. :/
WAG is the Wwise Adventure Game, one of the Wwise samples:
https://www.audiokinetic.com/resources/project-samples/?sample=15
* You are welcome to try downloading that project and try it out in there, but it's not using the newest version of Wwise or Unity currently. However, I did quickly update it before testing your stuff and I had no problems.

RTPC settings: Try to click the RTPC in Wwise's Game Syncs > Game Parameters so that it appears in the property editor. When there, check if the build in parameter is 'none' and whether there's any mode selected.

When you are there, you could try to right click the RTPC and Find Any References, so see whether the RTPC is used anywhere in the project where it potentially could be "set" from, like if it's referenced in a Wwise Meter or so.
Well as dumb as I feel now, this fixed it!

Both parameters were using the "Distance" built-in parameter. So it actually makes sense that it wouldn't use Global Parameters for a RTPC value linked to a game object...

Thanks a lot for your time and patience! :)
Happy to hear it worked! :)
Good luck with your game!
...