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.

How do I create a Wwise-type Event parameter for an Animation Event function? [closed]

0 votes

This is a question sent to us from elsewhere and shared here to benefit everyone.  

How do I create a Wwise-Type Event parameter for an Animation Event function?
Unfortunately, you cannot. This is a limitation of Unity's Animation Events system. However, there are other ways to reference a certain Wwise Event directly from an Animation Event. 
* You can read more about Animation Events in the Wwise-301 course

1) Type the Event Name into a String

Animation Events do accept String parameters, which is basically just text. Luckily, that's exactly what the AkSoundEngine.PostEvent() function requires when you want to post an Event from code. Here's an example of creating such a function.

public void PlayWwiseEvent(string NameOfEvent) {
     AkSoundEngine.PostEvent(NameOfEvent, this.gameObject)    
}

2) Create an Enum dropdown
If you want a Wwise-Type-like dropdown, you can also create n enum instead of a string. 

This method is most useful when you know the name of your Events, cause you will have to add the names manually to the enum if you create new ones or modify existing Event names. 
Start by defining the enum. Add the names of all your Events separated by a comma. Then, in the function inputs, add a new parameter based on that enum and make sure to ToString() the parameter in the PostEvent function, so you convert the enum selected into text. 

public enum WwiseEvents { Explosion, Open_Door, Close_Door, TakeFootstep, Sword_Impact, Gunshot }
public void PlayWwiseEvent(WwiseEvents Event) {
    AkSoundEngine.PostEvent(Event.ToString(), this.gameObject);  
}

closed with the note: This is a question sent to us from elsewhere and shared here to benefit everyone.
asked Oct 7, 2021 in General Discussion by Mads Maretty S. (Audiokinetic) (38,280 points)
closed Oct 7, 2021 by Mads Maretty S. (Audiokinetic)
...