예제 #1
0
    //will occur when player interacts with Enemy object
    void OnTriggerEnter2D(Collider2D collide)
    {
        if (collide.gameObject.tag == "hurtbox")
        {
            //to kill enemy, we tell the enemy script
            TheEnemy script = collide.gameObject.GetComponentInParent <TheEnemy>();
            script.Die();
        }

        if (collide.gameObject.tag == "hurtbox2")
        {
            TheBoss script = collide.gameObject.GetComponentInParent <TheBoss>();
            script.Oof();
            Debug.Log("oof");
        }

        if (collide.gameObject.tag == "hitbox")
        {
            health--; //player takes damage
        }

        if (collide.gameObject.tag == "checkPoint")
        {
            SpawnPoint = collide.transform;
            GameManager.UpdateSpawn(collide.transform);
            Debug.Log("2");
        }
        if (collide.gameObject.tag == "Finish")
        {
            SceneManager.LoadScene(newscene);
        }
    }
예제 #2
0
 public void OnTriggerEnter2D(Collider2D collision)
 {
     //if this object touches an enemy's hurtbox
     if (collision.gameObject.tag == "hurtbox")
     {
         //to kill enemy, we call enemy script Die() function to kill object
         TheEnemy script = collision.gameObject.GetComponentInParent <TheEnemy>();
         script.Die();
     }
 }
예제 #3
0
    //will occur when player interacts with Enemy object
    void OnTriggerEnter2D(Collider2D collide)
    {
        if (collide.gameObject.tag == "hurtbox")
        {
            //to kill enemy, we tell the enemy script
            TheEnemy script = collide.gameObject.GetComponentInParent <TheEnemy>();
            script.Die();
        }

        if (collide.gameObject.tag == "hitbox")
        {
            health--;             //player takes damage
        }

        if (collide.gameObject.tag == "checkPoint")
        {
            SpawnPoint = collide.transform;
            GameManager.UpdateSpawn(collide.transform);
        }
    }