I know there are multiple posts asking this same question, but I have spent an hour trying to fix this and I cannot do it. By the way, I am terrible at coding so if you could write out explicitly what I need to do(or just the code) that would be great. This is my C# Script.
using UnityEngine;
using System.Collections;
public class Collision : MonoBehaviour {
void OnTriggerEnter(Collider other) {
Destroy(other.gameObject.tag=="BuyPottery");
}
}
I have an Empty GameObject containing multiple shapes that’s called BuyPottery, and I want it to disappear when the player collides with it. I keep getting the error:
Assets/Collision.cs(6,17): error CS1502: The best overloaded method match for 'UnityEngine.Object.Destroy(UnityEngine.Object)' has some invalid arguments.
I think the problem is in the
Destroy(other.gameObject.tag=="BuyPottery");
part of the code, because when I just copy and paste the code from [here][1]
it works fine, but as soon as I change the gameObject it stops working. I feel really stupid right now and any help would be appreciated.
EDIT: I am trying to add the script to an empty Game Object, but if that changes things I can just add it to the objects contained in the Empty.
[1]: Unity - Scripting API: Collider.OnTriggerEnter(Collider)