diff --git a/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/Vehicle.cs b/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/Vehicle.cs index 1463ff3ce7..b624d5eaee 100644 --- a/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/Vehicle.cs +++ b/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/Vehicle.cs @@ -343,10 +343,25 @@ private void InitializeVehicle() { captureResetEvent = new AutoResetEvent(false); } + private GameObject FindChildWithTag(GameObject parent, string tag) { + GameObject child = null; + + foreach(Transform transform in parent.transform) { + if(transform.CompareTag(tag)) { + child = transform.gameObject; + break; + } + } + + return child; + } + //Register all the capture cameras in the scene for recording and data capture. //Make sure every camera is a child of a gameobject with tag "CaptureCameras" private void SetUpCameras() { - GameObject camerasParent = GameObject.FindGameObjectWithTag("CaptureCameras"); + GameObject this_vehicle = GameObject.Find(this.name); + GameObject camerasParent = FindChildWithTag(this_vehicle, "CaptureCameras"); + if (!camerasParent) { Debug.LogWarning("No Cameras found in the scene to capture data"); return;