Blueprint Interface - How do you retrieve variables once you have passed them?

So I am working on a blueprint interface so I can pull variables stored in my GameMode blueprint and pass them to my Map Generator.

Interface is implemented on both BP’s under blueprint props.

Interface has inputs for 4 variables which are connected in the GameMode BP to a Interface Message node. The Interface Message node also has the MapGenerator blueprint variable attached to it’s target input. I take this to mean I am sending these variables into the interface for retrieval by the MapGenerator BP.

In the MapGenerator, I have the Interface Event that outputs the variables I am trying to pass. This event never gets called. Going through the documentation this seems to be the way to pass the outputs of this interface but it just isn’t firing. I tried calling the event directly but it doesn’t show up in the context menu.

What am I misisng?

Try this setup:

GameMode blueprint has IGameMode (blueprint interface)
IGameMode has “NewFunction” with 4 input variables as you said. You can call this function to run stuff but also to return some values without calling any messages.

6361-interfaceoutputs.png

Then, you don’t need any interface set on MapGenerator. Just right-click and look for “NewFunction”, it’ll be in “Interface Messages” under “IGameMode_C” category. Place it on graph and apply inputs and outputs as you wish, you can pull off returned variables from the right side of this node:

Finally, define what “NewFunction” does in the BGameMode blueprint:

and

My GameMode BP doesn’t have any such interface…

Then create one yourself! :slight_smile:

Good to read:

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Types/Interface/index.html

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Types/Interface/UsingInterfaces/index.html

Oh I thought that was specific to whatever interface you were talking about.

I see now how you can lay nodes between the function, but isn’t that just for local override?

Here is what I am trying now:

First is the interface function in WorldData BP.
Then I am trying to fill the inputs with my variables.
Then I am trying to pull one of those inputs in my GameMode BP.

It is passing 0 to my print string instead of 10.

Am I doing things out of order or what? Do I pass the message on one and then use local on the receiver?

I feel like the doc page could be fleshed out quite a bit for a better explanation.

If you’re trying to pull variables from GameMode BP to WorldData BP, then I can see this setup (sorry for no screenshots, but I’m out-of-office):

  • GameMode BP has local variables, all 4 that you mentioned.
  • GameMode BP has attached Interface GameModeInterface. Not “WorldData”, because we’re trying to run functions/pull variables from the GameMode itself, so let’s call it “GameModeInterface” or “IGameMode” in short.
  • GameMode Interface has definition of function “GetWorldData”. Let’s use word “get” because it’s generic programming language word to get variable values from objects.
  • GetWorldData function has 4 output variables, not inputs. This function is only responsible for letting others know about GM’s data, not the other way around.
  • GameMode BP - enter “GetWorldData” definition, and attach variable nodes to every output pins in Return node.
  • Finally, in ANY OTHER blueprint you want: place GetWorldData function and use it’s output pins.

but isn’t that just for local override?

Yes and thats what Interfaces are for. If you attach InterfaceA to “BlueprintA”, then other blueprints can call Blueprint’s A functions that are listed in InterfaceA. Later, in each blueprint type, you decide what exactly those functions do.

For example : one “enemy” blueprint, when getting HitByTrain can decide to reduce it’s health but other “enemy” (which is sharing the same interface as the first one) can ignore it and just bounce off. HitByTrain here is one of the functions listed in the Interface and each enemy type defines their own functionality for this function name.

So I tried a few different combinations of message and target but no luck.

If I am in GameMode, and I want to pull variables from WorldData, then I use the message node(with envelope) with WorldData as the target to call the function in WorldData? Then I use the local version in WorldData to pass the variables?

I have tried every combination of of message node and target but the variables always pass 0.

Ok, I had an epiphany and it worked.

I put all my variables that I want it to call inside the function. So instead of just bridging the gap to the outside, they are on the inside tied directly into the Outputs. For some reason it wasn’t pulling them from the input to the output.

So here is how I understand it now:

In my GameMode I use the Message node with WorldData as a target to call the function in WorldData. That function is loaded with the variables to the outputs so when I draw off the output in GameMode it gives me what I want.

No need for anything to happen on the graph of WorldData as long as the function is complete and tucked away in the function list.

Please correct me if this is wrong or you have any additions. Thanks for your help! :slight_smile:

For anyone interested this is really all I had to do to pass the variable:

Yeah, I was late with my reply :smiley: You can read my last comment for more info, but I wasn’t completely sure from which place you wanted to pull/get variables. Cheers!

Thanks again, I will take this into consideration when I try to do more complicated things with my interface. :slight_smile:

Hopefully this is also a good additional reference for others as lost as I was.