|
Post by JCooz on Apr 1, 2015 21:38:08 GMT
Hello,
First I'd like to say that this plugin has been great, and has really accelerated our audio development.
However what I'm attempting to do is have a custom event such as Footstep triggered via animator from an NPC, where only that NPC received that event.
With the current setup, if we have 3-4 spawned NPCs within listening range, they would all receive the custom event and trigger whatever has been defined on their event script. So essentially, I'm just attempting to have a single object triggering and receiving a custom event so that the same NPC triggering a footstep sound plays the footstep sound. Or maybe there's a better solution than how we're attempting to set this up.
Thanks!
|
|
|
Post by DarkTonic Dev on Apr 1, 2015 23:44:42 GMT
I guess I'm not sure why you're sending / receiving the Custom Event if the listener and sender are always the same. Are sending and receiving both done by Event Sounds script? If so, instead of firing the event, you should do the receiving part (Actions) directly.
If not, you can use the API to do the sound actions directly.
-Brian
|
|
|
Post by JCooz on Apr 2, 2015 0:47:07 GMT
Thanks for the fast reply.
I guess I should have explained a bit further. Basically within our AI scripts, triggered by specific events in our AI such as attack, we're firing a specific custom event for that type of npc. As well as idle sounds when the player is within a specific range. I wasn't sure of a better method to trigger these from my scripts other than using a custom event since I need to trigger them from a script. I'm basically trying to trigger an event from the same object that needs to listen for the event, but without sending any other listeners. Would there be a way to define an event that my script can talk to directly to fire?
Thanks for your time. Jeremy
|
|
|
Post by DarkTonic Dev on Apr 2, 2015 1:30:07 GMT
Custom Events are made for multiple listener scenarios, with no discrimination except distance. If you don't need that, you don't really have a use for them.
You can write a new minimal script file with Master API calls, with a public method that you call after doing a GetComponent for the script. That's the easiest way.
Like:
public class AIAudioResponder { public void Respond() { MasterAudio.PlaySound3DAndForget("Noise"); } }
Then in your AI code:
GameObject goResponder; // you get this somehow var aiResponder = goResponder.GetComponent<AIAudioResponder>(); if (aiResponder != null) { aiResponder.Respond(); }
Or of course you could just put the PlaySound3DAndForget call right into the AI script and not add this complexity.
Note that this code doesn't have anything to do with Master Audio other than the PlaySound method call. It's just basic Unity code.
|
|
|
Post by JCooz on Apr 2, 2015 3:27:24 GMT
Thanks Brian,
I should have dug further into the api docs this is exactly what I should have looked into. Thanks again for pointing me into the right direction.
|
|
|
Post by DarkTonic Dev on Apr 2, 2015 5:46:46 GMT
Sure, no problem!
|
|