x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?

Product Version: Not Selected
Tags:
more ▼

asked May 15 '14 at 03:26 AM in Blueprint Scripting

avatar image

Zeustiak
1.8k 131 68 110

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Try this setup:

GameMode blueprint has **I**GameMode (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.

alt text

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:

alt text

Finally, define what "NewFunction" does in the BGameMode blueprint:

http://i59.tinypic.com/2iviivp.png

and

alt text

more ▼

answered May 15 '14 at 09:58 PM

avatar image

Zielak
235 8 14 18

avatar image Zeustiak May 16 '14 at 07:28 AM

My GameMode BP doesn't have any such interface....

avatar image Zielak May 16 '14 at 10:23 AM
avatar image Zeustiak May 16 '14 at 12:18 PM

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: alt text 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.

avatar image Zeustiak May 16 '14 at 12:49 PM

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.

avatar image Zielak May 16 '14 at 01:16 PM

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.

avatar image Zeustiak May 16 '14 at 01:48 PM

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

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

avatar image Zeustiak May 16 '14 at 12:59 PM

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! :)

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

avatar image Zielak May 16 '14 at 01:27 PM

Yeah, I was late with my reply :D 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!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question