Blueprint References in Unreal Engine 5

Video thumbnail

I'm going to show you how you can reference your Blueprints, which is quite useful. For example, in the following action, I have a collectible—as you can see on screen—that is hidden by default. To make it visible, I need to destroy some crates. You define how many you want to place and how you want them to behave, but that's the general idea.

Note that, before running the game, we already see the collectible in the editor:

Collecionable

For my implementation, I need to destroy a certain number of crates. In this case, I've set it to seven. Here I'm selecting it, and this property tells me how many crates should be destroyed, which in this case is 7. To make the example simpler, I'll only set one.

Notice that it's not displayed at the beginning. One of these crates is the one we have right here below. If I destroy it, you can see that the collectible appears. And at this point, of course, your implementation comes into play.

How does all this work?

Let's start with the Blueprint called CrystalHighCollect, which is exactly the one we have in the previous image.

Here you can see that I have a property called Show When Crystal Destroyed. This property tells me when the crystal should be displayed.

An interesting thing is that I'm applying a condition:

If the value is zero, it means I want to always display it by default.
That is, I don't want to use the cross-Blueprint reference functionality.

If I place one or more, the crystal will be hidden until enough boxes are destroyed.

We control this from the logic in the BeginPlay event.

Var BP


This is where the real logic comes in: in the referenced Blueprints, that is, in the components or actors that have a direct relationship with this collectible.

Is valid Node

And that's the trick: we can communicate between Blueprints. It's up to you what logic you want to implement, but the key is to understand how this communication is established.

To reference a Blueprint from the editor, we have a small selector (similar to the color selector). Click it and select the Blueprint you want to reference—as shown in the initial image.

Conclusions

What you do within that Blueprint is entirely up to you.
In my case, what this function does is increment the CrystalDestroyed property, which I showed you at the beginning, by one. This property indicates how many crystals have been destroyed, and once the expected number is reached, the collectible is displayed in the level.

And that's pretty much it.

This technique of referencing Blueprints can be applied to many things. For example:

  • If you have a door and want it to open when a certain condition is met.
  • If the player has a certain item in their inventory.
  • Or if an action in another Blueprint is completed.

All of this can be achieved perfectly using references between Blueprints.

I agree to receive announcements of interest about this Blog.

We will talk about references between Blueprints in UE5 to be able to innovate functions of a BP from another BP.

- Andrés Cruz

En español