Quantcast
Channel: Questions in topic: "crash"
Viewing all articles
Browse latest Browse all 2383

Unity crash, kinect calibration

$
0
0
Hi, I am trying to create a script to use kinect to measure the user's arm lenght. As kinect's values fluctuate a lot when doing that, in my script I was making 150 measures and then calculating an average value - that would be admited as his real arm lenght throughout the rest of the code. (Just so you know, the calibration is supposed to start when you put your left hand in your hip - and you should have your right arm completely extended sideways) The problem is that, as soon as I play the game, Unity crashes... Don't really get why... ----------------------------------------------------------------------------- var calibrate : boolean = true; var calibrationValuesNumber : int = 150; var calculate : boolean = false; var valueSum : float = 0.0f; //lenght of the users arm during calibration var rightArmLenghtAprox : float; //lenght of the users arm after calibration var rightArmLenght : float; //distance between the user's left hand and his hip var leftDistanceToHip : float; function Start () { calibrationFunction(); } function calibrationFunction() { while (calibrate == true) { leftDistanceToHip = Vector3.Distance(leftHand.transform.position, leftHip.transform.position); //This means that a user was detected and the skeleton has "expanded" and the distance between the body parts is no longer 0 if (calculate == false && leftDistanceToHip > 0.23) { calculate = true; Debug.Log("calculating..."); } if (calculate == true && leftDistanceToHip <= 0.23) { Debug.Log("calibrating... stay still"); for (var i : int = 1; i <= calibrationValuesNumber; i++) { rightArmLenghtAprox = Vector3.Distance(rightHand.transform.position, rightElbow.transform.position) + Vector3.Distance(rightElbow.transform.position, rightShoulder.transform.position); valueSum = valueSum + rightArmLenghtAprox; if (i == calibrationValuesNumber) { rightArmLenght = valueSum / calibrationValuesNumber; calibrate = false; Debug.Log("Average is: " + rightArmLenght.ToString()); } } } } } ----------------------------------------------------- Thanks in advance

Viewing all articles
Browse latest Browse all 2383

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>