Need efficient approach to Device with Independent/controllable LEDs v4.25.4

I have lots of meshes representing various electrical devices. I need to add LEDs to them that can be controlled/triggered from somewhere else. My approach at the moment is to add static mesh cubes (They slot into each LED port) and then create Events for each LED and link them up to a function that changes their material colour.

This approach means a lot of copying and pasting of nodes. I was wondering if there was a better approach?

I tried making a blueprint for a template LED but you can’t add blueprints inside of blueprints no?

Any help on this would be greatly appreciated!

I should clarify that I have lots of blueprints that each represent a device. Each device blueprint has similar functionality and I’m having to copy and paste that functionality to each at the moment. One bit of functionality is as I have posted above, LEDs that each get turned on/off by an event in the Level Blueprint. I want to be able to get my blueprint, add LEDs as static meshes to it and have the blueprint automatically give them the functionality, rather than having to keep adding it manually.

My current attempt so far uses ‘Get Components by Tag’ and then with a ‘For Each’ loop, trying to bind an event. That’s as far as I have got.

Create Your own messaging system.

Steps for it:

  • create game mode blueprint (because it is easiest to reference from anywhere, everything can find it and cast to)
  • in that game mode blueprint create dispatcher, lets call it MESSENER
  • create enumerator for groups/types of devices, like leds, numeric display, etc.
  • add to thet MESSENGER dispatcher parameters: enumerator for type, string, and device name/tag, and state (as string)
  • each actor that has some leds or controllable device, should hook to MESSENGER and listen for its type and name tag, then change state

Yes lots of strings (Easy to misspel).

However more advanced tips:

  • create base/parent actor that has that dispatcher hooked in begin play, and can read from it, parse and store state to some variables.
  • inherit from that parent class above, and create child devices one class for each type
  • then for difeferent visuals inherid from that child, add meshes and visuals, read variables from parent and change visuals/materials

Or you can do it all with blueprintable components instead of inheritance, but code for that is messy.

1 Like

Thank you very much Nawrot! Very clear answer, I shall give this a try :+1: