UE4 Blueprints

Carsen
4 min readApr 5, 2020

--

Now that we’ve looked at some C++, its time to try it out in UE4. The plan is not to use code, but to use our understanding of it to create what UE4 calls blueprints. Blueprints, put simply, are a GUI bubble coding, that focus’s on drag and drop to create your functionality. Knowing how C++ works is a huge help to understanding how exactly this functionality is created.

Why use one or the other?

The general consensus between UE4 developers is quiet simply that you should learn both. Should you try and create something in UE4 you could find yourself lacking in ability, because for some thing’s blueprints are limited or straight up missing features. As well blueprints can be vastly slower for running complicated games, where as C++ does not take that performance hit. However, for beginners, its recommended to begin with blueprints to learn the functionality and make your idea a reality, and its much easier to create simple things.

A simple demo:

The first most basic requirement for any game is being able to have the user interact with the application. So lets start by creating what’s know as an Event Listener. In C++ this is something that could be as simple as onClick() attached to a button, and in UE4 its even easier to create. The following steps are assuming you have launched UE4 and created a third person character project:

· First go to the UE4 Project Settings option located in the top left, under the menu drop down “Edit”

· This will launch the project settings window, on the left option bar, click on “input” located under the “Engine” Header

· Now that we are in the right place, look under the “Bindings” header. There will be an item called “Action Mappings”. Press the arrow to open the drop down and see the existing ones, and then click the “+” sign to add a new one.

· Name it whatever you’d like, in my case I chose “fire” as if it was for a shooter. Then find the key to bind it too, I picked “Left mouse Button”.

Now that we’ve made our settings, you can simply close the project settings editor, it auto saves. Now that we have a listener bound to left click, we need to have it do something. In C++ there’s a few ways to print output to the screen, such as printf, which we are going to hook up to that event listener we just made. Now we just need to find the blueprint for our “ThirdPersonCharacter”, you can see it located below in the content browser, with the path located at the top above it.

Double click and open this blueprint, you should now be viewing a tab called ‘Event Graph”. This is where all the main inputs begin, noted by the red bubbles. Some existing ones will be in place, but we are going to add the one we just made. Right click on a blank space, and a massive drop down menu of methods to add will appear. Simply search for the one we just made called “fire” and select it.

A red bubble has now appeared called “InputAction fire”, which is where the logic will begin anytime a user presses left click, as that’s what we bound it too. Obviously, the logic needed from this point could be vastly different depending on the game you’re creating, but ill simply show a “printf” attached to it so that you can see it work in the games view port. To find the “prinf” method in blueprints, its called “Print String” and by default prints hello, which you can freely change, or hook inputs up to it instead.

Now simply click compile, save and close the blueprint. Back on the main menu of your project, play it and try left clicking. You should get a “Hello” print out in your viewport.

And that’s it, its that simple to create event listeners in UE4 Blueprints

I personally do not feel nearly comfortable with UE4 to begin using C++ instead of blueprints. My plan is to continue with creating my projects using blueprints and when I get comfortable enough with the engine, to begin branching out into C++. However, the recent self-study into C++ has definitely helped me understand the logic I’m trying to create, and what’s available to me.

References:

https://www.quora.com/Should-I-learn-Blueprints-or-C++-in-Unreal-Engine

--

--