using System.Collections; using System.Collections.Generic; using UnityEngine; public class DistanceChecker : MonoBehaviour { //是否无障碍 public bool noObstacle = true; public bool IsNoObstacle() { return noObstacle; } private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Car") { //Drive drive = other.GetComponent(); //if (drive!= null&&drive.dirveState==DriveState.Turn) //{ // noObstacle = true; // return; //} noObstacle = false; } } private void OnTriggerExit(Collider other) { if (other.gameObject.tag == "Car") { noObstacle = true; } } }