Impact random character during gameplay

Hi - I’m trying to have a random player affected by a gameplay change a couple of minutes into play, eg they get infected. I’ve used breakpoints and endless print strings. The issue is that no matter what I try, the array doesn’t return a value for the cast to BP_PlayerController to read, it’s always blank.

Gameflow is lobby (select character) → play

Relevant blueprints are:

  • Lobby Game Mode event graph: I use Event OnPostLogin to add/remove all players to an array before game starts

  • Lobby Game Mode function: Use the array that’s collected the player controllers to set a player controller variable in the Game Instance so it’s persistent for when we move into play. I previously had the variable being called from the GameInstance and set here but that didn’t work either

  • GameInstance: PopulatePlayersInGame called from Lobby Game Mode above, and Choose Victim called in the game’s PlayerController blueprint which just calls this event after X seconds.

Have you tried get all actors of class(player character class) then get random array item?

your GET node is disconnected from the Array in the bottom picture

Turns out because it was running the code each time a player logged in, it was getting different values. I set the integer and then the player reference (off the set integer) and then stored that variable and that locked it in!

And yep the GET node was disconnected because I was messing around with things, it was connected when I was running things, though I have made those kinds of silly mistakes so often :smiley:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.