30 lines
682 B
C#
30 lines
682 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Death : MonoBehaviour
|
|
{
|
|
public Vector3 headOffset;
|
|
public float headRadius;
|
|
|
|
|
|
void Update()
|
|
{
|
|
Collider2D[] overlaps = Physics2D.OverlapCircleAll(transform.position + headOffset, headRadius);
|
|
foreach(Collider2D overlap in overlaps){
|
|
if(overlap!=null){
|
|
if(overlap.tag == "Ground"){
|
|
Debug.Log("Die!");
|
|
GameManager.GameOver();
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
void OnDrawGizmos(){
|
|
Gizmos.DrawWireSphere(transform.position+ headOffset, headRadius);
|
|
}
|
|
}
|