Page 1 of 1

Adding SFX and VFX when an onscreen variable changes

Posted: Sat Feb 29, 2020 2:48 pm
by lostmushroom
Hey guys, I'm making a Reigns type game with some variables visible on screen at all times. I'd like to play a sound effect and show an icon (such as an up or down arrow) every time any of these variables change.

I'm wondering if there is a smart way of doing this without having to add it to every individual node in which the variables change, since it happens frequently.

Thanks!

Re: Adding SFX and VFX when an onscreen variable changes

Posted: Sat Feb 29, 2020 4:39 pm
by Tony Li
Hi,

Here are a couple of ideas:

- Write a C# function to change the variable and play your effects. Then register this C# function with Lua, and use it in dialogue entry nodes' Script fields instead of changing the variable directly.

- Or add Condition Observers that watch the variables. Set their Frequency to Every Dialogue Entry.

Re: Adding SFX and VFX when an onscreen variable changes

Posted: Sun Mar 01, 2020 5:43 am
by lostmushroom
Thanks, I'll try the condition observer :)

Another question - is it possible to set min and max limits for variables, so they can never go below 0 or above 20 for example?

Re: Adding SFX and VFX when an onscreen variable changes

Posted: Sun Mar 01, 2020 8:28 am
by Tony Li
No; they're just variables, kind of like variables in C#.

Your best approach would be to write a C# method to change the variable's value and play your effects. In that method, you can also make sure the variable stays within limits.