How do I choose a random player in my game?
Take a random number between 0 and peercount:
random(Multiplayer.PeerCount)[/code:3kvfwk9j] To get the PeerID of the random picked Player: [code:3kvfwk9j]Multiplayer.PeerIDAt(random(Multiplayer.PeerCount))[/code:3kvfwk9j]
Develop games in your browser. Powerful, performant & highly capable.
How do I see the Username of the player? And the Id of the player is not showing... I made it the text of a text object.
For username just use PeerAlias
Multiplayer.PeerAliasAt(random(Multiplayer.PeerCount))[/code:19bc7vrf] Did you read the official 4 Part multiplayer Tutorial provided by Ashlay? [url=https://www.scirra.com/tutorials/892/multiplayer-tutorial-1-concepts]Link[/url] This will answer most of your questions.
Prolly want an int() in there.
Oh thats right
Multiplayer.PeerAliasAt(random(int(Multiplayer.PeerCount)))[/code:3kwvszz0] [b][EDIT:][/b] Nop i did not, i tested it, no need for [i]int()[/i] [code:3kwvszz0]Multiplayer.PeerAliasAt(random(Multiplayer.PeerCount)) Multiplayer.PeerIDAt(random(Multiplayer.PeerCount))[/code:3kwvszz0] These are working fine
int(random()), int(multiplayer.peercount) is googles.
I would imagine it's already set to only deal with whole numbers.
No such thing as a fraction of a peer, still, it's better to be safe than sorry.