//when an object collides with something, this is called private void OnCollisionEnter(Collision collision) { //checking the 'layer' that the object we collided with is on if (collision.collider.gameObject.layer == 10) { die.Die(); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag("Player") && !collision.gameObject.GetComponent <PlayerDie>().isDead) { PlayerDie player = collision.gameObject.GetComponent <PlayerDie>(); player.Die(); } }
void CheckWillPlayerBeKilled() { // canKillPlayer = Physics2D.OverlapBox(bottomCheck.position, bottomCubeSize, 0, playerLayer); if (canKillPlayer && !player.isDead) { Debug.Log("Should KillPlayer"); player.Die(); } }
private IEnumerator DrowningAnimation() { while (transform.position.y > -2) { transform.position += Vector3.down * Time.deltaTime * 4; yield return(null); } player.Die(); }
private IEnumerator CrashingAnimation() { while (!squeezeAnimation.HasAnimationCompleted) { squeezeAnimation.Animate(minScale, animationSpeed); yield return(null); } yield return(new WaitForSeconds(.25f)); player.Die(); }
private void OnTriggerStay2D(Collider2D collision) { if (collision.gameObject.CompareTag("Player") && !collision.gameObject.GetComponent <PlayerDie>().isDead) { if (timeTillExplosion <= 0) { // Debug.Log("OnTriggerSTAycircle"); PlayerDie player = collision.gameObject.GetComponent <PlayerDie>(); player.Die(); } } }