Esempio n. 1
0
        void OnTriggerEnter2D(Collider2D other)
        {
            if (other.tag == "Player")
            {
                player.enabled = false;
                player.GetComponent <Renderer>().enabled = false;

                player.isAlive = false;

                Debug.Log("HIT!");
            }

            if (other.tag == "Player2")
            {
                player2.enabled = false;
                player2.GetComponent <Renderer>().enabled = false;

                player2.isAlive = false;

                Debug.Log("HIT! Player 2");
            }
        }
Esempio n. 2
0
        // Update is called once per frame
        void Update()
        {
            p1Score.text = "Player 1: " + p1s;
            p2Score.text = "Player 2: " + p2s;

            if (!p2.isAlive)
            {
                p2.enabled = true;
                p2.GetComponent <Renderer>().enabled = true;
                p2.myRigidBody.position = new Vector3(2f, 0f, 0f);
                p2.isAlive = true;
                p1s++;
            }

            if (!p1.isAlive)
            {
                p1.enabled = true;
                p1.GetComponent <Renderer>().enabled = true;
                p1.myRigidBody.position = new Vector3(2f, 0f, 0f);
                p1.isAlive = true;

                p2s++;
            }
        }