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.

0 votes
Hello!
I'm very new to Wwise and Unity (and I'm not super familiar with C++ although I know Java) and I'm struggling with one specific thing in my first project.

I'm making sound for a Unity project where I have a water gun that shoots a liquid around.
The way the code is written I have a game object called Paint Manager that handles the task of painting the textures in the environment where the particles shot by the water gun collide with floor/walls.
Right now what I did (simplifying) is posting an event every time the method that was already in place tells the program to paint the surface.
I also set up a simple code to detect how far from the listener the collision happens. (using a RTPC).
However this obviously doesn't take actual position into account, so I don't have proper panning/cone attenuation for each collision happening.
The result is not bad still, but it lacks depth and I feel my solution is a bit spaghetti.
So let's say I have:
- A Vector3 position of the collision, let's call it Vector3 position;
- An event to call, let's call it AK.Wwise.Event Paint;

How would I tell wwise to place every instance of the event in the corresponding position?
Also what components would I have to add to the Paint Manager in order to have everything work properly?
If it's not possible to set up what I'm trying to do this way, what would be the most simple change I can make to achieve the result I want? (remaking or drastically altering the shooting system is not an option for me)

I can provide the code I wrote or extra details if needed
Thank youuu
ago in General Discussion by Matteo Donato (140 points)

1 Answer

+1 vote
 
Best answer

Hi Matteo,

This is an implementation question that might have different solutions. One possible approach could involve creating something like a WaterImpactPrefab that contains a GameObject with an AkEvent component set to trigger on Start. You would then instantiate this prefab each time a collision occurs with the floor or walls, placing it at the specific collision position. The event would be posted automatically at that location.

Another solution could involve creating a GameObject in code whenever a collision happens. You would set the transform.position of that GameObject to your desired Vector, then call Post on your paint event, passing the newly created GameObject to that function.

If you haven't already, I recommend taking the Wwise Unity Integration course and experimenting with the Wwise Adventure Game to get a feel for how the Unity integration works in general and how to post events from scripts.

ago by Alessandro Famà (3.3k points)
selected ago by Guillaume R. (Audiokinetic)
Very clear answer, thank you!

So in general if I need to position a sound in space I always need a corresponding gameObject at that position or are there workarounds?
(Obviously your solutions are more elegant and scalable than what I was trying to do)

Furthermore, what is the best way to dispose of the object once it's no longer needed? I'm assuming the audio triggered by the event will still play until the end even if I immediately delete the object but I'm not 100% sure about it, is that the case?

I took all the Wwise courses but I kinda powered through them so I'm still connecting some of the dots (and I had 0 Unity knowledge before the 301)
...