Plan du site  
pixel
pixel

Articles - Étudiants SUPINFO

Unreal Engine 4 - Part 8 : Blueprints

Par Fayçal SIDI ALI MEBAREK Publié le 26/08/2019 à 16:29:46 Noter cet article:
(0 votes)
Avis favorable du comité de lecture

In the previous sections, we saw the basics of the Unreal Engine 4, explained how the different types of lights work; we also saw the blocking, the setting up of textures and decor. We built our first scene.

Now to complete this, we will see what Blueprints are, we saw before that it is a scripting system that allows to develop without having to use pure C++ directly.

With blueprints, you simply connect the different elements to each other to make them interact with each other.

Blueprint = Visual scripting

Exactly, it is a scripting system, which you use through an interface. By placing our blueprints, we can nestle them together so that the scripts can be run in sequence. With blueprints you can define classes, objects....

Blueprint examples

We will return to our project, and continue it. We will test the concept of blueprints to place our lights.

So still in the "Content Browser" at the bottom of the page, we have the "Blueprints" folder, click on it to see what it contains. It contains two types of lamps.

We will take the first one: "Blueprint_CeilingLight" and place it in our decor. So we see that it is our lamp object that we had already placed in the set, but this time with a lamp with a light point already placed and oriented! This is the power of blueprints, we already have a glimpse of it. So let's replace our lamps that don't work with them:

Again, you can change the lamp power by changing the "Brighteness" setting, its color.... What I did so that you can fully see the result.

So it's not just a simple object placed, it's a blueprint.

So it was an example of a Blueprint proposed by those who designed the engine, so that we could test it. However, it is possible to create your own blueprints, by creating classes and objects in C++. It is therefore not a question of replacing C++ with blueprints, but of facilitating development by making them complementary.

So, it is possible to make your games, through the menus, physics, interface, scripts, only from the blueprint, without a single line of code.

Creation of our first Blueprint

To better understand what it is, we will tackle this piece and do ours. We're going to make a nice sliding door, which will open when our character approaches it! Wonderful.

First of all, we will place a glass on our door, and adjust it to cover the empty surface, like this, you know how to do it:

We have our window, it will slide when we approach it and close when we move away.

We will first go to the "Modes" tab on the left, then to "Basic", and select a "Box Trigger", place it at the door level, and adjust it so that it is the area that will trigger the script that will open and close the door:

We will also make our window "Movable" so that it can move around the game, otherwise no interaction will be possible. Click on the window, then in "Details", click on "Movable":

Now select your "Trigger Box" to be able to use it easily and click on "Blueprints" at the top of the page, then on "Open Level Blueprint":

You are on the page that allows you to create your blueprints to make the elements interact with each other, it is empty for the moment. We will add our "Trigger Box" to it. Right click in the middle, then "Add Event for Trigger Box 1" then "collision" and finally "Add On Actor Begin Overlap", here is what it looks like:

Do the same thing again and this time add Add On Actor End Overlap". This will be the beginning and end of our loop.

We want the window to move from right to left, in about 1 second, so we will add a "Timeline"; by right-clicking again, scroll down and click on "Timeline".

We want the door to open when we approach it, and close when we move away, so we want it to do the opposite. So let's do the following:

Here we have therefore linked the beginning of our action (Begin Overlap) with "Play", and the end of our action (End Overlap) with "Reverse" so that it has the opposite effect and returns to its initial position (door closed).

Now we will modify our Timeline so that the door opens and closes in 1 or 2 seconds. Double click on your timeline, it sends you to another page. Here, add a "Vector Track" by clicking on the "V+" button at the top of the page and name it as you wish. I have named it "Movement_Door".

The door will only move on the Y axis on my side (from left to right and vice versa in relation to the orientation of my door); with you it can be on the X axis, it is up to you to see how you have positioned your door

We will therefore hide the X and Z axes to avoid making mistakes. To do this, click on the eye near X and Y. Do "Shift" + left click on the green Y axis to select it and be able to modify it. When you are at 0 for time and value, redo "shift" + left click elsewhere and set 1.2 seconds for time and 110 for value for the second yellow dot.

