Functions, Arrays & Classes - Page 1
A look at functions, arrays and classes in UE4 & C++
For this exercise we will be just using blueprints so all we need is to run Unreal. It is easiest to manage the various versions of Unreal using the Epic Launcher. This allows you to install and run multiple versions of the engine. Go to https://www.epicgames.com/store/en-US/download and install the Epic Game Launcher. From here we will manage our game assets and resources. You will also need to install either Visual Studio Community 19 on the PC with C++ drivers or XCode on the mac.
Lets look at how functions work in C++ and in Unreal Blueprints. Then lets create a function in C++ that works within blueprints.
There are user defined functions as well as supplied functions by the language we are using or a library we are including. It is a block of code that performs a task. We can pass it parameters (various variables)and the function can return a single type or none at all (void). Let's write a simple function:
A function has three components. We start with
ReturnType then we have the name of the function
FunctionName and then in parenthesis we can pass it parameters (or not) separated by commas like
(Param1, Param2). So for example we can have a function that just prints a message that returns no value nor does it take any parameters that can read
void Sorry(). This is a function that returns nothing and takes no parameters. Let's give this a shot.