In Step 1 we set up a simple Heartbeat state with Volume and Delay.
Now we'll add variables to control the volume and delay.
- Open the Variable Manager.
- Type "volume" in the New Variable edit field and hit enter.
- Type "delay" in the New Variable edit field and hit enter.
- Note, the default variable type is float which is what we want to use for continuous values like Volume and Delay.
Setting Default Values
- Enter the default value for the variables in the edit field next to their type.
- Enter 1 for both volume and delay.
Using the Variables
- Select the Heartbeat state.
- Note the Variable Toggle on the Volume parameter:
- Any parameter that has a Variable Toggle can use a variable instead of an explicit value.
- Click the Variable Toggle and the input field changes to a Float Variable popup.
- Open the popup and select the "volume" variable.
- Repeat this for the Delay time in the Send Event action.
When you press Play, everything should run the same as before, but by adding variables, you can now control Volume and Delay in the running game (instead of just in the editor).
Using Sliders To Control Variables
Load the PlaymakerSamples/Heartbeat/heartBeat sample scene to see how to setup sliders to control the Volume and Delay variables.