/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { // left and right hand in front of left and right shoulder Vector3 handLeft = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 shoulderCenter = skeleton.getRawWorldPosition(JointType.SpineShoulder); Vector3 handRight = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 elbowLeft = skeleton.getRawWorldPosition(JointType.ElbowLeft); Vector3 elbowRight = skeleton.getRawWorldPosition(JointType.ElbowRight); Vector3 shoulderRight = skeleton.getRawWorldPosition(JointType.ShoulderRight); Vector3 shoulderLeft = skeleton.getRawWorldPosition(JointType.ShoulderLeft); if (handLeft.x > shoulderLeft.x && handRight.x < shoulderRight.x) { // left and right hand below shoulder height but above hip height Vector3 head = skeleton.getRawWorldPosition(JointType.Head); Vector3 hipCenter = skeleton.getRawWorldPosition(JointType.SpineBase); Vector3 spineMid = skeleton.getRawWorldPosition(JointType.SpineMid); if ((handLeft.y < head.y && handLeft.y > spineMid.y) && (handRight.y < head.y && handRight.y > spineMid.y)) { Debug.Log("Segment1 Success"); return(GesturePartResult.Succeed); } return(GesturePartResult.Fail); } return(GesturePartResult.Fail); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { // right hand below right shoulder Vector3 handRight = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 shoulderCenter = skeleton.getRawWorldPosition(JointType.SpineShoulder); Vector3 elbowRight = skeleton.getRawWorldPosition(JointType.ElbowRight); if (handRight.y > shoulderCenter.y) { // right hand in front right elbow if (handRight.z > elbowRight.z) { // right elbow in front of right shouder Vector3 shoulderRight = skeleton.getRawWorldPosition(JointType.ShoulderRight); if (elbowRight.z > shoulderRight.z) { //Debug.Log("Segment2 Success"); return(GesturePartResult.Succeed); } return(GesturePartResult.Pausing); } return(GesturePartResult.Pausing); } return(GesturePartResult.Fail); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { // left hand stays above left elbow Vector3 handLeft = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 shoulderCenter = skeleton.getRawWorldPosition(JointType.SpineShoulder); Vector3 elbowLeft = skeleton.getRawWorldPosition(JointType.ElbowLeft); if (handLeft.y > elbowLeft.y) { // left hand in front of left elbow if (handLeft.z > elbowLeft.z) { // left elbow in front of left shoulder Vector3 shoulderLeft = skeleton.getRawWorldPosition(JointType.ShoulderLeft); if (elbowLeft.z > shoulderLeft.z) { //Debug.Log("Segment2 Success"); return(GesturePartResult.Succeed); } return(GesturePartResult.Pausing); } return(GesturePartResult.Pausing); } return(GesturePartResult.Fail); }
public void calcPositions() //call this before retrieving detectInformations { Vector3 spineShoulder = _moCapAvatar.getRawWorldPosition(JointType.SpineShoulder); _handRightRel = _moCapAvatar.getRawWorldPosition(JointType.HandRight) - spineShoulder; _handLeftRel = _moCapAvatar.getRawWorldPosition(JointType.HandLeft) - spineShoulder; _shoulderRightRotY = Mathf.Asin(_handRightRel.y / _handRightRel.magnitude) * 180 / Mathf.PI + _rotYOffset; //_shoulderRightRotZ = Mathf.Asin(_handRightRel.z / _handRightRel.magnitude) * 180 / Mathf.PI + _rotYOffset; _shoulderLeftRotY = Mathf.Asin(_handLeftRel.y / _handRightRel.magnitude) * 180 / Mathf.PI + _rotYOffset; //_shoulderLeftRotZ = Mathf.Asin(_handLeftRel.z / _handRightRel.magnitude) * 180 / Mathf.PI + _rotYOffset; if (_shoulderLeftRotY > 90) { _shoulderLeftRotY = 90; } if (_shoulderRightRotY > 90) { _shoulderRightRotY = 90; } Vector3 headBase = _moCapAvatar.getRawWorldPosition(JointType.SpineMid); Vector3 head = _moCapAvatar.getRawWorldPosition(JointType.Head); Vector3 headDir = head - headBase; _headRotY = Mathf.Asin(headDir.y / headDir.magnitude) * 180 / Mathf.PI; if (headDir.x > 0) { _headRotY = 180 - _headRotY; } }
public Vector2 getMappedRightHandPosition() { Vector3 spineShoulder = AvatarModel.getRawWorldPosition(JointType.SpineShoulder); Vector3 handRightRel = AvatarModel.getRawWorldPosition(JointType.HandRight) - spineShoulder; Vector3 handLeftRel = AvatarModel.getRawWorldPosition(JointType.HandLeft) - spineShoulder; Vector2 result; result.x = (handRightRel.x - 0.1f) / 0.6f; result.y = (handRightRel.y + 0.2f) / 0.4f; return(result); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { Vector3 handLeft = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 handRight = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 spineMid = skeleton.getRawWorldPosition(JointType.SpineBase); // left and right hand bewlow spineMid if (handLeft.y < spineMid.y && handRight.y < spineMid.y) { Debug.Log("Segment2 Success"); return(GesturePartResult.Succeed); } return(GesturePartResult.Pausing); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { // right hand in front of right shoulder Vector3 handLeft = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 shoulderCenter = skeleton.getRawWorldPosition(JointType.SpineShoulder); Vector3 handRight = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 elbowLeft = skeleton.getRawWorldPosition(JointType.ElbowLeft); Vector3 hip = skeleton.getRawWorldPosition(JointType.SpineBase); if (handLeft.z > elbowLeft.z && handRight.y < hip.y) { // right hand below shoulder height but above hip height Vector3 head = skeleton.getRawWorldPosition(JointType.Head); if (handLeft.y < head.y && handLeft.y > hip.y) { // right hand left of right shoulder & right of left shoulder Vector3 shoulderRight = skeleton.getRawWorldPosition(JointType.ShoulderRight); Vector3 shoulderLeft = skeleton.getRawWorldPosition(JointType.ShoulderLeft); if (handLeft.x > shoulderLeft.x && handLeft.x < shoulderRight.x) { //Debug.Log("SwipeRight2 Success"); return(GesturePartResult.Succeed); } return(GesturePartResult.Pausing); } return(GesturePartResult.Fail); } return(GesturePartResult.Fail); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { Vector3 handLeft = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 handRight = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 head = skeleton.getRawWorldPosition(JointType.Head); // left and right hand above head if (handLeft.y >= head.y && handRight.y >= head.y) { //Debug.Log("Segment1 Success"); return(GesturePartResult.Succeed); } return(GesturePartResult.Pausing); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 rightHand = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 hip = skeleton.getRawWorldPosition(JointType.SpineBase); //position detection if (rightHand.y <= hip.y) { //Debug.Log("Cirlce seg3"); return(GesturePartResult.Succeed); //ggf. add hand.z betw. shoulders } return(GesturePartResult.Pausing); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 elbowRight = skeleton.getRawWorldPosition(JointType.ElbowRight); Vector3 shoulderRight = skeleton.getRawWorldPosition(JointType.ShoulderRight); //position detection if (elbowRight.z <= shoulderRight.z) { return(GesturePartResult.Succeed); Debug.Log("PushFwrd seg1"); } return(GesturePartResult.Fail); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 leftHand = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 rightHand = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 hip = skeleton.getRawWorldPosition(JointType.SpineBase); //position detection if (leftHand.y < hip.y && rightHand.y < hip.y) { //Debug.Log("PullUp seg1"); return(GesturePartResult.Succeed); } return(GesturePartResult.Pausing); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 rightHand = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 leftShoulder = skeleton.getRawWorldPosition(JointType.ShoulderLeft); Vector3 head = skeleton.getRawWorldPosition(JointType.Head); Vector3 hip = skeleton.getRawWorldPosition(JointType.SpineBase); if (rightHand.y < head.y && rightHand.y > hip.y) { if (rightHand.x < leftShoulder.x) { //Debug.Log("Circle seg4"); return(GesturePartResult.Succeed); } } return(GesturePartResult.Pausing); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 leftFoot = skeleton.getRawWorldPosition(JointType.FootLeft); Vector3 rightAnkel = skeleton.getRawWorldPosition(JointType.AnkleRight); Vector3 leftShoulder = skeleton.getRawWorldPosition(JointType.ShoulderLeft); Vector3 rightShoulder = skeleton.getRawWorldPosition(JointType.ShoulderRight); //position detection if (leftShoulder.z < rightShoulder.z) { if (leftFoot.y < rightAnkel.y) { //Debug.Log("TurnLeft seg2"); return(GesturePartResult.Succeed); } } return(GesturePartResult.Pausing); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 leftHand = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 rightHand = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 leftShoulder = skeleton.getRawWorldPosition(JointType.ShoulderLeft); Vector3 rightShoulder = skeleton.getRawWorldPosition(JointType.ShoulderRight); Vector3 shoulderMid = skeleton.getRawWorldPosition(JointType.SpineShoulder); //position detection if (leftHand.y <= shoulderMid.y && rightHand.y <= shoulderMid.y) { if (leftHand.x < leftShoulder.x && rightHand.x > rightShoulder.x) { Debug.Log("Cross seg2"); return(GesturePartResult.Succeed); } } return(GesturePartResult.Pausing); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 leftHand = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 rightHand = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 leftElbow = skeleton.getRawWorldPosition(JointType.ElbowLeft); Vector3 rightElbow = skeleton.getRawWorldPosition(JointType.ElbowRight); //position detection if (leftHand.y < leftElbow.y && rightHand.y < rightElbow.y) { //Debug.Log("HandL: "+leftHand.z+" ShoulderR: "+ rightShoulder.z); if (leftHand.x > rightElbow.x && rightHand.x < leftElbow.x) { Debug.Log("Cross seg1"); return(GesturePartResult.Succeed); } } return(GesturePartResult.Pausing); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 leftHand = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 rightHand = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 hip = skeleton.getRawWorldPosition(JointType.SpineBase); Vector3 leftShoulder = skeleton.getRawWorldPosition(JointType.ShoulderLeft); Vector3 rightShoulder = skeleton.getRawWorldPosition(JointType.ShoulderRight); if (leftHand.x <= leftShoulder.x && rightHand.x >= rightShoulder.x) { if (leftHand.y < hip.y && rightHand.y < hip.y) { //Debug.Log("PunchDown succeed"); return(GesturePartResult.Succeed); } return(GesturePartResult.Pausing); } return(GesturePartResult.Fail); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { // hand above elbow Vector3 handLeft = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 elbowLeft = skeleton.getRawWorldPosition(JointType.ElbowLeft); if (handLeft.y > elbowLeft.y) { // hand left of elbow if (handLeft.x < elbowLeft.x) { return(GesturePartResult.Succeed); } // hand has not dropped but is not quite where we expect it to be, pausing till next frame return(GesturePartResult.Pausing); } // hand dropped - no gesture fails return(GesturePartResult.Fail); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { // right hand in front of right shoulder Vector3 handLeft = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 shoulderCenter = skeleton.getRawWorldPosition(JointType.SpineShoulder); Vector3 handRight = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 elbowRight = skeleton.getRawWorldPosition(JointType.ElbowRight); if (handRight.z > elbowRight.z && handLeft.y < shoulderCenter.y) { // right hand below shoulder height but above hip height Vector3 head = skeleton.getRawWorldPosition(JointType.Head); Vector3 shoulderRight = skeleton.getRawWorldPosition(JointType.ShoulderRight); if (handRight.y < head.y && handRight.y >= shoulderCenter.y - 0.2f) { // right hand right of right shoulder if (handRight.x - 0.4f > shoulderRight.x) { //Debug.Log("Segment1 Success"); return(GesturePartResult.Succeed); } return(GesturePartResult.Pausing); } return(GesturePartResult.Fail); } return(GesturePartResult.Fail); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { // left hand under shoulder and right hand in front of body Vector3 handLeft = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 shoulderCenter = skeleton.getRawWorldPosition(JointType.SpineShoulder); Vector3 handRight = skeleton.getRawWorldPosition(JointType.HandRight); if (handLeft.y < shoulderCenter.y && handRight.z > shoulderCenter.z) { // right hand above hip center and below head and left of right elbow and right of hip center Vector3 head = skeleton.getRawWorldPosition(JointType.Head); Vector3 elbowRight = skeleton.getRawWorldPosition(JointType.ElbowRight); Vector3 hipCenter = skeleton.getRawWorldPosition(JointType.SpineBase); if (handRight.y < head.y && handRight.y > hipCenter.y && handRight.x < elbowRight.x && handRight.x > hipCenter.x) { return(GesturePartResult.Succeed); } return(GesturePartResult.Pausing); } return(GesturePartResult.Fail); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 leftHand = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 rightHand = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 shoulder = skeleton.getRawWorldPosition(JointType.SpineShoulder); Vector3 leftShoulder = skeleton.getRawWorldPosition(JointType.ShoulderLeft); Vector3 rightShoulder = skeleton.getRawWorldPosition(JointType.ShoulderRight); //position detection if (leftHand.x <= leftShoulder.x && rightHand.x >= rightShoulder.x) { if (leftHand.y > shoulder.y && rightHand.y > shoulder.y) { //Debug.Log("PunchDown seg1"); return(GesturePartResult.Succeed); } } return(GesturePartResult.Fail); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 elbowRight = skeleton.getRawWorldPosition(JointType.ElbowRight); Vector3 shoulderRight = skeleton.getRawWorldPosition(JointType.ShoulderRight); Vector3 handRight = skeleton.getRawWorldPosition(JointType.HandRight); if (elbowRight.z > shoulderRight.z) { if (handRight.y <= shoulderRight.y) { return(GesturePartResult.Succeed); Debug.Log("PushFwrd succeed"); } return(GesturePartResult.Pausing); Debug.Log("PushFwrd pausing"); } return(GesturePartResult.Fail); Debug.Log("PushFwrd failed"); }
public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { // right hand between spinemid and head Vector3 rightHand = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 spineMid = skeleton.getRawWorldPosition(JointType.SpineMid); Vector3 head = skeleton.getRawWorldPosition(JointType.Head); if (rightHand.y > spineMid.y && rightHand.y < head.y) { //right hand left from spine if (rightHand.x < spineMid.x) { //right elbow under spinemid Vector3 rightElbow = skeleton.getRawWorldPosition(JointType.ElbowRight); if (rightElbow.y < spineMid.y) { return(GesturePartResult.Succeed); } return(GesturePartResult.Pausing); } return(GesturePartResult.Fail); } return(GesturePartResult.Fail); }
// Update is called once per frame void Update() { // Bit shift the index of the layer (8) to get a bit mask int layerMask = 1 << 8; // This would cast rays only against colliders in layer 8. // But instead we want to collide against everything except layer 8. The ~ operator does this, it inverts a bitmask. layerMask = ~layerMask; RaycastHit hit; if (Physics.Raycast(skeleton.getRawWorldPosition(JointType.ElbowRight), skeleton.getRawWorldPosition(JointType.HandRight) - skeleton.getRawWorldPosition(JointType.ElbowRight), out hit, Mathf.Infinity, layerMask)) { Debug.DrawRay(skeleton.getRawWorldPosition(JointType.ElbowRight), (skeleton.getRawWorldPosition(JointType.HandRight) - skeleton.getRawWorldPosition(JointType.ElbowRight)) * hit.distance, Color.yellow); Debug.Log("Did Hit"); } else { Debug.DrawRay(skeleton.getRawWorldPosition(JointType.ElbowRight), (skeleton.getRawWorldPosition(JointType.HandRight) - skeleton.getRawWorldPosition(JointType.ElbowRight)) * 1000, Color.white); Debug.Log("Did not Hit"); } }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 leftHand = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 rightHand = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 leftShoulder = skeleton.getRawWorldPosition(JointType.ShoulderLeft); Vector3 rightShoulder = skeleton.getRawWorldPosition(JointType.ShoulderRight); Vector3 shoulder = skeleton.getRawWorldPosition(JointType.SpineShoulder); Vector3 hip = skeleton.getRawWorldPosition(JointType.SpineBase); //position detection if (leftHand.y < shoulder.y && rightHand.y < shoulder.y && leftHand.y > hip.y && rightHand.y > hip.y) { //Debug.Log("HandL: "+leftHand.z+" ShoulderR: "+ rightShoulder.z); if (leftHand.x > leftShoulder.x && rightHand.x < rightShoulder.x && leftHand.x < rightShoulder.x && rightHand.x > leftShoulder.x) { //Debug.Log("Clap seg1"); return(GesturePartResult.Succeed); } } return(GesturePartResult.Pausing); }
void Control() { bool isBackMarkerTracked = trackingManager.IsBackMarkerTracked(); bool isFrontmarkerTracked = trackingManager.IsFrontMarkerTracked(); if (Input.GetKeyDown(KeyCode.UpArrow)) { micAmplify += 100; PlayerPrefs.SetFloat("Amplify", micAmplify); } if (Input.GetKeyDown(KeyCode.DownArrow)) { micAmplify -= 100; PlayerPrefs.SetFloat("Amplify", micAmplify); } if (Input.GetKeyDown(KeyCode.LeftArrow)) { wakeUpLevel -= 1; PlayerPrefs.SetFloat("Threshold", wakeUpLevel); } if (Input.GetKeyDown(KeyCode.RightArrow)) { wakeUpLevel += 1; PlayerPrefs.SetFloat("Threshold", wakeUpLevel); } if (Input.GetKeyDown(KeyCode.Tab)) { debugEnabled = !debugEnabled; } if (Input.GetKeyDown(KeyCode.Space)) { micLevel = wakeUpLevel + 1; } if (Input.GetKeyDown(KeyCode.KeypadPlus)) { manager.speed += 0.5f; } if (Input.GetKeyDown(KeyCode.KeypadMinus)) { manager.speed -= 0.5f; } //Debug.Log("" + isFrontmarkerTracked + " " + isBackMarkerTracked); //Set useFixedSkeleton in UnityChanController if backMarker is tracked if (isBackMarkerTracked) { chanController.useFixedSkeleton = true; } else { chanController.useFixedSkeleton = false; } // Throw if (Input.GetKeyDown(KeyCode.T)) { StartCoroutine(Throw()); } if (isFrontmarkerTracked) { if (throwingLeft) { StartCoroutine(Throw(false)); throwingLeft = false; } if (throwingRight) { StartCoroutine(Throw(true)); throwingRight = false; } } else { throwingLeft = false; throwingRight = false; } // Write isWriting = false; if (!blocked) { material.color = Color.white; } if (isBackMarkerTracked) { if (!blocked) { //At least one hand needs to be above shoulder to count as writing Vector3 handRight = AvatarModel.getRawWorldPosition(JointType.HandRight); Vector3 handLeft = AvatarModel.getRawWorldPosition(JointType.HandLeft); Vector3 shoulderCenter = AvatarModel.getRawWorldPosition(JointType.HandRight); if (handRight.y > shoulderCenter.y || handLeft.y > shoulderCenter.y) { isWriting = true; Manager.AddScore(1 * Time.deltaTime); material.color = Color.green; } else { //Always count as writing while looking towards blackboard. Use this together with fixed character skeleton isWriting = true; Manager.AddScore(1 * Time.deltaTime); Manager.IncreaseMultiplier(Time.deltaTime); material.color = Color.green; } } } if (Input.GetKey(KeyCode.W)) { if (!blocked) { isWriting = true; Manager.AddScore(1 * Time.deltaTime); Manager.IncreaseMultiplier(Time.deltaTime); material.color = Color.green; } } if (isWriting) { chalkboard.volume = 1; } else { chalkboard.volume = 0; } }