Broadcast update : what would be the smart way to do it

There are a couple ways I think you could do this. You’ll probably want to check out the “Blueprint Communication Methods” section of this page: Specialized Node Groups | Unreal Engine Documentation (I think there are also some demo maps/videos, but not sure off the top of my head).

One way is the aforementioned looping over a collection of actors manually and acting on them that way. You could construct that list in different ways (looping through actors up front and putting them in a list, having actors register themselves into a list as they begin play, etc.). If you needed different types of actors to be usable, you could also look into blueprint interfaces and use them in conjuction: Implementing Blueprint Interfaces | Unreal Engine Documentation.

However, another way you could do this seems much closer to what you’re used to. I actually had to just try this out myself because I’ve not used it yet (I live mostly in C++, so this was a fun excuse to learn!): Event Dispatchers | Unreal Engine Documentation

To try out your example, here’s what I basically did:

  1. Created a blueprint that represented the sun.
  2. Made the sun easily globally accessible to other blueprints.
  • There are various ways to do this. I assumed in this example that the sun was an important gameplay element that there was probably only one of, so I actually spawned it and stored a variable reference to it inside my GameMode’s blueprint. Note this wouldn’t be accessible to clients in a networked game (would probably want it in the GameState for networked play).
  1. Added a float variable to the sun blueprint to represent current temperature.
  2. Added an event dispatcher to the sun blueprint that will be fired every time the sun should broadcast a temperature update.

  1. Added a float input to the event dispatcher representing temperature.

  1. Hooked up a timer to call a function that would update the sun’s temperature every second inside the sun’s blueprint.

  1. Made the update function just constantly add to the sun’s temperature (getting hot in here!). In each update, it also calls the event dispatcher so any listeners will get the update.
  • To call the dispatcher, just drag it from the variable pane into the event graph and you’ll get a context menu:

  1. Created another blueprint that would act as a listener for the sun updates. I cleverly called it SunListener! So creative! :stuck_out_tongue:

  2. Hooked the blueprint up to be a listener to the sun’s event dispatcher by:

  3. Accessing the game mode during BeginPlay in the listener’s blueprint, casting it to my custom GameMode blueprint, and then accessing the sun variable stored there.

  1. Pulling off of the sun variable node and selecting the corresponding Assign function.

  1. Hooking up whatever I wanted for the auto-generated event from the Assign function. In my case, I just made it output the name of the actor and the temperature it received to the screen so I could see it was working.

  1. Placed some of the listener actors in the world, ran the game to see what happened…and VOILA!

Hope this helps! I’m definitely not a blueprint expert, so there may still be some other better ways to do this too!