void Start() { activeGrabObject = null; gameObject.AddComponent <Rigidbody>(); gameObject.GetComponent <Rigidbody>().isKinematic = true; gameObject.GetComponent <Rigidbody>().useGravity = false; }
public void release(custom_TrackedObject controller) { activeGrabObject = null; activeMove = false; gameObject.GetComponent <Rigidbody>().isKinematic = false; gameObject.GetComponent <Rigidbody>().useGravity = true; //gameObject.GetComponent<Rigidbody>().AddForce(gameObject.GetComponent<VelocityEstimator>().GetVelocityEstimate()); }
public void grab(custom_TrackedObject controller) { activeGrabObject = controller; if (activeGrabObject == null) { activeMove = false; } else { initialRotation = Quaternion.Inverse(activeGrabObject.currRotation) * gameObject.transform.rotation; Vector3 tmpVec = gameObject.transform.position - activeGrabObject.currPosition; inititalOffset.Set( Vector3.Dot(activeGrabObject.currUpVec, tmpVec), Vector3.Dot(activeGrabObject.currRightVec, tmpVec), Vector3.Dot(activeGrabObject.currForwardVec, tmpVec) ); activeMove = true; gameObject.GetComponent <Rigidbody>().isKinematic = true; gameObject.GetComponent <Rigidbody>().useGravity = false; } }