public void ReleaseBall() { if (!isThrown) //get the throw distance from the initial hand position and the position after grabbing { CapsuleHand capsuleHand = m_Hand.GetComponentInChildren <CapsuleHand> (); if (capsuleHand) { m_HandModel = capsuleHand.GetLeapHand(); endPos = m_HandModel.PalmPosition.ToVector3(); Rigidbody rb = GetComponent <Rigidbody> (); Vector3 displacement = initPos - endPos; Vector3 throwDirection = displacement.normalized; //This is very finally the throw happenes if (displacement.sqrMagnitude > minDispThrow) // give the thrown ball falling speed with gravity { isThrown = true; rb.velocity = throwDirection * displacement.magnitude * m_SpeedScale; rb.useGravity = true; } else { transform.position = ballInitPos; } } isDragged = false; } }
// Update is called once per frame void Update() { if (!isThrown) //check whether it is the throw action or drag action { if (isDragged) { CapsuleHand capsuleHand = m_Hand.GetComponentInChildren <CapsuleHand> (); if (capsuleHand) { m_HandModel = capsuleHand.GetLeapHand(); transform.position += (m_HandModel.PalmPosition.ToVector3() - initPalmPos); initPalmPos = m_HandModel.PalmPosition.ToVector3(); } } } else { if (collided) //if the time to wait to reset the ball { m_TimeAfterCollision += Time.deltaTime; if (m_TimeAfterCollision >= m_TimeToWait) { m_MiniGameController.ResetBall(); } } } }
//public IEnumerator Pause() //{ // print(Time.time); // if (Time.time >= pauseTime) // { // state = AnimaState.Pause; // anim.speed = 0; // yield break; // } // else // { // yield return new WaitForSeconds(3f); // if (Time.time >= pauseTime) // { // state = AnimaState.Pause; // anim.speed = 0; // yield break; // } // } //} public void CheckState(GameObject go, string handName) { if (handName == "LeftHand") { nowHand = leftHand; } else if (handName == "RightHand") { nowHand = rightHand; } if (nowHand.GetGesure() == HandType.Catch) { if (go == targetArray[index]) { GoOn(); print("Go on 0.3s"); } //else //{ // StartCoroutine(Pause()); //} } //else //{ // StartCoroutine(Pause()); //} }
//private Transform objectToMove; // The object we will move. //private Vector3 offSet; // The object's position relative to the mouse position. //private float dist; void Start() { GameObject prefabLineToRender = Resources.Load("Line") as GameObject; GameObject lineToRender = Instantiate(prefabLineToRender, new Vector3(0, 0, 0), Quaternion.identity) as GameObject; myLineRenderer = lineToRender.GetComponent <LineRenderer> (); rightHandScript = rightHandObject.GetComponent <CapsuleHand> (); //GameObject prefabNode = Resources.Load ("Node") as GameObject; }
public static void UpdateTarget(this CapsuleHand hand) { if (hand.target != null) { hand.target.rotation = hand.palm.rotation; //why? hand.target.Rotate(new Vector3(0, 1, 0), -60); } }
public static GestureType getGesture(this CapsuleHand hand) { if (hand != null) { return(GestureJudge.Instance.checkAGesture(hand._jointSpheres, hand.palm)); } else { return(GestureType.None); } }
public bool HaveCath(CapsuleHand hand) { if (hand == leftHand) { return(left); } else { return(right); } }
public static HandType GetGesure(this CapsuleHand hand) { if (hand != null) { return(GesureRecognition.Instance.CheckGesure(hand._jointSpheres, hand.palm)); } else { return(GesureRecognition.Instance.CheckGesure(null, null)); } }
public void GrabBall(GameObject hand) { m_Hand = hand; if (!isThrown) //get the hand initial position if it is not the throw action { CapsuleHand capsuleHand = m_Hand.GetComponentInChildren <CapsuleHand> (); m_HandModel = capsuleHand.GetLeapHand(); initPos = m_HandModel.PalmPosition.ToVector3(); initPalmPos = m_HandModel.PalmPosition.ToVector3(); isDragged = true; } }
void Start() { target = gameObject.GetComponent <CapsuleHand>(); if (target.Handedness == Chirality.Left) { ReplayManager.instance.left_hand = this; } else { ReplayManager.instance.right_hand = this; } }
public static void SetReceptor(this CapsuleHand hand, Transform target, int type) { if (type == 1) { target.parent = hand._jointSpheres[11]; } else if (type == 2) { target.parent = hand.palmPositionSphere; hand.target = target; } }
void OnTriggerStay(Collider other) { // Debug.Log ("collison enter"); if (other.gameObject.tag == SeeionDataCtrl.LeftHand || other.gameObject.tag == SeeionDataCtrl.RightHand) { // Debug.Log ("hand catch : " + other.tag); this._funcHand = this._hCtrl.getHandByName(other.tag); if (this._funcHand != null) { // Debug.Log("hand is get"); //if player prepare to catch it if (this._hCtrl.getGestureType(this._funcHand) == GestureType.Catch) { // Debug.Log (this._hCtrl.getGestureType (this._funcHand)); //if player didnt catch anything if (!this._hCtrl.isHandCatch(this._funcHand)) { this._isInCatch = true; //set hand was catching something this._hCtrl.toggleHandIsCatch(this._funcHand); this._funcHand.setHandReceiver(this.transform); //why?? this.transform.localPosition = new Vector3(-1.16f, 0, -0.57f); this._rig.velocity = Vector3.zero; this._rig.angularVelocity = Vector3.zero; this._rig.isKinematic = true; this._rig.useGravity = false; } } else if (this._hCtrl.getGestureType(this._funcHand) == GestureType.Open) { //open gesture this._isInCatch = false; this._bCtrl.restoreBrickItem(); this._hCtrl.toggleHandIsCatch(this._funcHand); this._funcHand.target = null; this._funcHand = null; transform.parent = this._parentTrans; // HandManager._instance.right = false; this._rig.isKinematic = false; // this._rig.useGravity = true; } } } }
public virtual void OnTriggerStay(Collider other) { //modify by tezika if (other.tag == "RightHand") { if (HandManager._instance.GetHandType(other.tag) == HandType.Catch) { if (!HandManager._instance.HaveCath(other.tag)) { hand = HandManager._instance.GetHand(other.tag); HandManager._instance.right = true; if (tag == "Test tube rack") { hand.SetReceptor(transform, 1); } else { hand.SetReceptor(transform, 2); transform.localPosition = new Vector3(-1.16f, 0, -0.57f); } rigid.velocity = Vector3.zero; rigid.angularVelocity = Vector3.zero; rigid.isKinematic = true; rigid.useGravity = false; //offset = transform.localPosition; } } else { if (hand == HandManager._instance.GetHand(other.tag)) { hand.target = null; hand = null; transform.parent = parent; HandManager._instance.right = false; rigid.isKinematic = false; // rigid.useGravity = true; } } } }
public GestureType getGestureType(CapsuleHand hand) { return(this._hand2GestureMap [hand]); }
public bool isHandCatch(CapsuleHand hand) { return(this._hand2isCatchMap [hand]); }
public void toggleHandIsCatch(CapsuleHand hand) { this._hand2isCatchMap [hand] = !this._hand2isCatchMap [hand]; }
public static void setHandReceiver(this CapsuleHand hand, Transform target) { target.parent = hand.palmPositionSphere; hand.target = target; }
// Start is called before the first frame update void Start() { hand = GetComponent <CapsuleHand>(); attachedObject = Instantiate(AttachedObjectPrefab, transform); }
// Update is called once per frame void Update() { if (handLeft == null) { leftHandModel = GameObject.FindGameObjectWithTag("LeftHandInteraction"); if (leftHandModel != null) { if ((capsuleHandLeft = leftHandModel.GetComponent <CapsuleHand>()) != null) { handLeft = capsuleHandLeft.GetLeapHand(); if (handLeft.IsRight) { handRight = handLeft; handLeft = null; } if (handRight == handLeft) { handLeft = null; } } } } if (handRight == null) { rightHandModel = GameObject.FindGameObjectWithTag("RightHandInteraction"); if (rightHandModel != null) { if ((capsuleHandRight = rightHandModel.GetComponent <CapsuleHand>()) != null) { handRight = capsuleHandRight.GetLeapHand(); if (handRight.IsLeft) { handLeft = handRight; handRight = null; } if (handRight == handLeft) { handRight = null; } } } } // movement and rotation if (handLeft != null && handRight != null) { CheckMovementRotation(); DoMovementRotation(); } // allow game space extension by right hand fist gesture if (allowGameSpaceExtension && GameObject.FindGameObjectWithTag("RightHandInteraction") == null) { isFistThumbUp = false; handRight = null; } else if (gameSpaceExtension != null && handRight != null) { isFistThumbUp = CheckFistThumbUp(handRight); } if (gameSpaceExtension != null) { Debug.Log("LeapMovement: isFist = " + isFistThumbUp + " allowGameSpaceExtension=" + allowGameSpaceExtension); if (isFistThumbUp && !allowGameSpaceExtension) { gameSpaceExtension.SetAllowGameSpaceExtension(true); allowGameSpaceExtension = true; } if (!isFistThumbUp && allowGameSpaceExtension) { gameSpaceExtension.SetAllowGameSpaceExtension(false); allowGameSpaceExtension = false; } } }