I'm trying to setup a system where I pickup an object drop it into a zone, and then the object is destroyed.

So far I have:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class TriggerZone2 : MonoBehaviour {
    public Text MyText;
    private int score;
    public bool CompareTag(string Player);

    // Use this for initialization
    void Start () {
        MyText.text = "";

    // Update is called once per frame
    void Update () {
        MyText.text = "$" + score;

    void OnTriggerEnter(Collider coll) {
        score = score + 1;

        if (other.CompareTag ("Player")) {
            Destroy (other.gameObject);

Everything works up until I try to destroy the game object. The console keeps saying

Assets/Scripts/TriggerZone2.cs(11,21): error CS0501: `TriggerZone2.CompareTag(string)' must have a body because it is not marked abstract, extern, or partial.

I've looked up quite a few threads, but I'm still not sure what it wants me to do with it. How do I fix this?

  • \$\begingroup\$ What is 'other'? As in the identifier; the word 'other' is used in OnTriggerEnter() but I don't see where that value is defined. \$\endgroup\$ – jhocking Aug 12 '15 at 20:56
  • \$\begingroup\$ @jhocking Going by this I thought that it would delete anything, BUT the things tagged within it. I'm new to C#, and rusty on Unity though. \$\endgroup\$ – Sie Aug 12 '15 at 20:58
  • \$\begingroup\$ Note that their example code defines 'other' as the parameter to the function. You called it 'coll'. \$\endgroup\$ – jhocking Aug 12 '15 at 21:00

That error is saying there's no CompareTag() method defined. That error points to line 11 in your script; note that CompareTag() is called on that line, but there is no CompareTag() defined in your script.

In this case, I don't think you wanted to write public bool CompareTag(string Player); I'm not sure what you're even trying to do there, but it looks unnecessary so just delete that entire line.

  • \$\begingroup\$ I figured it out. Basically my goal was to have it so that any object with a certain tag would be deleted, and add to the score. Thanks. \$\endgroup\$ – Sie Aug 12 '15 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.