private void checkLight(float time) { if (stopLight != null) { Stoplight stopScript = (Stoplight)stopLight.GetComponent("Stoplight"); if (stopScript.stop) { if (ProximityTester.proximityTest(stoplightProximityRange, this.transform.position, stopLight.transform.position)) { //car stops in place until light is go if (!hasLogged) { Debug.Log("stop"); } hasLogged = true; } else { checkCarCollision(time); } } else { checkCarCollision(time); } } else { checkCarCollision(time); } }
// Update is called once per frame void Update() { float time = Time.deltaTime; if (!willChange && playerCar != null) { if (ProximityTester.proximityTest(proximityRange, this.transform.position, playerCar.transform.position)) { willChange = true; } } if (willChange && numChanges < maxNumChanges) { if (totalTime > timeToChangeLight[numChanges]) { ChangeLight(); numChanges++; } totalTime += time; } }