- Home /
GameObject' does not contain a definition for `Find'
My code was working fine a few min ago but i had to restart my computer now unity is throwing errors where everything was working just fine and I am not sure what the problem is can anyone help. using UnityEngine; using System.Collections; public class CoinsScript : MonoBehaviour { public AudioClip coinSound; HudScript hud; void OnTriggerEnter2D(Collider2D other) { if(other.tag == "Player") { hud = GameObject.Find("Main Camera").GetComponent<HudScript>(); hud.IncreaseCoins(1); AudioSource.PlayClipAtPoint(coinSound,gameObject.transform.position); Destroy(this.gameObject); DontDestroyOnLoad(this.gameObject); } } }
Answer by Bunny83 · Mar 20, 2014 at 10:27 AM
The only possible reasons for this error is that you have created a class / script / variable and named it "GameObject". In MonoDevelop try "Search"-->"Find In Files" and search for
"class GameObject"
and / or
"struct GameObject"
or just
"GameObject"
and see if you can find something.
i did find class Gameobject in the revmob sdk script do i have to change that?
ok im so dumb i found the problem thank you so much i over looked it in one of my scripts i for got to change public class GameObject : $$anonymous$$onoBehaviour to the name of my script
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Changing Axis to Buttons 2 Answers
Syntax error: Instance required to access non static member 1 Answer
Script help please 1 Answer
Need help with WeaponSwitch Script 0 Answers