Unreal Engine: Level Blueprint | How to Start Writing Visual Code

Are you new to Unreal Engine and eager to begin learning about Blueprints and the Level Blueprint? If so, you’ve come to the right place!

Some people truly enjoy writing code using languages such as C++ or C# within tools like Visual Studio. They find it both enjoyable and fascinating. And it’s true that there are advantages to it, like better performance and more freedom.

On the other hand, there are people who aren’t skilled in coding, simply dislike it, or have no interest in dealing with the task of writing lines of code. Alternatively, they might even have an interest in programming but require a quick working prototype. This is where Blueprints come into play.

Blueprints allow you to code in Unreal Engine using a Visual Scripting System. It’s similar to developing a program by connecting various boxes that hold information. These boxes are known as nodes, and each one has a specific function.

You can, for example, connect a node that causes a game character to walk to another node that sets the character’s speed to 10. By connecting these two nodes, the character will move at a speed of 10 units without having to write a single line of C++ code.

So, even if you’re not typing code directly, you’re still coding. It’s really cool how everything works!

What is the Level Blueprint?

The Level Blueprint is the best place to start learning about Unreal Engine’s Blueprint Scripting System. Continue reading, and you’ll be writing your first scripts using this visual coding system in no time.

The most important thing to understand about the Level Blueprint is that it only works for one level at a time. As a result, if you open or create a new level or map, the code you already have won’t work.

If you want your code to work on all levels, you must use Blueprints, like Blueprint Actors. I’ll go into more detail about this later.

For now lets open the Level Blueprint!

To do this, simply click on the Blueprints icon in the Viewport Menu, and then choose ‘Open Level Blueprint‘.

How to begin coding in Blueprints?

If you’ve done it correctly, you’ll see a new window with a gray grid. This window is called the Event Graph tab.

When you open a Level Blueprint for the first time, you’ll notice two disabled red nodes that you can either delete or ignore for now. These nodes will always be the Event BeginPlay and Event Tick.

I closed the Event Graph, how do I reopen it?

Tip: To open the Event Graph again, just go to Window -> My Blueprint. Now double-click “EventGraph” in the Graphs panel.

Step 1: Search for the Blueprint Node

This step may appear difficult at this time because you are unfamiliar with the Blueprint nodes.

However, if you use the same nodes repeatedly, you’ll quickly become familiar with them.

To find a Blueprint node, simply right-click anywhere in the Event Graph and start typing the node’s name.

In this case, type ‘Print String‘ and click on the node’s name to make it appear on the screen.

Step 2: Connecting Different Nodes

For the time being, it is critical to understand that red nodes will be the starting point for all Blueprint Scripting.

These red nodes are known as Event Nodes. You will find them inside the ‘Add Event’ section.

Event nodes start execution in response to something happening. Examples would be a button press or a collision.

For now, choose Event BeginPlay.

Add Event Nodes in Blueprints

So let’s connect the Print String to the Event Node!

Step 3: Execute code in Unreal Engine

Drag the left mouse button from the white arrow of the Event BeginPlay to the first white arrow of the Print String to connect the two Blueprint nodes.

These white arrows are known as Execution pins.

Do it exactly as shown in the screenshot below.

How to execute Blueprint Code in Unreal Engine

Simply press the play button in the tool bar to run the code.

How do I break connections?

Tip: Simply right-click on the execution pin and select ‘Break This Link’ from the menu. Alternatively, left-click on the connection line while holding down the ALT key on your keyboard.

Commenting Blueprints (C)

Adding comments to your Blueprints is extremely useful for maintaining organization within your projects, whether you’re working alone or as part of a team.

In the long run, if you revisit an older piece of code that you haven’t looked at in months, it will be much easier and quicker to understand if it’s annotated rather than without any annotations.

There are two types of comments in Unreal Engine:

Commenting Blueprints in Unreal Engine

The first option is to press the ‘C’ key on your keyboard. This will create a gray rectangle where you can add comments to make your code more understandable. You can change the color by selecting the comment box and changing the comment color in the details panel.

A Comment Bubble is the second option. Simply press the three small dots that appear in the left upper corner of a blueprint node to write it.

How to Straighten Connections?

Tip: If you are a very organized person, you will appreciate this tip. Select all of the blueprints you want to organize with a left click, then right click on the execution pin and select Straighten Connection –> Straighten All Pin Connections. Or just press the ‘Q’ key on your keyboard.

How to create a Reference in Unreal Engine

To reference actors in the Level Blueprint, select one actor in your Viewport or Outliner and right-click anywhere in the Event Graph.

Now select ‘Create a Reference to…‘ and the name of the selected asset.

Check that Context Sensitive is enabled if the option does not appear.

Keep in mind that this method only works within the Level Blueprint. It will not work with Blueprint actors.

It’s also important to understand that the chosen actor must be loaded in order to function properly. As a result, if you use world partitioning or spawn actors later in the game, the actor reference method may not work as intended.

Level Blueprint Create a Reference

Level Blueprint vs Other Blueprints

As you’ve read, the level blueprint is incredibly useful when working on prototypes, small levels, or games that only consist of one map.

However, in all other situations, you should be scripting within different Blueprints. There are numerous types of blueprints. The Blueprint actor, on the other hand, is the easiest to grasp as a beginner.

If you want to try it, create a Blueprint Actor, paste the Level Blueprint Code into your Actor Blueprint’s Event Graph, and finally place the actor in the level.

Unreal Engine Create a Blueprint Class
Blueprint Actor

I hope you found the information here useful. Happy creating!

Unreal Engine Roadmap