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!
Adding SFX and VFX when an onscreen variable changes
-
- Posts: 194
- Joined: Mon Jul 01, 2019 1:21 pm
Re: Adding SFX and VFX when an onscreen variable changes
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.
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.
-
- Posts: 194
- Joined: Mon Jul 01, 2019 1:21 pm
Re: Adding SFX and VFX when an onscreen variable changes
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?
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
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.
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.