Playing a SFX on a Conversation Node

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
HawkX
Posts: 147
Joined: Mon Feb 27, 2017 1:50 pm
Location: Quebec
Contact:

Playing a SFX on a Conversation Node

Post by HawkX »

Hi again! :)

I am trying to figure out the easiest way to play a single SFX on a specific conversation node without affecting timing of my subtitles or anything...

I went through viewtopic.php?f=3&t=840&hilit=sound but that one was for a 3d game with actual characters gameobject...

Since you played my game i imagine you have a pretty good understanding of how it could be possible ;)

I already have a SFX manager which has 2 audiosource and is in charge of playing every SFX in the game... whenever I need to play something i simply call :
FindObjectOfType<SFXManager> ().SFX_SelectStage ();

while replacing SFX_SelectStage by the one containing the appropriate SFX ;)

I have done Lua when I was Cinematics Designer at Funcom but it was mostly for creating cinematics, moving camera and characters, etc... so i dont really know how that would fit in...

As always, thanks infinitely for your time!! :)
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Playing a SFX on a Conversation Node

Post by Tony Li »

You can use the SendMessage() sequencer command to invoke methods on a GameObject. For example, let's say your SFXManager script is on a GameObject named "SFX Manager". Set the node's Sequence to something like:

Code: Select all

SendMessage(SFX_SelectStage,,SFX Manager);
Delay({{end}})
The Dialogue Manager's Default Sequence defaults to Delay({{end}}). If your Default Sequence is different, replace the line above.

The SendMessage() command above finds the GameObject named "SFX Manager" and calls its SFX_SelectStage() method. Note that there are three parameters. The middle parameter is blank. This is an optional string that you can pass to a method. For example:

Code: Select all

SendMessage(SFX_PronounceName,George,SFX Manager)
would call SFXManager.SFX_PronounceName("George").

If you don't want to use SendMessage(), you could write a custom sequencer command. They're really easy to write, and the Dialogue System includes a starter template file that you can copy.
User avatar
HawkX
Posts: 147
Joined: Mon Feb 27, 2017 1:50 pm
Location: Quebec
Contact:

Re: Playing a SFX on a Conversation Node

Post by HawkX »

Hi again! :)

Havent had time to test it until now... insane day (as are often most friday's somehow) :P

I actually came here to ask a followup... but instead of asking, i tried it first...

since my SFXManager script is on a super huge "dont destroy on load" gameobject which has ALL of my managers (sfx, music, combat, daily rewards, inventory, etc...) had to call DND instead in the sequence... and i added the bottom part with my "default sequence"

AND IT WORKS!! :D

SendMessage(SFX_WinGame,,DND);
Delay([var=finalDelay])@{{end}}

That is seriously amazing! :) The stuff I can do with that now!! :)

Thanks a lot! as always!
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Playing a SFX on a Conversation Node

Post by Tony Li »

Awesome! :-)
Post Reply