Download

Communication between Level blueprint and player-chosen instance of Class blueprint

Hi there.

I have many instances of one blueprint around a level of my turn-based game.
Blueprint have 2 boolean parameters, let’s call them “Active” and “On”.
On is randomized and player cannot control it directly, so at any given turn there are some On and not On actors that are stored in respective arrays in Level Blueprint (dispatcher “EndTurn” triggers event with resorting logic).

I want the player to be able to make one of On actors Active when player clicks on that actor.
But I also want to allow only one Active actor in level.

Thus, when the player clicks on actor, I want to check if:

  1. Current actor is On, then somehow notify player if it is not On(that’s easy)
  2. Current actor is Active, then make it not **Active **(that’s easy)
  3. Current actor is not Active, then check all other On actors if any of them is Active. If nothing found, make this actor Active. Else, notify player that there’s another Active actor at the moment.

My first thought was to create function in Level BP that has actor on input(to know which actor was clicked), checks things using already existent arrays, then outputs Bool True if any Active were found in On array or False if not. But afaik, there’s no way to call Level Blueprint function from Class Blueprint.
Also, in this tutorial an Event Dispatcher thing is described, but creating Custom Event from 100+ instances of my BP does not look like a good idea.
What else can be done to help with my Blueprints’ miscommunication? Seems like I miss something very obvious…

Thank you in advance.

interface on BP and event in your game mode to decide turns, and your controller can call/loop through available actors saved in gamemode’s objectArray for remaining Active actors.

Should I move my arrays and sorting logic form Level BP to Game Mode BP and then establish communication between actor’s BP and Game Mode BP?

I started using UE4 just 2 weeks ago and that’s my absolutely first experience in anything more complicated than simple Excel sheets.
Complete noob here, so please sorry for asking for details and/or misunderstanding.