Esempio n. 1
0
 void OnCollisionEnter2D(Collision2D col)
 {
     //If this object collides with the maincharacter, it will decrement health equal to the damage variable
     if (col.gameObject.name == "MainCharacter")
     {
         for (int i = 0; i < damage; i++)
         {
             MainCharacter.dec_health();
         }
     }
     else if (col.gameObject.name == "trackingenemy(Clone)")
     {
     }
     else if (col.gameObject.name == "Lazer(Clone)")
     {
         //decrease the boss's health if it collides with a laser
         dec_health();
     }
     else if (col.gameObject.name == "WallBlock")
     {
         //if the boss comes into contact with the edge of the arena, teleport back to the center.
         rb2d.velocity = Vector2.zero;
         mov_vector    = Vector2.zero;
         mode          = 2;
     }
 }
Esempio n. 2
0
 void OnCollisionEnter2D(Collision2D col)
 {
     //If this object collides with the maincharacter, it will decrement health equal to the damage variable
     if (col.gameObject.name == "MainCharacter")
     {
         for (int i = 0; i < damage; i++)
         {
             MainCharacter.dec_health();
         }
     }
     //Destroy(this.gameObject);
 }
Esempio n. 3
0
 void OnCollisionEnter2D(Collision2D col)
 {
     //If this object collides with the maincharacter, it will decrement health equal to the damage variable
     if (col.gameObject.name == "MainCharacter")
     {
         for (int i = 0; i < damage; i++)
         {
             MainCharacter.dec_health();
         }
     }
     if (col.gameObject.name == "Lazer(Clone)")   //if this object collides with a laser, play its death audio and destroy it
     {
         AudioSource.GetComponent <AudioSource>().Play();
         Destroy(this.gameObject);
     }
 }
    void OnCollisionEnter2D(Collision2D col)
    {
        //Stops the object, then reverses the direction of the vector upon collision
        rb2d.velocity = Vector2.zero;
        mov_vector.x  = mov_vector.x * -1;
        mov_vector.y  = mov_vector.y * -1;

        //If this object collides with the maincharacter, it will decrement health equal to the damage variable
        if (col.gameObject.name == "MainCharacter")
        {
            for (int i = 0; i < damage; i++)
            {
                MainCharacter.dec_health();
            }
        }
        if (col.gameObject.name == "Lazer(Clone)")   //If the collision is with a lazer projectile, the object will play its death sound and die
        {
            AudioSource.GetComponent <AudioSource>().Play();
            Destroy(this.gameObject);
        }
    }