I am completely new to Blueprint and would love to get some support regarding Blueprint Interfaces. My target is to transfer a variable (or just the value) from one Blueprint (Widget) to another (Actor). The idea is to set the room dimensions (length, width, height) for a static mesh cube with the widget input.
You can see in the pictures attached, what I have done so far.
Interface: I have one input and one output to transport a value from one blueprint to another
Widget: I took the Editable Text Box Variable, took the text from it, converted it into a float and set it as an input to the interface. First question: What shall I use as the “Target” input in the Interface function?
Actor: Again: What to take as target, what to take as the input? Regarding my logic, there is no input necessary in my actor class.
Setup a reference chain so the widget knows the object, eg a overlap or trace hit result, place the interface on the object, place the message on the widget. send the new size via interface message, inside the interface function on the object place your logic to change size, hope that is helpful.
Hello there.
Interfaces are “empty” Function Declarations (in quotation marks, because they are not really empty in Blueprint, but just imagine they are empty).
To work with interfaces, your classes/Blueprints need to implement these interfaces.
For this, you need to go to the “Class Settings” (Top Bar of the Blueprint Window).
There is a section “Implemented Interfaces”. Add you interface there.
But what does an interface do? An Interface forces a Class/Blueprint to provide the functions of the Interfaces at Compiel Time.
This is really helpful when you want multiple, separate classes to have a common funcitonality.
So what is the benefit of interfaces over Inheritance or simply declaring the functions in multiple Blueprints?
Interfaces are a type, just like regular Blueprints/Classes are. Which means you can store a reference to an object which implements this interface.
To answer your question “What measn Target : Interface”?
Well, As I said, Interfaces are common Types like Blueprints/Classes. If you want to call a function of an interface, you need to plugin an object which implements this interface into Target.
As an Example for an Interface would be an “Area Interface” for different shapes.
The Interface “Area” would return the Area of a given Shape.
For the class “Circle”, the interface would return Pir^2
For a class “Rectangle”, the interface would return "ab"