Question by
matt_sunley · Aug 30, 2015 at 01:45 PM ·
scripting problemerror
Error - An Object Reference is Required to Access Non-Static Member
Please halp me fix this..."GameController.AddScore()"
using UnityEngine; using System.Collections;
public class DestroyScript : MonoBehaviour{ public GameController gc; public GameObject Explosion;
void Start(){
gc = GameObject.FindGameObjectWithTag ("Player").GetComponent<GameController>();
}
void OnTriggerEnter (Collider Other)
{
if(Other.tag == "Player")
{
Instantiate (Explosion,transform.position, transform.rotation);
GameController.AddScore();
Destroy(gameObject);
}
}
}
Comment
Answer by noshipu · Aug 31, 2015 at 03:16 AM
Hello. I think that you should rewrite at 10 line.
gc.AddScore();
I recommend that you watch this tutorial video. http://unity3d.com/jp/learn/tutorials/modules/beginner/scripting/getcomponent
Your answer
Follow this Question
Related Questions
Object reference not set to an instance of an object (c#) 0 Answers
how to fix cs1014 error 1 Answer
Missing ',' when there is no need? 0 Answers
only using GetMouseButtonDown(0) once 0 Answers
I need help working out a C# script with error CS0120 1 Answer