Simple Updating Variable across BP through Interface

Can’t figure out if I’m blind or just dumb at the moment, but can’t get a variable to update and pass to another BP through Interface. Reduced it to the minimum of just print strings.

Intended flow is player is unable to interact with something without item X → player picks up item (remote) → Variable ‘HasRemote’ gets updated → passed to Interface → Call that Interface on Character BP to get variable and make new interactions possible.



This is not set up correctly.

  • the BP_Remote calls its own Character Pickup
  • player pressing X also calls its own Character Pickup

They should be calling one another instead, there’s currently no communication going on whatsoever.


  • in the most stripped down version:

image

  • player calling it:


In this very example, there’s no need for a 2-way interface (you may need it for other reasons, of course - do tell). Here, the interface is only implemented in the BP_Remote.

When you press X, you must decide which actor you wish to interact with. How would you like it done? It’s usually a trace (look at something), an overlap (proximity) or a mouse click (widget click).

Thanks a lot, you’re right.

Essentially I have a general interaction in my character BP set up with a line trace that interacts with actors having a certain tag. It’s connected with actor BPs via another interface. That all works so far.

The player press x was just a simple interface test setup.

The idea for this interface is a sort of inventory. I have a list of boolians in it ‘has_item_xyz’ that gets updated when character BP interacts with/picks up item_xyz. Then I can access/update those boolians in other BPs, unlocking new interactions.

So the testing method is the culprit. You’d need to send the message to the actor you wish to interact with. Currently the player is calling it for Self. Unless the implementation of Character Pickup in the player does the tracing. We can’t see that here, though.

Yes, that was it! I’m so stupid lol
Got it all working as intended, though ran into another snag:

Right now I can get the variable (HasRemote) from the interface, but as soon as I interact with another pickup tagged actor, it gets overwritten. Is there a way to only update the bool in this BP once? Like once it changes to true, stay that way. Sort of like this mockup (HasKey is only there as mockup in the screenshot). Tried with a DoOnce and DoOnceMulti, but couldn’t get it to stick.

How many items are we talking about? I’m wondering if bools are good enough here. Perhaps it’d be more convenient to use a Set or a Dictionary.


So, the overall idea is that we interact with various items, pick them up, flag it. And now other interactions can be based on those bools. Right?

Exactly. Have the interface work as a simple inventory list that “stores” the bools and can then be called and updated whether player currently has item x and can thus interact with certain BPs or not.

Don’t know if there are better ways to do this. So far I’ve been doing archviz with only simple interactions, and just started experimenting more with blueprints and interactions to try my hands on a simple walking simulator/escape room kind of project.

How many items are you expecting? 30 or 300?


Consider the following:

  • the player has a Name Set, it’s a list of unique names. They can be added or removed but an entry cannot appear twice on that list:

  • above, the Interface call returns the Name of the Item and we add it to the Item List Set
  • when it’s time to use an item, we query the Item List container to see if the item is there
  • this way you only have 1 variable rather than dozens of branching, cascading Booleans

  • for this to work the Item would have to interpret the Interface message like so:

  • each item has a Name variable and you get to define it

You could use enumerators instead - less prone to typos. Working with 30 enums is a OK, working with 300 enums - not so much, though.

1 Like

And here’s the kicker. Let’s say that you already have a remote and you’re attempting to collect another one. You can send your Item List to the Item by reference:

The item can then respond based on the player’s current inventory content, and decide whether something needs adding to the inventory:

This way you do not need to complicate things with a 2-way interface. The items do not need to call the player. And you do not need to track variables in multiple blueprints. Previously you were updating bools in the player and in each item. With this approach there’s only one variable updated once - in the player.

1 Like

Wow, thanks a lot for that.

I can’t say I 100% understand everything that’s happening, but it seems like a more elegant solution to what I’ve been trying to do. Especially since it looks very scalable - for now I’m only trying to get it working with a handful of items, and then expand from there.

Definitely have to try implementing and toying with it a bit, but I think this is what I’ve been looking for. Thank you so much.

1 Like