HillClimb/Assets/Scripts/Death.cs
2023-01-22 15:59:13 +05:30

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);
}
}