Ok here are my scripts. I’m using C#, as you can tell.
I keep getting the error message "an object reference is required to access non-static member. Also a couple of others which I wasn’t getting before even thought I was doing the exact same thing.
Ok, here’s the script attached to the text:
usingUnityEngine;
usingSystem.Collections;
usingUnityEngine.UI;
publicclasstimer : MonoBehaviour {
publicfloatstartingTime;
TexttheText;
publicautoplayer;
voidStart () {
theText = GetComponent ();
}
publicvoidUpdate()
{
startingTime -= Time.deltaTime;
if (startingTime <= 0.0f)
{
}
theText.text = “” + Mathf.Round (startingTime);
}
publicvoidAddTime (inttimeToAdd)
{
startingTime += timeToAdd;
}
}
and here’s the script attached to the object I want to make the time increase when the player makes contact with it:
usingUnityEngine;
usingSystem.Collections;
publicclassdeathcore : MonoBehaviour {
publicinttimeToAdd;
//publicautogameController;
//publictimertimer;
voidOnTriggerEnter(Colliderother)
{
if (other.tag == “Player”)
timer.AddTime (timeToAdd);
Destroy (gameObject);
}
}
Any help would be much appreciated. Almost have a finished game but this is the last thing I need to do. Thanks.
By the way, obviously there are spaces after the publics etc just didn’t register when I pasted for some reason.