Variables are another great way of adding versatility to a game blueprint, they are easy to make, easy to change and easy to reference in many blueprints. Because of this you can do lots of clever things in your game mechanic such as level up systems that just simply change a variable and drastically effect how the game plays. That's why you will use two to control walk and sprint speeds in your blueprint.
- [Narrator] We have talked quite a bit about the two variables that will set the walk and sprint speeds for our character, but haven't actually gone ahead and set them up yet. And so I think it's time we changed that. Now unfortunately we can't test each part of the logic that we're building here, as we need everything in place before we can actually put this particular mechanic to the test, which is sometimes the way with certain game play features. Let's finalize the setup then, so that we can go ahead and test it by clicking the plus icon in the Variables tab twice, renaming the first to Walk Speed, and the second to Sprint Speed, and then if needed we can set each in turn to be a float variable from over on the right side of the UI.
We can then compile the blueprint by clicking the Compile button so that we have access to the variables value parameters. We want to then set the walk speed to a value of about 700. The number used here will of course be dependent upon your personal preference and the type of game you are making, as well as its scale. We will be able to alter this later on should we feel that our character is ultimately moving too fast or too slow, but if we already have a walk speed value that we like, something used on a previous project perhaps, then we can certainly go ahead and use that here.
Getting back to building our mechanic then, let's also set our sprint speed to a value of 1,000. I'm setting a high value here, as this will help us clearly see when the sprint actually starts. If it is still hard to tell whether things are working or not once we test things out, then we can try setting this to a higher value, such as 1,300. We now have our two separate speeds stored in variables and ready to use. As noted, we are going to use a lurk mode in order to blend between each of these values, and so let's move on to creating that in our next exercise.
- Creating the project
- Making the input action
- Building the sprint blueprint
- Timelines and input control
- Variables and lerps
- Adding the walk and run variables