Struggling to communicate between blueprints (setting a string variable value from other blueprints)

Sorry for a question I am sure has been posted 100 times already but no matter how many forum posts or videos I watch I can’t seem to wrap my head around this.

I have a sign in my game with text on it that is driven by a string variable in the sign’s blueprint class.

I would like other actions taken by other actors (The player hitting a button, objects overlapping a trigger) to change this text but to do so those other blueprints must change the string variable on the sign BPC.

How do I allow other blueprints to edit this string variable?

I would appreciate a detailed breakdown as I am very new to this element of development.

thank you very much.

  1. Add a function that takes a string input on your blueprint class

  2. You will need to get a reference to this blueprint from a event. Take a trigger for example. Add a trigger to your level.
    image

  3. Open your level BP while selecting the trigger.
    image
    Add the reference for trigger to level BP, do the same for the sign blueprint.
    image

  4. Bind the trigger event to call Change Text on sign blueprint.

1 Like

It’s circumstantial. Here’s another approach:

  • the Sign updates its own text when this Custom Event is called (the variable is optional):

  • when stepped into, the Trigger :point_down: calls that event :point_up_2:, asking an instance of the Sign to update its text:

  • since we flagged the SignReference as Instance Editable :point_up_2: we can tell the Trigger which instance of the Sign to talk to:

Thank you for the solution!

I was wondering if it was possible for the player to hit a key on their keyboard and have that change the text on the sign only while that key is pressed?

Sure.

  • how do we know which sign? (in case there are many)
  • are we looking at it?
  • is this proximity based? (we just need to be close)
  • combination of the 2 above?
  • is it hard-coded? (one sign only, ever)
  • is it just a sign, or are we going to interact with many actors with the same key?

It’s circumstantial.

See what I mean. Depending on what needs to be done, you’d script it differently. There is no one best way to communicate.

I just want to make it so when a key is held the only sign in the world changes its text, and when it’s released, the text changes back to what it was originally.

• OnKeyPress → Get Actor of Class → Do Stuff
• OnKeyReleased → Get Actor of Class → Undo Stuff