Randomised roles

Basically, I want to create a murder mystery game where there is one murderer and the rest are civilians trying to escape. I have no idea how to set up a system where when the match begins one person is randomly the killer, any help is greatly appreciated

Hmm…well, I’ve never done a game like this before, but it sounds like you are making a multiplayer game so you should probably read up on Replication.

Other than that, I would try to get all the player controllers into a variable array somewhere (I think a server’s Game State would be the normal place for something like this in a multiplayer game?).

Then you could have a bool variable in each player controller that if it is true, that person is the killer.

Then all you would have to do is roll a random int of however many players you are having in your game, and whichever number you get, set that element in your player controller array to true on the killer bool. Then you can base any special coding or abilities you want the killer to have on branches testing if that bool is true (this will require casting to the player controller to check the bool if you are making anything in a blueprint that isn’t player controller).

…And, you have to do all of that while using Replication correctly (I can’t help you there, but Unreal has a ton of documentation that you can read on it. :slight_smile: )

If I understand your post correctly, you just want to randomize something? You could assign each character a number and use one of the random int nodes.

Or maybe there is even a random enum node somewhere, and then you could even do it by name.

Thanks for replying, as I am new to this, is there any chance you can point me in the right direction to set it up

Thanks a lot mate, I’ll have a look into replication and go from there, cheers :slight_smile:

did you ever find a solution? i have the same issue