void OnCollisionEnter(Collision collision) { Vector3 force = (Vector3.forward + Vector3.up + Random.insideUnitSphere).normalized * Random.Range(100, 150); collision.rigidbody.AddForce(force, ForceMode.Impulse); CylindricalTower_Car car = collision.gameObject.GetComponent <CylindricalTower_Car>(); if (car != null) { car.speed = 1; } }
public void DestroyCar(CylindricalTower_Car car) { GameObject.Destroy(car.gameObject); Instantiate(cars[Random.Range(0, cars.Length)]); }