I’m new to unity and unet. I’m trying to make a cricket game. I want to share a boolean variable between two clients.
if(isBatting==null){ if (random.Next (0, 2) == 1) { isBatting = true; Instantiate(batsmanPrefab, batsmanPrefab.transform.position, batsmanPrefab.transform.rotation); }else { isBatting = false; Instantiate(bowlerPrefab, bowlerPrefab.transform.position, bowlerPrefab.transform.rotation); } }else{ if(isBatting){ Instantiate(bowlerPrefab, bowlerPrefab.transform.position, bowlerPrefab.transform.rotation); }else{ Instantiate(batsmanPrefab, batsmanPrefab.transform.position, batsmanPrefab.transform.rotation); } }
in the above code, when the first person joins the network, the code will randomly assign it to batting and bowling mode. Then when another joins, he will get the current state from that boolean and get its opposite mode. But i am completely beginner in unity. So i have no idea, how to send and get data from the network server.
need help…