Question by
Dudicus · Mar 16, 2016 at 12:11 AM ·
networkingserverclientcommand
Network Not Updating On All Clients PLEASE HELP!!!
I'm very new to networking in Unity so sorry if this is an easy question. When I try to change text and delete gameobjects it only shows up on the host. I know everything on this script might not be the most efficient way but I just want to know, not how to make it shorter. And I also know I might need to change to a NetworkBehaviour for SyncVar or ClientRpc. By the way, shouldStart is turned on in other scripts when a game starts. Heres the code:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.Networking;
public class GameController : MonoBehaviour {
public Text timer;
public Camera theCamera;
public GameObject removalWall;
[HideInInspector]
public bool shouldStart = false;
void Start ()
{
timer = GameObject.FindGameObjectWithTag("Timer").GetComponent<Text>();
theCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
removalWall = GameObject.FindGameObjectWithTag("RemoveWall");
}
void Update ()
{
timer = GameObject.FindGameObjectWithTag("Timer").GetComponent<Text>();
theCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
removalWall = GameObject.FindGameObjectWithTag("RemoveWall");
if (shouldStart == true)
{
StartCoroutine(StartCountdown());
shouldStart = false;
}
}
IEnumerator StartCountdown ()
{
timer.text = "10";
yield return new WaitForSeconds(1);
timer.text = "9";
yield return new WaitForSeconds(1);
timer.text = "8";
yield return new WaitForSeconds(1);
timer.text = "7";
yield return new WaitForSeconds(1);
timer.text = "6";
yield return new WaitForSeconds(1);
timer.text = "5";
yield return new WaitForSeconds(1);
timer.text = "4";
yield return new WaitForSeconds(1);
timer.text = "3";
yield return new WaitForSeconds(1);
timer.text = "2";
yield return new WaitForSeconds(1);
timer.text = "1";
yield return new WaitForSeconds(1);
timer.text = "Go!";
//removalWall.SetActive(false);
Network.Destroy(removalWall);
yield return new WaitForSeconds(1);
}
}
Comment