// Add a reward to the car if it´s the currect checkpoint, otherwise give the car a punishment void OnCollisionEnter(Collision collision) { CarReward car = collision.gameObject.GetComponentInParent <CarReward>(); if (!car) { return; } if (s_NextCheckpoint < 0 || m_CheckpointIndex < 0 || s_NextCheckpoint == m_CheckpointIndex) { // Correct checkpoint car.AddReward(m_Reward); } else { // Incorrect checkpoint car.AddReward(m_Punishment); } }
void OnTriggerEnter(Collider other) { CarReward car = other.gameObject.GetComponentInParent <CarReward>(); if (car) { if (!m_KillCar) { car.AddReward(m_Punishment); } else { car.Kill = true; } } }
// Give the car a punishment if it's not set to kill the car void OnCollisionStay(Collision collisionInfo) { CarReward car = collisionInfo.gameObject.GetComponentInParent <CarReward>(); if (car) { if (!m_KillCar) { car.AddReward(m_Punishment); } else { car.Kill = true; } } }