Countdown
Options
I did this script and it works fine but there is a problem, when I enter room it works fine and countdown works, but when someone else enters the room it counts down again, I want when a player enters, the camera is placed on the player who was already in the room.
sorry for my english
sorry for my english
(CSharp): private Text TimeUIText; private float timeToStartRace = 5.0f; private void Awake() { TimeUIText = DeathMatchGameController.instance.TimeUIText; } // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (PhotonNetwork.IsMasterClient) { if (timeToStartRace >= 0.0f) { timeToStartRace -= Time.deltaTime; photonView.RPC("SetTime", RpcTarget.AllBuffered, timeToStartRace); } else if (timeToStartRace < 0.0f) { photonView.RPC("StartTheRace", RpcTarget.AllBuffered); } } } [PunRPC] public void SetTime(float time) { if (time > 0.0f) { TimeUIText.text = time.ToString("F0"); } else { //The countdown is over TimeUIText.text = ""; } } [PunRPC] public void StartTheRace() { GetComponent<CarUserControl>().enabled = true; this.enabled = false; }
0