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; } }
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)); }