Exemplo n.º 1
0
    //make sure u replace "Plane" with your gameobject name.on which player is standing
    void OnCollisionEnter(Collision theCollision)
    {
        if (theCollision.gameObject.tag == "Egg")
        {
            if (isLocalPlayer)
            {
                scoreManager.AddPoint();
            }
            NetworkServer.Destroy(theCollision.gameObject);
        }

        if (theCollision.gameObject.tag == "GoldenEgg")
        {
            if (isLocalPlayer)
            {
                scoreManager.AddDoublePoints();
            }
            NetworkServer.Destroy(theCollision.gameObject);
        }
    }
Exemplo n.º 2
0
    //make sure u replace "Plane" with your gameobject name.on which player is standing
    void OnCollisionEnter(Collision theCollision)
    {
        if (theCollision.gameObject.tag == "Egg")
        {
            if (isLocalPlayer)
            {
                scoreManager.AddPoint();
            }
            NetworkServer.Destroy(theCollision.gameObject);
        }

        if (theCollision.gameObject.tag == "GoldenEgg")
        {
            if (isLocalPlayer)
            {
                scoreManager.AddDoublePoints();
                if (!particleSystem.isPlaying)
                {
                    particleSystem.Play();
                }
            }
            NetworkServer.Destroy(theCollision.gameObject);
        }

        if (theCollision.gameObject.tag == "Bullet")
        {
            isFrozen   = true;
            timeFrozen = 0f;
        }

        if (theCollision.gameObject.tag == "MovingBlock")
        {
            float   moveHorizontal = Input.GetAxis("Horizontal");
            float   moveVertical   = Input.GetAxis("Vertical");
            Vector3 movement       = new Vector3(moveHorizontal, 0, moveVertical);

            rb.AddForce(movement * 10);
        }
    }