Storing data with variables

The first step is to create the two variables we need: Direction and Speed. Find the panel labeled My Blueprint. You should see an empty category marker called Variables, with a + sign to the right. Click on that + sign to create your first variable.

In the Details panel, you will see a series of fields for editing your new variable. The four fields that we have to edit are the Variable Name, Variable Type, Instance Editable, and Default Value fields. We want our first variable to contain information about the speed of movement, so name the variable Speed. For Variable Type, we want a variable that can hold a number that represents our desired speed, so select Float from the drop-down menu.

Check the box next to Instance Editable to enable the variable to be changed outside of this Blueprint. This is useful for quickly adjusting the value to our liking once we start testing the moving target in the game. The Default Value category is likely to not have a field, but to feature a message asking you to compile the Blueprint first. Do that, and a field for entering an initial value will appear. Change the default value to 200.0.

Using the same process, create a second variable called Direction. Choose Vector for Variable Type. Vector contains information about the X, Y, and Z coordinates, and in this case, we need to indicate the direction of change we want for the object movement. Make the direction variable Instance Editable and set Default Value to -10.0 for the Y axis:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset