How to know whos winner
Options
Hello I wrote this script to know who won and lost. Basically there are 2 main units, if one of them dies owner of that unit loses the game. but somehow this isnt working.
GameObject loserPanel; GameObject winnerPanel; Combat enemyComat; void Start() { photon = GetComponent<PhotonView>(); isDeath = false; animator = GetComponent<Animator>(); stats = GetComponent<StatsHolder>(); dmg = 10+((float)stats.level*1.25f); loserPanel = GameObject.FindGameObjectWithTag("LoserPanel"); winnerPanel = GameObject.Find("Canvas/WinnerPanel"); } private void OnTriggerEnter(Collider other) { if (other.tag == "Player"||other.tag=="PlayerM") { if (enemyComat = null) { enemyComat = other.gameObject.GetComponent<Combat>(); } other.gameObject.GetComponent<PhotonView>().RPC("Combat1",RpcTarget.Others,dmg); } } void Update() { if (isDeath) { Destroy(gameObject, 3); } if (this.tag == "Player11" && isDeath == true) { Debug.Log("You lost"); loserPanel.SetActive(true); } if (enemyComat != null) { if (enemyComat.isDeath == true) { Debug.Log("YouWon"); winnerPanel.SetActive(true); } } }
0