Adding SFX and VFX when an onscreen variable changes

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Adding SFX and VFX when an onscreen variable changes

Post 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!
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Adding SFX and VFX when an onscreen variable changes

Post 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.
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Re: Adding SFX and VFX when an onscreen variable changes

Post 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?
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Adding SFX and VFX when an onscreen variable changes

Post 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.
Post Reply