Integration with Audiokinetic Wwise (WIP)

Haytam95

Active member
Wwise integration (WIP)

?Why?



On my project I'm using audiokinetic Wwise to manage the sound effects and soundtrack. So make UCC work along with Wwise is a priority to me. Also Wwise is a stardard in videogame industry, so make this integration will be a nice improvement to the UCC controller.

As UCC is quite big, we will be integrating the most important features of it. This is quite an complex integration, so coding experience will be needed until a final integration is made.



✔️List of integrations

? Footsteps and other impact effects

Thanks to the methods exposed in this post, we are able to integrate footsteps and other effects (like bullets impact) with Wwise nicely and clean. We just need to extend the class SurfaceImpact and SurfaceImpactInspector. The result is this:

index.php


A new Wwise folder that allows to setup an AkSwitch and AkEvent to it.

C#:
public class SurfaceEffectExtended : SurfaceEffect {
        public Event akEvent;
        public Switch akSwitch;

        public override void SpawnFootprint(RaycastHit hit, Vector3 gravityDirection, float timeScale, GameObject originator,
            bool spawnDecals, Vector3 footprintDirection, bool flipFootprint) {
            base.SpawnFootprint(hit, gravityDirection, timeScale, originator, spawnDecals, footprintDirection,
                flipFootprint);

            akSwitch?.SetValue(originator);
            akEvent?.Post(originator);
        }

        public override void Spawn(RaycastHit hit, Vector3 gravityDirection, float timeScale, GameObject originator,
            bool spawnDecals) {
            base.Spawn(hit, gravityDirection, timeScale, originator, spawnDecals);

            akSwitch.SetValue(originator);
            akEvent.Post(originator);
        }
    }

C#:
[CustomEditor(typeof(SurfaceEffectExtended))]
    public class SurfaceEffectExtendedInspector : SurfaceEffectInspector {
     
        [MenuItem("Assets/Create/Ultimate Character Controller/Surface Effect extended")]
        public new static void CreateSurfaceEffect()
        {
            var path = EditorUtility.SaveFilePanel("Save Surface Effect", InspectorUtility.GetSaveFilePath(), "SurfaceEffect.asset", "asset");
            if (path.Length != 0 && Application.dataPath.Length < path.Length) {
                var surfaceType = ScriptableObject.CreateInstance<SurfaceEffectExtended>();

                // Save the surface effect.
                path = string.Format("Assets/{0}", path.Substring(Application.dataPath.Length + 1));
                AssetDatabase.DeleteAsset(path);
                AssetDatabase.CreateAsset(surfaceType, path);
                AssetDatabase.ImportAsset(path);
            }
        }

        public override void OnInspectorGUI() {
            base.OnInspectorGUI();

            EditorGUI.BeginChangeCheck();
            if (!Foldout("Wwise")) return;
            EditorGUILayout.PropertyField(PropertyFromName("akSwitch"), true);
            EditorGUILayout.PropertyField(PropertyFromName("akEvent"), true);
        }
    }




? Interaction system

The interaction system is good enough, to make it work out of the box. Here is the interactable class, just add it to an Interactable object, choose the event and you're good to go!

C#:
using Opsive.UltimateCharacterController.Traits;
using UnityEngine;
using Event = AK.Wwise.Event;

public class WwiseEventInteractable : MonoBehavior, IInteractableTarget {
    public Event[] startEvents;

    private void Awake() {
        if (GetComponent<AkGameObj>() == null) {
            gameObject.AddComponent<AkGameObj>();
        }
    }

    public bool CanInteract(GameObject character) {
        return true;
    }

    public void Interact(GameObject character) {
        foreach (var ev in startEvents) {
            ev.Post(gameObject);
        }
    }
}

Tips: You can add other Wwise fields, to make a more robust interaction.




?‍♂️ Abilities (WIP)

Currently the only way to make it work is to just hardcode the AkSoundEngine.PostEvent() on Ability Start or other ability life cycle.

Blocked by: Abilities can't have a custom inspector, because they are inside the Ultimate Character Locomotion inspector. So I'm stuck at exposing the wwise fields. I tried changing the AudioManager file and it's inspector to make it work with Wwise (then overriding all the "Audio" functions in UCC) but it becomes very messy.

Idea: It could work, if UCC exposed an event every time an Audio should play (Abilities, weapons, and so on), we could create an WwiseAudioManager and subscribe to those events.




? Attribute Manager

Following the UCC core, we will just create an Ability for the character to sync Wwise RTPC values with UCC attributes. This will work with the specific attribute that is associated with the ability. For update all attributes at once, read the tip bellow.

C#:
public class RTPCUpdater : Ability {
 
      private Attribute attribute;
      public override void Start() {
            if (m_GameObject.GetComponent<AkGameObj>() == null) {
                m_GameObject.AddComponent<AkGameObj>();
            }

            attribute = AttributeModifier.Attribute;
        }

    public override void Update() {
            AkSoundEngine.SetRTPCValue(attribute.Name, attribute.Value, m_GameObject);
        }
 
 
    public override bool IsConcurrent => true;
 
}

Tip: This could be improved, if you add a list of strings with attribute names and then do a foreach to update all RTPC values at once.




❤️ Health (WIP)

Nothing done yet, probably your best shot is to just extend the class and override the methods.



I will continue updating the post with more integrations, as I contine working on my project. Of course, contributions and ideas are welcome!

Thank you!
 
Last edited:
This seems very impressive! I’ve only just started using Wwise so Im still learning it (just moved from Fmod).

So with this integration you are making it’s possible to use switches and events? So this is good for footstep systems/surface detection (bullet hits on different surfaces and materials) and player interactivity (press this button to trigger an event type thing).

Curious about player movement, weapons usage, reloads, weapon changing.

Also using states in Wwise. I guess play health would use states alive/dead kind of thing.

I’m really excited you are doing this because Wwise is incredible and I wouldn’t want to be making a game without it. I’ve recently got a Playmaker action working in Wwise which will play a Wwise event so that’s another interact sound element sorted.
 
This seems very impressive! I’ve only just started using Wwise so Im still learning it (just moved from Fmod).

So with this integration you are making it’s possible to use switches and events? So this is good for footstep systems/surface detection (bullet hits on different surfaces and materials) and player interactivity (press this button to trigger an event type thing).

Curious about player movement, weapons usage, reloads, weapon changing.

Also using states in Wwise. I guess play health would use states alive/dead kind of thing.

I’m really excited you are doing this because Wwise is incredible and I wouldn’t want to be making a game without it. I’ve recently got a Playmaker action working in Wwise which will play a Wwise event so that’s another interact sound element sorted.
Hi!

Sadly I'm not working with ucc anymore, this is as far as it gets.

I do not like the animation paradigm of ucc, so I developed my own solution.

I hope this will help you, but don't expect any update
 
Hi!

Sadly I'm not working with ucc anymore, this is as far as it gets.

I do not like the animation paradigm of ucc, so I developed my own solution.

I hope this will help you, but don't expect any update
Ok man, fair enough and thanks for going this far.
 
Top