Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

The name 'gameObject' does not exist in the current context

I can’t understand why my script is not working..I don’t get why this is wrong..this is my script code below.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class k : MonoBehaviour
{
void OnTriggerEnter(Collider collider)
    {
        if(collider.gameObject.name == "holms")
        {
            GameVariables.keyCount+=2;
            Destroy(gameobject);
        }
    }
}

I was searching the internet to find similar issue and I find similar threads but not similar to this. It different from the other post here or in google search.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You mis-typed Destroy(gameObject)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading