- Home /
How do I make a random player generator?
Hi, Could someone please tell me how to make a random player generator button? So I'm making a game that currently can be played with 5 players, but I'm thinking of adding a "?" random button which selects any player from that 5 player list. I've searched everywhere and cannot find a good answer. If anyone could help that would be great!! Thanks
Answer by ArseneySorokin · Sep 27, 2018 at 10:51 AM
To select a random object from a list of objects, 1. create the list:
public List<GameObject> players;
fill it inside the editor.
Select one, using the Random Class.
GameObject randomPlayer = players[Random.Range(0, players.Count)];
Ahoy there ArseneySorokin,
Yeah!But...how now we can select this player to do stuff.I mean...I want to have a group of 4-10 players for example.Now I want to select someone as the murderer for example.So i want him to have a kill option that the inoccent players DONT have.With the lines of code you gave(wich i understand)...how im able to do it the easiest way by using the unity UNET.
Sorry for my bad grammar. Thanks so far, ArisZis
Your answer
Follow this Question
Related Questions
After Restarting Scene, Player can't move anymore 0 Answers
¿Los controles del Player se programan diferente para cada plataforma? 0 Answers
Why am I not jumping? 1 Answer
Random Number Generator 4 Answers
Triggering random sound on player 1 Answer