using System.Collections; using System.Collections.Generic; using UnityEngine; public class LawCheck : MonoBehaviour { [HideInInspector] public float maxSpeed ; private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player" || other.gameObject.tag == "Car") { maxSpeed = DriveManager.Instance.OverSpeedMaxValue; Car car = null; car = other.GetComponent(); if (car == null) return; if (car.overSpeed >= maxSpeed-5) { DriveManager.Instance.SetCarSoundTip(car); Debug.Log(car.CarIDCard); LawCheckList.Instance.AddCarID(car.CarIDCard,"-超速"); } Debug.Log("违章检测·"); } } private void OnTriggerExit(Collider other) { if (other.gameObject.tag == "Player" || other.gameObject.tag == "Car") { maxSpeed = DriveManager.Instance.OverSpeedMaxValue; Car car = null; car = other.GetComponent(); if (car == null) return; if (car.overSpeed >= maxSpeed) { DriveManager.Instance.SetCarSoundTip(car); Debug.Log(car.CarIDCard); LawCheckList.Instance.AddCarID(car.CarIDCard,"-超速"); } } } }