private void UpdateVelocity() { Pose pose = _targetGrabber.GetPose(); Vector3 velocity = (pose.position - _prevPos) / Time.deltaTime; if (velocity == Vector3.zero) { return; } _velocityDataIndex = Time.frameCount % _velocityData.Length; _velocityData[_velocityDataIndex] = velocity; _prevPos = pose.position; }
public void Begin(IGrabber grabber) { _targetGrabber = grabber; Pose pose = _targetGrabber.GetPose(); _prevPos = pose.position; _isThrowing = false; _lastVelocity = Vector3.zero; _offsetPos = transform.position - pose.position; _offsetRot = Quaternion.Inverse(pose.rotation) * transform.rotation; _grabberRotInv = Quaternion.Inverse(pose.rotation); if (_hasRigidbody) { _rigidbody.isKinematic = true; } }