Download

Trouble understanding Blueprint Interfaces

Hi There,

From my understanding an interface is essentially a contract that ensures the functions of said interface are implemented in any blueprint that inherits the interface.

I’ve just run a test in 4.13.0.

Say i create an interface called Character_Movement and it has a function called Character_Climb it takes a transform and actor as inputs. I then open the standard ThirdPersonCharacter Blueprint and inherit the Character_Movement Interface.

Shouldn’t the project fail to build and run if Character_Climb from the inherited interface hasn’t been implemented in the ThirdPersonCharacter blueprint?

In my case the project builds and runs just fine invalidating the requirements of the interface, so just wondering if I am doing something wrong or misunderstanding what an interface is for.

You only need to place the interface on the BP that has the code for what happens when the interface message is sent.

So say you want to send a message from an enemy every 5 seconds to your character BP. You implement the interface on the character BP and make an Event YourInterfaceFunctionName and make some code happen. All you do on the enemy BP is use a YourInterfaceFunctionName (Message) node and your character BP will execute the event.

It’s just for communicating between BPs.

Isn’t this what event dispatchers are for though not blueprint interfaces? I always assumed a blueprint interface was the same thing as a C++ interface.

It is the same as a c++ interface, but more lenient. The blueprints that inherit from a blueprint interface automatically create functions with return values for you, but void functions you need to place on the graph yourself.

Interface functions with return values will only complain at you if your return value is an array, and I think object type.

From what I understand event dispatchers ‘listen’ for some function to execute and then execute some code when it occurs but it notifies every object that uses it. I think interfaces are more targeted. So you can send information to a particular BP.

Thanks guys for the explanations, much appreciate it.