- Home /
Check bool on another player
Hi everyone,
I've recently started the multiplayer for a project. I don't have much experience with networking in unity, so I'm blaming lack of experience for this brain-block...
My problem is:
I have a bool ready; This bool is used on the menu to see if the player is ready, if they are display that they are and show a "Start game" button. Easy stuff! Now I'm having trouble checking the ready status of other players. All players need to know the ready status of all the other players, so that the GUI will update for each player.
This really boils down to "How do I check a variable on another player across a network". RPC's can't return values for obvious reasons.
I have tried using RPC's to pass variables, as shown in This Question but even then, I need to update the GUI based on the value of other players variable status, not just assign a variable to another players variable. I was thinking of assigning each player a number, then associating the ready bool in some way to that... But then it all gets convoluted and I start feeling like I'm overthinking things.
I would've thought that accessing variables on other players would be pretty simple, as I'm sure it would be used a LOT in multiplayer games, if someone could shed some light on this for me that would be great.
Thanks a lot!
Edit: I'm using Photon Cloud for networking. Not sure if that opens more options for me, or helps someone help me :).
Have you tried doing a "static bool ready = false;" on every players? And then a if(PlayerX.ready == true && PlayerY.ready == true) ......
static variables would suit the situation I think. $$anonymous$$y problem with your idea would be "playerx". Where and how would "playerx" be assigned? I did design I small system of incrementing an int when a player joins, then adding that to the end of a string variable set to "Player". But my problem with that is, what happens if player2 leaves in a 4 player game? Again... "then it all gets convoluted and I start feeling like I'm overthinking things."
Shit yea. Leaves IN the game or BEFORE launching the game ? If everyone isn't ready, Player2 can leave, to free his place. I think you must write it down on paper. it's called "specifications" : you write all the features down that you want to do, and then check if it's realizable or not, and if it is, then, check how you can do it.
I know how to prepare and design a system before I start working on it, I also don't feel that advice helps to answer the question. Thank you though, I appreciate that your trying to help.
I feel you may be fishing for information: We would like to leave the game open to players during a game, this feature might be removed later if it proves too difficult and time consu$$anonymous$$g to allow. I don't feel that a simple "ready check" should make us re-think the decision to allow during-game joins.
No problem. But think of that : nowadays, very recent games has that function, and if only severals games use that system, i think it is because it is hard to make. And devs are not alone on the project. Here you are the only guy. And you are not so experienced. I think you should give up that "replace player who was in ame" feature. Think first of your game, and of bans if a players leaves.
Answer by Jaws959 · Feb 13, 2015 at 07:54 AM
Hi there, I am actually trying to do exactly the same scenario here on a game I am currently making. For each player, the Photon Network Plugin uses allocated View ID's which can be set for each player for example, "int userID = PhotonNetwork.AllocateViewID ();" Using this might help you control each player's view as you can write IF statements for their specific userID, however I still do not know how to get the boolean synchronized to make ready check.
Your answer
![](https://koobas.hobune.stream/wayback/20220613070212im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
how to properly clean up the NetworkView to prevent errors ? 0 Answers
Multiplayer Moving Bullet 1 Answer
Check RPC is from Server 1 Answer
RPC call not sending correct data 0 Answers