Blueprint Interface with variables (scratching my head)

Hello there,

Disclaimer: I’m new to UE4 (and programming) and now using 4.4

At first, I’ve been able to work fairly easily with BP Interfaces. I assigned the interface to each blueprint involved and then call the event(s) or the function(s) so far so good BUT I keep failing at transmitting a variable using a BPI (Inputs - Output).
I’ve been looking into Tutorials, I’ve checked the Example on the marketplace, tried to use the most basic set-up (assign a default value to the variable on one side and just try to do a print string on the other side) but no matter what I get 0 when I try to read the Output.

Any idea what could go wrong ?

Thanks

Hey mindfane,

Ok so the BPI:

Now the BP “caster” assigning the value:

The “Time” variable is ok if I print it via the event graph, it does what it supposed to do.

■■■■…I can’t post more than three screenshots in one post.

New post incoming in a sec

Following post:

Third screenshot, the BP trying to read the value from the BPI

Weird thing: my first post disappeared…

So the BPI

and The BP assigning the value (via function)

The variable Time is correctly updated (checked using a print string in the vent graph) but nothing comes out like I’m unable to assign the value into the BPI

I found a workaround by putting my variable calculation into the BP gamemode and then from the BP HUD using a “get gamemode” to ultimately get my variable.

Very efficient and simple but obviously I feel very stupid not being able to get the BPI works as it should ^^

Can you show as a screenshot of your BP interface function declaration and also a definition?

Check these things:

  1. Make sure you have set a value to the variable ‘Time’ in your caster class at some point before you call ‘Race Time’ on it. Otherwise it will return the default value for this variable…which I am assuming is Zero.
  2. I see that you are calling the function on PlayerCharacter directly. Try casting your PlayerCharacter to ‘TriggerRace’ and call the function ‘Race Time’ on the casted object.

PS: However if the ‘Race Time’ function is supposed to return the time sicne the race started, I think it is best put inside GameMode class instead of the Character class. So I think your current solution is the right way to go.