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.

+1 vote
Hello everyone! I am doing some testing on the Unity 3D Game Kit project from Unity Market Place using Unity 2020.2.1f1 (along with Wwise 2019.8.7432) and for some reason i CAN'T make a basic Ak Event "Trigger on: Start" works. Been doing it in several projects for the last 2 years but doesnt seem to work on this version! As always i checked the Rigidbody on my Player Game Object (Ellen), created a trigger box (Is Trigger) added the Ak Trigger Enter/Trigger Exit component targeting the Player Game Object...All the steps we are suppose to follow to trigger something on a trigger but not working :/.

Its really basic but still can't find a way to work around and it's blocking a lot of features i want to try with Ak Environment/Switches/States etc....

Do someone as something in mind that i might have missed ?

Thanks
in General Discussion by Angel I. (130 points)
Hi Angel, I am also having this problem, the Ellen character is as you describe and it does not trigger the collider, which I have set up just like you... my problem in addition to this is that I am new to this scripting so I don't have experience of debugging the scripts. I tried with the script from the 301 Certification that checks for the Player tag and triggers on enter and exit and I get no errors on the console, I have checked many times and it should work... I am also on Unity 2020.2.2f1 but WWISE 2019.2.9

Please, if you have solved this problem, can you let me know how? It must be something to do with the Ellen character... all else works fine!

Thanks,
Julio

2 Answers

0 votes
Hey Angel,

That's strange. Have you tried creating a custom script and test if Start() is called?

All of those Trigger On options in the AkEvent / AkAmbient is merely using the MonoBehaviour functions, like OnTriggerEnter() or Start(). So if those functions are working in a custom script, it should work for the integration as well. And Start() should definitely be called, as long as the game object you attach it to is enabled.

As for the Trigger Enter conditions, the same applies as above. AkTriggerEnter is simply using the OnTriggerEnter() function, so if you've got a Rigidbody + Trigger on it, it should work. I would definitely try to test this out in a custom script on the same game object.

Let us know if the functions in a custom script works.
by Mads Maretty S. (Audiokinetic) (39.8k points)
Hi Mads and thank you for your message! Actually i wrote my message wrong the Ak Event Trigger on Start DO work ! Its only the Ak Trigger Enter that i just don't manage to make works even tho i have a capsule collider on the game object (Ellen) that is the player character we control, rigidbody on both and of course the option "Is Trigger" on the sphere cube i created to test my Trigger Enter sound! Do you know if i am missing something else ? Really weird as i have been doing it 1000 times on other 3D projects and that is the first time it's not working even tho everything sounds here...


Updated message: Actually went back in Unity, removed the Ak Event custom script and wrote the following script:

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

public class Test : MonoBehaviour
{

    [SerializeField] private AK.Wwise.Event MusicEvent;
    void OnTriggerEnter()
    {
        MusicEvent.Post(gameObject);
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

==> Now the Box Trigger is working as i clearly here my music when the box is colliding with the ground but DOESN'T hear it anymore when i elevate my Box Trigger from the ground (to prevent the box trigger and ground to collide) which means the script is working BUT still can't make my Player Controler Game object triggers the script ! So it seems the problem is coming from the Player Character Game Object but it's weird as i have a rigidbody on it and the capsule collider is there too .

Do you know what could cause that Mads ? :) Thanks
Hmm. Regarding Capsule collider, there shouldn't be any differences between the type of collider. They all call OnTriggerEnter(). You could also write it like this...
https://www.audiokinetic.com/qa/8197/how-do-i-detect-which-sounds-are-entering-the-akenvironment?show=8197#q8197
About the script, it looks good, even though I would probably start by using prints.

IMO it still sounds like a problem with setting up trigger collider interactions. So I would probably...
(1) Start out testing two very simple triggers. Create a script like above with prints and test out your system.
(2) Once the above works, compare the "simple" setup with your player. Why is it that the above works, but specifically for the player it doesn't. Like check what components it has, maybe even check the collision matrix. Sometimes the best way to detect a problem, is to make it simple until it works and then scale it up again.

If you can't get (2) to work, then I would probably start reconstructing the player. Import it again, add the scripts / components, etc. to get a fresh start.
+1 vote

Hey Angel,

Alternatively, 

you may want to try changing the order of script execution 

by referring to the following documentation 

to ensure that AK-related scripts have a higher priority 

in the execution order list

Unity - Manual: Script Execution Order settings (unity3d.com)

by Hou Chenzhong (Audiokinetic) (6.0k points)
hi Hou and thank you for your advice! Unfortunately it doesnt seem to be this causing the problem as i followed what you said by moving all Ak relatives script at the top of the list in the execution order but still doesn't make the Ak Event: Trigger On Trigger Enter works! As explained above on Mads comment it always has been working on Start and it works in Trigger Enter but NOT when its the character ! (it works when the cube collide the ground but not when i enter the cube collider with the player (which has a Capsule Collider and a a Ridibody attached)

If you have any other ideas its great!
Thanks in advance guys
Hey Angel, I've had the same problem while using the 3d game kit, where I couldn't get Ellen to trigger an AkEvent:Trigger on enter, and finally managed to make it work by changing the triggers layer to "environment". Not sure if this will help you, good luck.
Hi Kiran for your answer! Just to be sure what do you mean by "changing the trigger layer to environment" ? :)
Hey! I mean in the top right of the inspector window, under "layer".
Holy mother of God...I was researching for this problem for a whole week. I would never tought about the layer set. This is it man. Kiran B., you saved me! =D Thanks a lot!
Life saver! thxs a lot
Had a little problem using triggers also on the "3DGameKit" on Unity, just writing this down in case someone has the same issue : nothing would trigger even though I added the right TAG to Ellen (the character / listener) Or added a Rigidbody to her (which isn't on the character in the beginning and can cause problems when using the functions  - void ontrigger[...]) - the last problem that I found on this project while using triggers and that actually fixed the issue was on >> Edit - ProjectSettings - Physics - Scroll down and where there is the “Layer Collision Matrix”, on the first line: Default, look for the column “Player” and check the check box. And then the trigger functions should be working fine again. Hope this can help someone!
thanks a lot! Kiran B.
Same problem as Angel and now it works! Thanks a lot!
...