Trigger Interface function from Game State to Controller

Hi everyone :slight_smile:,

I’m working on a multiplayer turn-based game and I want to link my Game State BP with my controller BP(they are both in the same game mode).

I’m still a beginner so I think the problem came from a knowledge that I don’t have about the behavior of an interface.

So my problem is in the game state, I’m using a variable Player State that I’ll use in my controller to perform action on a specific player. After a branch, I’m using a function of my interface (Message) from a for each loop with all my controller (I tried several differents for test).


(it’s a simple version here without the player state)

In my controller blueprint, I’m using the event of the interface function to print string Hello (I also test with a widget).

image

The problem is that the event in my controller blueprint is never triggered. Does anyone know what I forgot or don’t know here ?

Thanks a lot to anyone willing to help me :smiley:

2 Likes

Does anyone could help me on this topic ? Thanks :slight_smile:

check if your Controller is valid in the loop, the advantage and disadvantage of interfaces is they dont notify you if they fail.

While your setup is fine this might be a better use for EventDispatchers but dont go changing everything if you’re not comfortable with that

2 Likes

Hey @LesPaul0689!

To add on a bit more to what @Auran131 explained, I would also double check that your array has all the intended members and the array is of the correct type. If your player controllers are not added to the array, it won’t fire either.

We can definitely figure this out!

1 Like

Thanks @Auran131 and @Quetzalcodename, I’ll check that :slight_smile:

For the array, it should be good, I’m using the event OnPostLogin on the game mode to store the players controller into an array. Then, in the event begin play of the game state, I cast the game mode and copy the array into a local array of the game state :wink:

I’ll come back to you after I perfom some tests :grin: Thanks again

I’m back, so I don’t really understand but it worked ! :+1: I create a new project and make this and it worked :

I check if it was valid like you said, I don’t know if it was the solution but the call of the interface work. Also, I discover that you need to put a breakpoint on the interface and on the node after the trigger in your other blueprint to see what it happen.

If you simply put a break after the event of the interface function, Unreal will not take it into account.

Thanks again for your help @Auran131 & @Quetzalcodename :smiley:

1 Like