I don’t understand this, i have this script which works fine, and i’ve added a timesClocked; int which counts how many times the player used clock, everytime CountDown coroutine is activated , it should add +1 to the timesClocked, but its staying at 0?
here’s the script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SlowDownTime : MonoBehaviour {
public static float slowTimeScale = 0.3f;
public static float normalTimeScale = 1f;
public static float timeOut = 2f;
private int timesClocked;
// Use this for initialization
void Start ()
{
timesClocked = 0;
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "Player") {
other.GetComponent<Player_Controller> ().StartCoroutine (CountDown ());
Destroy (gameObject);
}
}
public static IEnumerator CountDown()
{
Time.timeScale = slowTimeScale;
yield return new WaitForSeconds (timeOut);
Time.timeScale = normalTimeScale;
timesClocked = timesClocked + 1;
}
}
it’s also giving me this reference error
Assets/Scripts/SlowDownTime.cs(40,3): error CS0120: An object reference is required to access non-static member `SlowDownTime.timesClocked’