void PoliceCarMode_Change() { if (distance >= 10 && distance <= 30) { Debug.Log("Mode Changing"); currentCarMode = policeCarMode.aggressive; Invoke("PoliceCarMode_PreviousMode", 2.0f); } }
void OnEnable() { PoliceCarinstantiation_Back(); int randomValue_Mode = Random.Range(0, 8); thisTrans = transform; isDoubleSpeed = 1; playercarScript = GameObject.FindGameObjectWithTag("Player").GetComponent <playerCarControl> (); currentCarState = carStates.OnRoad; currentCarMode = policeCarMode.avoid; BlueLight_Enable(); InvokeRepeating("PoliceCarMode_Change", 10f, 20f); policeCarSound.volume = 0.3f; }
void OnCollisionEnter(Collision incomingCollision) { string incTag = incomingCollision.collider.tag; if (incTag.Contains("trafficCar") || incTag.Contains("policeCar") || incTag.Contains("Player")) { carSpeed = 0; wheelSpeed = 0; isDoubleSpeed = 0; turnSpeed = 0; GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll; GameObject trafficCar = incomingCollision.collider.gameObject; trafficCar.SendMessage("StopCar", SendMessageOptions.DontRequireReceiver); //to stop the car //iTween.RotateTo (trafficCar,new Vector3(0,0,0), 1.0f); Destroy(gameObject, 3f); policeCarSound.volume = 0; currentCarState = carStates.idle; currentCarMode = policeCarMode.idle; } }
void PoliceCarMode_PreviousMode() { currentCarMode = policeCarMode.avoid; }