BluePrint Interface Message

Can anyone please explain what is BluePrint Interface Message and when I should use it ? as I dont understand it.

Thanks

An interface is just a set of functions with defined inputs and outputs, but no implementation. Each Actor that wants to offer the functionalities described by an interface has to define its own implementation for it. It is easier to understand through some examples.

Say that in your world there are objects (Actors) that you can pickup/drop and others you cannot. In principle you don’t know which ones you can pickup/drop. An Actor that wants to provide the capability to be picked up, can implement a Pickup/Drop interface to attach itself to the player’s hand when picked up and detach itself when dropped.

The player actor (Pawn) just needs to get close to an object and call the interface pickup function. If the object the player is close to implements that interface, the object will be picked up. If not, the object will just ignore the request and stay where it is.

The beauty of interfaces is that you can always call them without knowing upfront whether it will work or not (actually you can query an object to ask if it implements a specific interface), but also without generating any error if the object your are calling the interface for doesn’t implement it. In other words, you can always call an interface for an object. If the object you are calling the interface for implements it, it will react to it, otherwise nothing will happen.

Say for example you also have weapons in your game. A weapon can implement the same pickup/drop interface as before, but additionally can implement a Fire interface. So you can pickup/drop a weapon and, when you hold it, you can call the Fire interface function to have it fire a bullet.

If instead of a weapon you pick up a torch, you can call the Fire interface for it as well, but instead of firing a bullet the torch will simply light up because it implements the exact same interface differently. Finally if you pickup an apple which doesn’t implement the Fire interface, you can still call Fire on it but nothing will happen.

This is the official reference on using Interfaces with Unreal Engine 4, but the concept is common to other systems/programming languages:

Hope this helps!