What is a Blueprint Interface?
In Unreal Engine, Blueprint Interfaces are used to make different Blueprints in your game understand and follow the same set of rules or instructions.
For example, interfaces are particularly useful for setting up objects as interactable or not.
It’s like putting a label on them: if they have the label, the player can interact with the object. If the label is not there, the object is not interactable for the player.
That’s why Blueprint interfaces are very useful for avoiding unnecessary casting.
1. How to create Blueprint Interfaces?
To create a Blueprint Interface, simply right-click or use the ‘+ Add’ button in the Content Browser, then select ‘Blueprint → Blueprint Interface‘.
Then, name the file as you prefer. Just remember the name, as it will be important in the following steps.
2. Create Blueprint Interface Functions
Next, double-click the Blueprint Interface, and a new window will open.
Here, you simply need to name the function that you want to use in this interface. At this step, you are essentially creating the ‘label’ that you will apply to other objects.
Name the function as you prefer, such as ‘interact,’ ‘change material,’ or any other action you want the object to perform.
You can completely ignore the event graph on the left, as it is read-only, and you can’t make changes there.
Just add as many functions as you like, name them, and you’re good to go.
Tip: Additionally, you can also include inputs and outputs, just like in any other function, but it’s not mandatory.
3. Add Blueprint Interfaces in Unreal Engine
The next step is to apply the Blueprint Interface to the objects we want to interact with. Let’s say we want to label them as ‘interactable’.
To do this, open the blueprint with which you want to interact and select ‘Class Settings‘ from the top menu.
Then, in the details tab, choose ‘Interfaces -> Implemented Interfaces‘ and click ‘Add‘. Now, choose the Blueprint Interface you created in step one from the list.
Tip: If you’re familiar with inheritance, adding the interface in the parent means you won’t need to repeat this step for the child.
4. Interacting with Blueprint Interfaces
Finally, all you need to do is create an interaction with the actors you want to interact with, whether it’s by overlapping or using a line trace.
When the interaction happens, simply call the Interface by its name.
I plan to expand on this section in the near future, but for now, I’m confident that this video will help you understand what I mean.
Unreal Engine Learning Path
Blueprints Course
Learn more