void FixedUpdate() { if (_reader != null) { var frame = _reader.AcquireLatestFrame(); if (frame != null) { IList <Body> _bodies = new Body[frame.BodyFrameSource.BodyCount]; frame.GetAndRefreshBodyData(_bodies); // Display only first active body for (int i = 0; i < frame.BodyFrameSource.BodyCount; i++) { if (_bodies[i] != null) { if (_bodies[i].IsTracked) { if (_bodies[i].HandLeftState == HandState.Closed) { leftHandClosed = true; leftHandStateText.text = "Closed"; } else //if (_bodies[i].HandLeftState == HandState.Open) { leftHandClosed = false; leftHandStateText.text = "Open"; } if (_bodies[i].HandRightState == HandState.Closed) { rightHandClosed = true; rightHandStateText.text = "Closed"; } else //if (_bodies[i].HandRightState == HandState.Open) { rightHandClosed = false; rightHandStateText.text = "Open"; } bodyDrawer.DrawSkeleton(_bodies[i].Joints); if (state == PractiseState.KinectChecking) { ConvertedBody convertedBody = exerciseService.Convert(_bodies[i], jsonExercise .ExerciseRecording .JointMappings); ProgressText.text = exerciseService.Progression(); ExerciseScore score = exerciseService.Check(convertedBody); if (exerciseService.State() == ExerciseValidator.ValidatorState.Checking) { // Check body and add score to list exerciseResultScores.Add(score); // Add body to list for recording exerciseResultRecording.Add(convertedBody); } if (exerciseService.State() == ExerciseValidator.ValidatorState.Done) { CompletedOverlay.SetActive(true); TimerText.text = ""; int endScore = 0; int total = 0; for (int j = 0; j < exerciseResultScores.Count; j++) { total += exerciseResultScores[j].Score; } endScore = (int)Math.Round(((float)total / (float)exerciseResultScores.Count) * 25); string exerciseResultRecordingCompressed = Convert.ToBase64String(Gzip.Compress(JsonConvert.SerializeObject(exerciseResultRecording))); JObject resultJson = new JObject( new JProperty("duration", 0), new JProperty("score", endScore), new JProperty("exercisePlanning_ID", hrs.currentPlanningId), new JProperty("result", exerciseResultRecordingCompressed)); ScoreText.text = baseScoreText + endScore + "%"; StartCoroutine( requestService.Post("/exerciseresult", resultJson.ToString(), success => { Debug.Log(success); }, error => { Debug.Log(error); } )); state = PractiseState.KinectDone; } } // Exit after first tracked body is found break; } } } // Disable untracked body for (int i = 0; i < frame.BodyFrameSource.BodyCount; i++) { if (!_bodies[i].IsTracked && bodyDrawer.Tracked) { //bodyDrawer.Untracked(); } } // Clear frame to get a new one frame.Dispose(); } } }