public void WheelColliderSet(GameObject parentCar)//调用定义的递归方法设置轮子碰撞器 根据父物体设置轮子模型网格面 { wheelColliders[0] = FindOBJ.findit(parentCar, "FL").GetComponent <WheelCollider>(); wheelColliders[1] = FindOBJ.findit(parentCar, "FR").GetComponent <WheelCollider>(); wheelColliders[2] = FindOBJ.findit(parentCar, "BL").GetComponent <WheelCollider>(); wheelColliders[3] = FindOBJ.findit(parentCar, "BR").GetComponent <WheelCollider>(); tireMesh[0] = FindOBJ.findit(parentCar, "fl_wheel").transform; tireMesh[1] = FindOBJ.findit(parentCar, "fr_wheel").transform; tireMesh[2] = FindOBJ.findit(parentCar, "rl_wheel").transform; tireMesh[3] = FindOBJ.findit(parentCar, "rr_wheel").transform; }
// Use this for initialization void Start() { Transform[] waypointTransform = waypoint.GetComponentsInChildren <Transform>(); nodes = new List <Transform>(); for (int i = 0; i < waypointTransform.Length; i++) { if (waypointTransform[i] != waypoint.transform) { nodes.Add(waypointTransform[i]); } } FL = FindOBJ.findit(TargetCar, "FL").GetComponent <WheelCollider>(); FR = FindOBJ.findit(TargetCar, "FR").GetComponent <WheelCollider>(); BL = FindOBJ.findit(TargetCar, "BL").GetComponent <WheelCollider>(); BR = FindOBJ.findit(TargetCar, "BR").GetComponent <WheelCollider>(); TireFR = FindOBJ.findit(TargetCar, "fr_wheel").GetComponent <Transform>(); TireFL = FindOBJ.findit(TargetCar, "fl_wheel").GetComponent <Transform>(); }