Giving a random player a role (Among Us)
Options
I'd like to recreate Among Us, but I don't know how I can randomly pick a player and give him a role (imposter, crewmate).
0
Comments
-
Using Player properties or Room properties, booth should work.
I wrote some code that should be useable out of the box using player properties https://pastebin.com/sf3TJjrP
Usage should be somewhat clear.
CallAssignTagToRandomPlayer(string tag)
to assign a given tag/roll whatever you wanna call it to a random player.
Get the player that has a given tag.GetPlayerWithTag(string tag)
or get all players with a tagGetPlayersWithTag(string tag)
0 -
@decoyishere You can also access other players 'Player' object through PhotonNetwork.PlayerListOthers. For example you could do any of the following:
var selectedPlayer = PhotonNetwork.PlayerListOthers[Random.Range(0, PhotonNetwork.PlayerListOthers.Length - 1)]
0 -
Using Player properties or Room properties, booth should work.
I wrote some code that should be useable out of the box using player properties https://pastebin.com/sf3TJjrP
Usage should be somewhat clear.
CallAssignTagToRandomPlayer(string tag)
to assign a given tag/roll whatever you wanna call it to a random player.
Get the player that has a given tag.GetPlayerWithTag(string tag)
or get all players with a tagGetPlayersWithTag(string tag)
i am getting in your pastebin code.
Errors :
The name 'SetTag' does not exist in the current context
The name 'GetTag' does not exist in the current context0 -
psychosija wrote: »Using Player properties or Room properties, booth should work.
I wrote some code that should be useable out of the box using player properties https://pastebin.com/sf3TJjrP
Usage should be somewhat clear.
CallAssignTagToRandomPlayer(string tag)
to assign a given tag/roll whatever you wanna call it to a random player.
Get the player that has a given tag.GetPlayerWithTag(string tag)
or get all players with a tagGetPlayersWithTag(string tag)
i am getting in your pastebin code.
Errors :
The name 'SetTag' does not exist in the current context
The name 'GetTag' does not exist in the current context
nvm. i am dumb.
0 -
now i am getting this error : The name 'PunPlayerTag' does not exist in the current context0