Categories
Uncategorised

Developer Journal : Variables and Functions

Developer Journal

As of the 15th of Monday, I’ve been learning more about using the Unreal Engine.

During this week we covered on how to use variables and functions in the blueprint system, both of these are crucial to cover as they are mainly used to store important information from the game and to make certain actions possible.

What variables can do is to give certain objects or actors within the game world certain properties using values such as; floats, integers, booleans and even strings.

“Variables are properties that hold a value or reference an Object or Actor in the world.”

unrealengine.com, 2021

Shown in Figure 1, you can see that there are some examples as to what some variables can be.

Float & Integer variables may keep track of things such as time as they use numbers as values, whilst something like Booleans can be assigned to more simpler on/off functions such as toggling a player’s light – Strings may also be used for something such as storing the player’s name.

Variable Nodes
Figure 1 (UnrealEngine.com)

Essentially, variables can be used as statistics to help record what is happening within your game. As we are currently using the blueprint system, these variables will be mostly present within our node graphs we use to structure most of the game with.

This brings us into using Functions, which can be created and stored on a singular blueprint and then can be assigned to a simple function which can be called from a different graph.

“Functions are node graphs belonging to a particular Blueprint that can be executed, or called, from another graph within the Blueprint.”

unrealengine.com, 2021

An example of how a function may be used is shown in Figure 2, this presents us with a “Take Damage” function inside a character’s blueprint. Once this function is called, it will take away some of the player’s health.

PlayerHealthFunction.png
Figure 2 (UnrealEngine.com)

The reason why this may of been done is that there may be multiple ways to take damage within the game, and instead of having to recreate the structure over again for each way it is instead assigned to a simple function which can just be called and still serve the same purpose.

Unreal uses Classes, which can contain both the variables and functions we’ve covered together. These can be used as Parents which can allow the properties within them to be inherited into other blueprints.

“Selecting a Parent Class allows you to inherit properties from the Parent to use in the Blueprint you are creating.”

unrealengine.com, 2021

Anything in Unreal can be used as a parent class, for example a parent Actor blueprint can contain properties for ammo and health – which a child blueprint can inherit.

As it is separate from the parent blueprint, we can add some specific functionality that only applies to just the child blueprint such as a unique weapon only available to the actor whilst still inheriting the functionality shared from the parent blueprint.

A more general example of how a parent system is used can be seen here on Figure 3.

Figure 3 (Grewell, C)

The parent class is a tree, and its children are different sorts of trees that have their own specific properties unique to them. The text in bold displays the new properties of each child object, whilst also inheriting the previous properties from their parent.

I personally think that learning classes, variables and functions are a great at trying to get your head around how a good chunk of the blueprinting system might work in Unreal – it also helps with programming generally.

Although I’ve already been familiar with using these in different engines and programs before such as Visual Studio, it is a good idea to keep revising them and also seeing how they may be used differently.

Bibliography

Docs.unrealengine.com. 2021. Blueprint Variables. [online] Available at: https://docs.unrealengine.com/en-US/ProgrammingAndScripting/Blueprints/UserGuide/Variables/index.html [Accessed 21 March 2021].

Docs.unrealengine.com. 2021. Functions. [online] Available at: https://docs.unrealengine.com/en-US/ProgrammingAndScripting/Blueprints/UserGuide/Functions/index.html [Accessed 21 March 2021].

Docs.unrealengine.com. 2021. Blueprint Class. [online] Available at: https://docs.unrealengine.com/en-US/ProgrammingAndScripting/Blueprints/UserGuide/Types/ClassBlueprint/index.html [Accessed 21 March 2021].

Grewell, C., 2018. Classes. [online] Medium. Available at: https://medium.com/applab/classes-d2fb62e266c0 [Accessed 21 March 2021].

Leave a Reply

Your email address will not be published. Required fields are marked *