void OnTriggerEnter(Collider other) { if (otherCar == null) { otherCar = other.transform.GetComponent <CarRaceController>(); } }
void OnTriggerExit(Collider other) { if (otherCar != null) { if (otherCar == other.transform.GetComponent <CarRaceController>()) { otherCar = null; } } }
void OnTriggerEnter(Collider other) { CarRaceController car = other.GetComponent <CarRaceController>(); if (car == null) { car = other.transform.parent.GetComponent <CarRaceController>(); } if (car != null) { Debug.Log("It went through"); gameManager.RespawnCar(car); } }
void OnTriggerEnter(Collider other) { CarRaceController car = other.GetComponent <CarRaceController>(); if (car == null) { car = other.transform.parent.GetComponent <CarRaceController>(); } if (car != null && car.position == 1) { Debug.Log("FinishLine crossed"); gameManager.FinishLineCrossed(); gameObject.SetActive(false); } }
public void RespawnCar(CarRaceController carToRespawn) { Debug.Log("Car is Respawning"); carToRespawn.gameObject.transform.position = carRespawner.transform.position + carRespawner.transform.up * 2; if (carRespawner.reverse) { carToRespawn.gameObject.transform.rotation = carRespawner.transform.rotation * Quaternion.Euler(0, 180, 0); } else { carToRespawn.gameObject.transform.rotation = carRespawner.transform.rotation; carToRespawn.GetComponent <Rigidbody>().velocity = Vector3.zero; } carToRespawn.transform.FindChild("NodeToFollow").GetComponent <FollowPathV2>().currentSpline = carRespawner.currentSpline; carToRespawn.transform.FindChild("NodeToFollow").GetComponent <FollowPathV2>().reverse = carRespawner.reverse; }
void OnTriggerEnter(Collider other) { CarRaceController car = other.GetComponent <CarRaceController>(); if (car == null) { car = other.transform.parent.GetComponent <CarRaceController>(); } if (car != null && car.position == 1 && other.gameObject.name != "NodeToFollow") { if (Vector3.Dot(transform.forward, other.transform.forward) < 0) { Debug.Log("It went through"); gameManager.LapCounter(); gameObject.SetActive(false); } } }