/* * //Method aborted * private bool isGrabGesture(){ * GameObject thumb_2 = this.transform.GetChild (0).GetChild (2).gameObject; * GameObject indexfinger_2 = this.transform.GetChild (1).GetChild (2).gameObject; * float dist_thumb_index = Vector3.Distance(thumb_2.transform.position, indexfinger_2.transform.position); * if (dist_thumb_index < 0.065){ * return true; * } * return false; * } */ /* grabObject * Input: GameObject obj * Output: None * Summary: 1. Reset and inactivate rigidbody of current obj. Otherwise obj could "magically" move in your hand :) 2. Set obj to move with hand */ private void grabObject(GameObject obj) { obj.GetComponent <Collider> ().isTrigger = true; /*new feature: push*/ if (push_enabled) { if (coroutine != null) { StopCoroutine(coroutine); } palm.GetComponent <Collider> ().isTrigger = true; } obj.GetComponent <Rigidbody> ().useGravity = false; obj.GetComponent <Rigidbody> ().velocity = Vector3.zero; obj.GetComponent <Rigidbody> ().angularVelocity = Vector3.zero; obj.GetComponent <Rigidbody> ().Sleep(); // When grabbing, highlight it. GrabCollider grabCol = obj.GetComponentInChildren <GrabCollider>(); if (grabCol != null) { grabCol.OnBeingGrabbed(); } inverseGrabRotation = Quaternion.Inverse(grabHolder.transform.rotation); grabDeltaPosition = obj.transform.position - grabHolder.transform.position; //this was used to make obj a child //obj.transform.SetParent(grabHolder.transform); //trying this right now: //initialize MA array objBuffer = new Vector3[smoothingBuffer]; for (int i = 0; i < smoothingBuffer; i++) { objBuffer [i] = obj.transform.position; } this.updateObjTransform(obj); /* pulasation */ /* before invoke, check 2 things. if it is enabled, if there are existing ones */ /* FIX!!!*/ //InvokeRepeating ("VPulse", 1.0f, 1.0f); is_grabbing = true; }