mirror of
https://github.com/Steffo99/keep-everything-alive.git
synced 2024-11-25 10:44:18 +00:00
20 lines
444 B
C#
20 lines
444 B
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
public class DeleteIfTooClose : MonoBehaviour
|
|||
|
{
|
|||
|
private GameObject player;
|
|||
|
public float threshold = 1f;
|
|||
|
|
|||
|
void Awake() {
|
|||
|
player = GameObject.FindGameObjectWithTag("Player");
|
|||
|
}
|
|||
|
|
|||
|
void Start() {
|
|||
|
if(Vector2.Distance(transform.position, player.transform.position) <= threshold) {
|
|||
|
Destroy(gameObject);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|