Select random player as traitor

Hi there! I am trying to develop a multiplayer “who is the traitor” sort of game, but am currently stuck.

How would I go about randomly selecting two players as a traitor when the level loads up, while the other players are just normal?

Sorry if this is actually really easy… Any help is appreciated!

Thank you in advance! :slight_smile:

I have a similar situation where I need to give a player on a specific team a bomb when the match starts. If you just need it to fire off as soon as the level starts then I recommend putting (or spawning) an actor into the level at play. Then get all actors by tag or class and check to see that the array has enough elements to pick a character (i.e. waiting for the array to have two elements instead of one) if it’s not valid, delay 0 then check again. Then when the elements are valid, pick one (random or w/e) and then set that element as a traitor.

It’s best to have a method to notify the game that all/enough players have connected but I’ll leave that up to you. If you have such a method just get a member of your game through that method instead.

I can’t provide screenshots right now but the nodes would look like this:

Begin Play
OutActors = GetAllActorsOfClass/Tag(Character Class or tag)
If (Len(OutActors) <= 1){Delay 0 and check again}
Else {Get random OutActor and set as traitor}

I hope this helps!

Help pls with ss :frowning:

FYI “traitor” games are known as “Werewolf” or “Mafia”.

Have you created MP games before? That would be a good start.

How do you normally make random selections?