Unreal Engine 4 introduction
Unreal Engine is a powerful framework for game developement, suitable for projects of all sizes, styles and complexity. For a simple project like mine Unity could have been the first choice, but since I'm attending an UE4 course I'll try to build it with this engine instead.
First of all, every entity in Unreal (Player, Enemies, Ammo, Particle Systems, etc.) is an Actor. It has some basic functions like position, rotation and scale, and if needed it can be extended for more specialized tasks (i.e. Static Mesh Actor can simulate Physics, Pawn can be possessed by the Player, and so on).
There are 2 main ways to create scripts for Actors in Unreal: Blueprints and C++. While blueprints are internally structured like C++ classes, they offer a visual representation of the behaviour of that class.
![]() |
A simple Event Graph of a Blueprint |
Each level of the game has its own Blueprint, taking care of all the Actors, Cameras and every entity in the scene.
Then every Actor has its own Blueprint Class, allowing you to create scripts with Object Oriented Programming style.
As you can see in the Graph Editor of the Blueprint, there are boxes of different colors. Let's see what these boxes are:
Red boxes: These are Events. Every action starts from one of these. They can be Input events, prefixed events like Begin Play (happens once at the beginning of the level) or Tick (happens every frame), or even custom events created by the programmer.
Blue boxes: These are functions. They are triggered by something, accept input parameters and produce outputs.
Green boxes: these are GETs. They expose a variable value and can be plugged in as input parameters of a function.
Cyan boxes: these are simply CASTs. They're useful when a GET returns a generic type, but you need more specific values or functions, available only in the extended class derived from the generic one.
The white triangles on the left and right of every box, called execution pins, are used to chain the execution of functions. Notice that Events don't have a left pin, because they can only be at the beginning of the chain and trigger the execution of other functions. The functions of a chain will be executed sequencencially, from left to right.
As a programmer, I feel more comfortable working with C++ code instead of Blueprints. I have the feeling they are confusing when the Actor logic becomes complicated, and simple instructions like a FOR loop look unnecessarily complicated to me. But Blueprints have some strengths too, like binding inputs and using timelines for animations.
So, is there a way to mix the two worlds? Of course there is: you can extend a C++ class to a Blueprint, thus creating all the needed methods in C++ and then delegating the Blueprint only for the actions that are easier to perform in that environment. This is accomplished by creating Properties and Functions with a particular syntax that makes them visible in the Editor (we'll see this in more detail when we create our first class).
So, is there a way to mix the two worlds? Of course there is: you can extend a C++ class to a Blueprint, thus creating all the needed methods in C++ and then delegating the Blueprint only for the actions that are easier to perform in that environment. This is accomplished by creating Properties and Functions with a particular syntax that makes them visible in the Editor (we'll see this in more detail when we create our first class).
In order to do this, I will start my project as "New C++ project" and choose "Basic Code", this will create some basic C++ classes that will be useful later:
Next time I'm going to create my first class, the "MainMap" one, that will manage the spawning of all the hexagon components and the common actions of the map.
Thanks for reading and game you next time!
Commenti
Posta un commento