void Update() { int state = 0; if (BodySourceManager == null) { Debug.Log("Is BodyManager null" + BodySourceManager); return; } _BodyManager = BodySourceManager.GetComponent <BodySourceManager>(); if (_BodyManager == null) { return; } Kinect.Body[] data = _BodyManager.GetData(); if (data == null) { return; } List <ulong> trackedIds = new List <ulong>(); foreach (var body in data) { if (body == null) { continue; } if (body.IsTracked) { trackedIds.Add(body.TrackingId); } } List <ulong> knownIds = new List <ulong>(_Bodies.Keys); // First delete untracked bodies foreach (ulong trackingId in knownIds) { if (!trackedIds.Contains(trackingId)) { Destroy(_Bodies[trackingId]); _Bodies.Remove(trackingId); } } foreach (var body in data) { if (body == null) { continue; } if (body.IsTracked) { if (!_Bodies.ContainsKey(body.TrackingId)) { _Bodies[body.TrackingId] = CreateBodyObject(body.TrackingId); } //RefreshBodyObject(body, _Bodies[body.TrackingId]); //Check Hand State if body is being Tracked state = CheckLeftHandState(body.HandLeftState) + (2 * CheckRightHandState(body.HandRightState)); if (!levelHasGenerated) { return; } switch (state) { case 0: signalStart = false; break; case 1: //Left if (prevState == 0) { platformRotate.TurnLeft(); } Debug.Log("Left"); break; case 2: //Right Debug.Log("Right"); if (prevState == 0) { platformRotate.TurnRight(); } break; case 3: //Both Debug.Log("Both"); if (prevState == 0) { // playerScript.flipjump = true; platformRotate.Flip(); } break; default: break; } /* * CheckRightHandState(body.HandRightState); * CheckLeftHandState(body.HandLeftState); * * if(rightHandActive && leftHandActive) * { * //flip * Debug.LogError("BOTH"); * } */ } } }
void Update() { int state = 0; if (BodyManager == null) { return; } if (Input.GetKeyDown(KeyCode.J)) { //Left platformRotate.TurnLeft(); } if (Input.GetKeyDown(KeyCode.L)) { //Right platformRotate.TurnRight(); } if (Input.GetKeyDown(KeyCode.I)) { //Flip platformRotate.Flip(); } //if (playerScript.flipjump) //{ // // .. increment a timer to count up to restarting. // flipTimer += Time.deltaTime; // if (flipTimer >= flipDelay) // { // playerScript.flipjump = false; // } //} //if (playerScript.flipjump) // playerScript.flipjump = false; _BodyManager = BodyManager.GetComponent <BodyManager>(); if (_BodyManager == null) { return; } Kinect.Body[] data = _BodyManager.GetData(); if (data == null) { return; } List <ulong> trackedIds = new List <ulong>(); foreach (var body in data) { if (body == null) { continue; } if (body.IsTracked) { trackedIds.Add(body.TrackingId); Debug.Log("Found Body"); } } List <ulong> knownIds = new List <ulong>(_Bodies.Keys); // First delete untracked bodies foreach (ulong trackingId in knownIds) { if (!trackedIds.Contains(trackingId)) { Destroy(_Bodies[trackingId]); _Bodies.Remove(trackingId); } } foreach (var body in data) { if (body == null) { continue; } if (body.IsTracked) { //Check Hand State if body is being Tracked state = CheckLeftHandState(body.HandLeftState) + (2 * CheckRightHandState(body.HandRightState)); Debug.Log("state: " + state); switch (state) { case 0: signalStart = false; break; case 1: //Left Debug.Log("Left"); if (prevState == 0) { platformRotate.TurnLeft(); } break; case 2: //Right Debug.Log("Right"); signalStart = true; if (prevState == 0) { platformRotate.TurnRight(); } break; case 3: //Both Debug.Log("Both"); if (prevState == 0) { // playerScript.flipjump = true; platformRotate.Flip(); } break; default: break; } prevState = state; } } }