References are hard.

I don’t really know what is going on here. I’m trying to learn interfaces and am not doing so well. The images below is what I have. I’m just trying to transfer a integer without casting right now. And all these print strings only ever print 1 and 2.





1 Like

I see you’re trying to send the int to a widget or the player?

Then the ref needs to point to the widget or the player, currently it’s pointing at the same blueprint :slight_smile:

To send it to the player, try

image

Make sure the player is implementing the interface.

Interfaces don’t really have an implementation of their own, their functionality has to be implemented in the BP they are being implemented. It becomes polymorphic in nature. The problem you are facing could be, that the variable REF you are using does not have the implementation of New Function. Try implementing it and then set the reference properly, then calling the function.

Here I made a new interface with a function called “Do Something”

Then I created a new test BP called “BP_TestActor” and implemented the interface in it. Look at the lower right, where it says Implemented Interfaces. Also observe that now I have a new thing in the left menu called “Interfaces” where it is showing me the function that I have to provide implementation for. So I did that


Now I will create a reference to this blueprint by placing it in the level and then in the Level Blueprint and simply call this function and see what happens.

and here the 10 is printed on the screen
image

If it was a widget what would i do?

There is a similar node for widgets

image

Eventually, seeing as you’re making the widgets, you do have a reference anyway, and can use that. But for now, using ‘get’ nodes is fine :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.