Example #1
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "Player")
     {
         hearts.takeDamage();
         soundManager.playIceSound();
         // healthBar.TakeDamage(5f);
         Instantiate(impactEffect, transform.position, transform.rotation);
         Destroy(this.gameObject);
     }
 }
Example #2
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "Player")
     {
         Debug.Log("Hit player!");
         hearts.takeDamage();
         //gameObject.SetActive(false);
         Destroy(gameObject);
     }
     else if ((col.gameObject.tag == "Playground") | (col.gameObject.tag == "MovingPlatform"))
     {
         //Debug.Log("Playground collision");
         //gameObject.SetActive(false);
         Destroy(gameObject);
     }
 }
Example #3
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "Player")
     {
         //timer is to avoid getting "hit" twice on the same collision
         if (timer >= 60)
         {
             hearts.takeDamage();
             timer = 0;
         }
         else
         {
             return;
         }
     }
 }
 void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         //timer is to avoid getting "hit" twice on the same collision
         if (timer >= 60)
         {
             hearts.takeDamage();
             Vector2 force = -collision.rigidbody.velocity.normalized * collisionForce;
             Debug.Log("Force is" + force);
             collision.rigidbody.AddForce(force * 500, ForceMode2D.Force);
             timer = 0;
         }
         else
         {
             return;
         }
     }
 }