Beispiel #1
0
    // Controls behaviour if we get hit by lasers or a player
    void OnCollisionEnter2D(Collision2D collision)
    {
        string tag = collision.collider.tag;

        if (tag == "Laser")
        {
            Destroy(collision.collider.gameObject);
            Damage(damagePerHit);
            if (health <= 0f)
            {
                DownSize(collision.contacts [0].normal);
            }
        }
        else if (tag == "Player")
        {
            Death death = collision.collider.gameObject.GetComponent <Death> ();
            if (death)
            {
                death.Kill();
            }
            else
            {
                Debug.LogError("Death script missing on player");
            }
        }
    }
Beispiel #2
0
    void OnCollisionEnter(Collision collision)
    {
        GameObject gObj = collision.gameObject;

        if (gObj.tag == "Player" || gObj.tag == "Player 2")
        {
            (gObj.GetComponent("RigidbodyFirstPersonController") as MonoBehaviour).enabled = false;

            Death gObjDeath = gObj.GetComponent <Death>();

            if (!gObjDeath.isDead)
            {
                gObjDeath.Kill();
            }
        }
    }