Example #1
0
        private void ThrowReleasedObject(Rigidbody rb, float objectThrowMultiplier)
        {
            var origin = VRTK_DeviceFinder.TrackedObjectOrigin(gameObject);

            var velocity        = controllerEvents.GetVelocity();
            var angularVelocity = controllerEvents.GetAngularVelocity();

            if (origin != null)
            {
                rb.velocity        = origin.TransformDirection(velocity) * (throwMultiplier * objectThrowMultiplier);
                rb.angularVelocity = origin.TransformDirection(angularVelocity);
            }
            else
            {
                rb.velocity        = velocity * (throwMultiplier * objectThrowMultiplier);
                rb.angularVelocity = angularVelocity;
            }
        }
Example #2
0
        private void ThrowReleasedObject(Rigidbody rb, float objectThrowMultiplier)
        {
            var origin = VRTK_DeviceFinder.TrackedObjectOrigin(gameObject);

            var velocity        = controllerEvents.GetVelocity();
            var angularVelocity = controllerEvents.GetAngularVelocity();

            if (origin != null)
            {
                rb.velocity        = origin.TransformVector(velocity) * (throwMultiplier * objectThrowMultiplier);
                rb.angularVelocity = origin.TransformDirection(angularVelocity);
            }
            else
            {
                rb.velocity        = velocity * (throwMultiplier * objectThrowMultiplier);
                rb.angularVelocity = angularVelocity;
            }

            Vector3 collisionCenter = rb.GetComponent <Collider>().bounds.center;

            rb.velocity = rb.GetPointVelocity(collisionCenter + (collisionCenter - transform.position));
        }