Exemplo n.º 1
0
        private void OnTriggerEnter2D(Collider2D other)
        {
            if (!other.CompareTag("Coin"))
            {
                return;
            }

            _AudioSource.PlayOneShot(_PlayerData.CoinSound);

            if (IsServer)
            {
                Destroy(NetworkSpawnManager.SpawnedObjects[other.GetComponent <NetworkObject>().NetworkObjectId]);
                _SessionManager.AddCoin(_ID);
            }
            else if (IsOwner)
            {
                _UI.SetCoinsCount(++_Coins);
            }
        }