Concerning the value of time, it is the time we want for our door to open, so we will take 1.2 seconds for our example.

Here is the result of our "Timeline":

We are done with the "Timeline". The door will therefore start to open at time t=0 and end its sliding at time t=1.2 second. And we have specified that this will influence the X axis, so it will slide from right to left or the other way around; that's what we're going to add now.

Then we will go back to our "Event Graph", and add an event that will launch the beginning of the action; for that do a right click then type in the search bar "event begin play" and click on it to add it :

Now, make sure that your "door" is selected on the game engine, then come back to the Event Graph; On my side the door is a window, it will be it that will open: its name is "SM_GlassWindow3". We will add it by committing for the begin play event, so right-clicking and clicking on "Create a reference to SM_GlassWindow3".

Now that you have understood the principle, we will move faster, do the same by adding "Get Actor Location" and then connect your door to "Target" so that it will be the target of the value change. Then, hold down the click on "Return Value" and right-click on the blank, and click on "Promote to variable"; like this:

You are asked to enter a name for your variable, it is important to find your way around. We will name it "InitialDoorLocation":

Now let's connect our "Event BeginPlay" to the white pine of the variable we just created. Then we will copy and paste your door down. Let's take the pin blue by clicking on it and then right-click, type "set actor location" and click on it".

Let's connect the "update" pin of your timeline to the white pin of "set actor location" that you just added. This will cause the position of the door to change over time; it will change at any time from t=0 to t=1.2 seconds as we have specified in the timeline.

Now let's add our variable "InitialDoorLocation" by doing "ctrl" + hold click and drag it, like this:

Let's now click on the yellow pin of our variable, and right-click to add our vector "vector + vector"; then connect the pin "Movement Door" of our timeline, to the pin of the coordinates of our vector.

Let's now link our yellow pine from our vector to "New location" of "Set Actor Location". This is what our blueprint level gives for the moment:

As you can see, I always try not to cross the lines, so that the blueptint always remains clear. Here it is not very long, but sometimes we can have maybe 5 or 10 more elements, and that is where it can become difficult to find your way around, if you are not organized.

Here we are, we have finished our Level Blueprint, it is time to test it! First of all we need to compile it, you can do it by clicking on "Compile" at the top left.

We can now go back to our level, play to test; let's see what it looks like:

At this point, I'm out of the trigger box, so the script doesn't start. I'm going to go ahead and enter it to see the result.

That's it! our door opens from right to left, exactly as planned, and in 1.2 seconds; you have to test it at home to see.

Conclusion

We have just seen how a blueprint works, how the concept is very effective, and we have even created one to understand how it works. So it is very convenient to work with blueprints, it saves us a lot of time, at least for small scripts like the one we just made.

However, to create your own customized and advanced blueprints, it is in some cases mandatory to use the C++ box.

In summary, In all these parts on Unreal Engine 4, we reviewed its evolution, from its creation to what we have today; we saw how to get it, and how to use the Epic Games launcher (which I recommend if you had any problems whatsoever during the course of this article). We saw the basics of the Unreal Engine 4, from blocking to using different lights. With that, we created our first set, used and created our first blueprint.

We will then see the use of sounds in the engine.

A propos de SUPINFO | Contacts & adresses | Enseigner à SUPINFO | Presse | Conditions d'utilisation & Copyright | Respect de la vie privée | Investir
Logo de la société Cisco, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société IBM, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Sun-Oracle, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Apple, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Sybase, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Novell, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Intel, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Accenture, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société SAP, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Prometric, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Toeic, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo du IT Academy Program par Microsoft, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management

SUPINFO International University
Ecole d'Informatique - IT School
École Supérieure d'Informatique de Paris, leader en France
La Grande Ecole de l'informatique, du numérique et du management
Fondée en 1965, reconnue par l'État. Titre Bac+5 certifié au niveau I.
SUPINFO International University is globally operated by EDUCINVEST Belgium - Avenue Louise, 534 - 1050 Brussels