I understand basic purpose of using interfaces in blueprints. An object implements a defined interface, then when another object has a reference to it, it can test if it implements the interface, and optionally call some interface functions, which the first object can then handle.
I’m looking to do something slightly different, and more in line with how interfaces are used in C++ I want to create a variable on an Actor BP, and give that variable an interface type that I have defined. Then I want to assign that variable to an object that has implemented the interface. I can do the first two steps, but I cannot seem to be able to assign an object that implements the interface.
For example, I’ve made an “Animal” interface:
And I’ve defined a single method “Noise” which returns a string:
Now I have a new BP called “Animal Owner” that has a variable of type Animal Interface
And on its BeginPlay, it simply calls the Animal variable’s “Noise” function
Lastly, I have a “Cat” BP that implements the Animal Interface
All of this seems to be set up so that it would work. But I can’t assign the Cat to the Animal Owner’s Animal variable. It doesn’t list the Cat BP from the dropdown, and drag and drop doesn’t work either, even though Cat implements the Animal interface:
Anybody have an idea what I’m doing wrong? The only thing I can imagine is that “you can’t do that.” But then I would ask why can you even make a variable to have an interface type if you can’t assign anything to it? Thanks