So i have a row of cubes. I want to collide into them and when i do they get destroyed.
void OnTriggerEnter(Collider coll)
{
if(coll.gameObject.tag == "Buns")
{
incube = true;
}
}
void Update()
{
if (Input.GetKeyDown(Keycode.lol)&& incube == true)
{
//but how to distroy object? Destroy(gameObject); yea i know but how to tell what im colliding with at the moment. I dont wanna break every cube at once. Also they randomly spawn so dont say “Give each a number” or something lol
}
}
How to delete the object im colliding with when i push buttons