void Update() { kinectData = KinectData.GetComponent <KinectController>(); Kinect.Body closestBody = GetClosestBody(); if (closestBody == null) { ResetCalibration(null, "body not found"); return; } ulong currentClosestTrackingId = closestBody.TrackingId; if (trackingId != currentClosestTrackingId) { ResetCalibration(currentClosestTrackingId, "body not found"); return; } Kinect.Body currentBody = kinectData.Bodies.Find(body => body.TrackingId == trackingId); if (calibrationTimer < calibrationTime) { shoulderAndHipRatio.AddData(GetShoulderAndHipRatio( GetBodyPosition(currentBody, Kinect.JointType.ShoulderLeft), GetBodyPosition(currentBody, Kinect.JointType.ShoulderRight), GetBodyPosition(currentBody, Kinect.JointType.HipLeft), GetBodyPosition(currentBody, Kinect.JointType.HipRight))); upperbodyLength.AddData(GetUpperbodyLength( GetBodyPosition(currentBody, Kinect.JointType.Head), GetBodyPosition(currentBody, Kinect.JointType.Neck), GetBodyPosition(currentBody, Kinect.JointType.SpineBase))); DisplayText.text = string.Format("Time: {2}\n\nSH: {0}\nUL: {1}", shoulderAndHipRatio.ToString(), upperbodyLength.ToString(), calibrationTimer.ToString("0.00")); calibrationTimer += Time.deltaTime; } else { if (Application.loadedLevelName == "MainMenu" || Application.loadedLevel == 0) { SetPlayerPrefs(trackingId.Value, shoulderAndHipRatio.Average, upperbodyLength.Average); Application.LoadLevel(1); // change this later } else { if (Match(shoulderAndHipRatio.Average, upperbodyLength.Average)) { Application.LoadLevel(Application.loadedLevel); } else { ResetCalibration(null, "not a match"); } } } }