Mini tutorial - Are you making good use of the construction script?

If you are new to blueprinting you might not know a lot about the Construction Script which is available on any actor blueprint.

The construction script gets called in the editor - you don’t have to enter play mode. This makes it is a great place to do some design time visual helpers.

Here’s an example:

My game is sort of like a racing game. You have several stations around the map and each station holds a list of races that can be played while the player is at that station.

To setup the races, I have an instance editable actor array. This makes it so that you can add any actors from the level into this array at design time, like this:
image

But there is a lot of these actors and it can be hard to tell which ones have been selected for use and which have not. So I wanted to add some colors and text so that my eyes can quickly see what is going on in the level.

The result is this:

So now I can easily see which of the actors are assigned to the station (the big pink SP), and which race they belong to easily because of the color scheme.

Here is the code to do that:


(note the conversion node between Select and Set Text Render Color is a convert to linear color node (just makes it so you can use friednly color picker))

So I first grab the array of the actors. In this circumstance it happens to be tucked away within an array of structs and the array is actually the keys to a map - however the only important thing here is just that we have an array of some actors to loop through.

So, looping through array of actors I can just use a select node to assign some colors and text to a text render component.

You’ll probably want to ensure that you set the text render component to Editor Only so it doesn’t show up in your built game.

Well, that’s it. Just a simple example of how you can make some very basic but extremely helpful little editor level design tools to help speed up your workflow.