Hello everyone, I am trying to make mini game with roles for example every game have 2 civ 1 doctor 1 police but i want to randomize the enum for 2 player have role(police , doctor) except 2 players have civ role but i don’t know how to do that i trying a lot but i got different result if anyone can help me I really appreciate it
You can use my example below, mine is assigning a profile pic to a player and am storing them in their player state.
Player State BP
You can replace my player icon texture variable with your Enum Role.
If you need that role to be persistent across switching map you will need to set it to their game instance as well.
Game Mode BP
For the array, depending on your game style if a role can be assigned to only 1 player, you will want to make a remove element from array or something similar to prevent assigning duplicate role.
You will need to create a player state bp, these work similar to a controller bp but for multiplayer, since they exist in client and server where you will want to share the player data.
Create bp player state, open it and add your variable enum ERole from it.
I got the solution after I understand how array works
First, I make player state blueprint. Then, I add player role variable for player state (BP_Test. Next, I add Roles array into game and roles inside array. For example, mafia, civ, etc. Finally, In game mode i use on post login then cast to bp_test and shuffle the array to randomize for each loop to set result of array to assign player role variable after assign variable it will be removed from array to avoid duplicate role assignment.