PJ/Assets/scripts/Destroy.cs

17 lines
325 B
C#
Raw Normal View History

using UnityEngine;
public class Destroy : MonoBehaviour
{
public float Time;
public bool Touch;
void Awake(){Invoke("Dest", Time);}
void Dest(){Destroy(this.gameObject);}
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.tag == "Player" && Touch)
{
Dest();
}
}
}