private void AttemptGrabObject() { var objectToGrab = GetGrabbableObject(); if (objectToGrab != null) { IncrementGrabState(); var initialGrabAttempt = false; if (objectToGrab.GetComponent <VRTK_InteractableObject>().AttachIsTrackObject()) { initialGrabAttempt = GrabTrackedObject(); } else { initialGrabAttempt = GrabInteractedObject(); } if (grabbedObject && initialGrabAttempt) { VRTK_InteractableObject grabbedInteractableObject = grabbedObject.GetComponent <VRTK_InteractableObject>(); var rumbleAmount = grabbedInteractableObject.rumbleOnGrab; if (!rumbleAmount.Equals(Vector2.zero)) { controllerActions.TriggerHapticPulse((ushort)rumbleAmount.y, rumbleAmount.x, 0.05f); } if (hasAnimations) { if (grabbedInteractableObject.grabLarge) { animator.GrabLarge(); } else if (grabbedInteractableObject.grabSmall) { animator.GrabSmall(); } else if (grabbedInteractableObject.grabStickUp) { animator.GrabStickUp(); } else if (grabbedInteractableObject.grabStickFront) { animator.GrabStickFront(); } else { animator.Grab(); } } } } else { grabPrecognitionTimer = grabPrecognition; if (createRigidBodyWhenNotTouching) { interactTouch.ToggleControllerRigidBody(true); } } }
private void AttemptGrabObject() { if (IsValidGrab()) { if (interactTouch.GetTouchedObject().GetComponent <VRTK_InteractableObject>().AttachIsTrackObject()) { GrabTrackedObject(); } else { GrabInteractedObject(); } if (!IsObjectHoldOnGrab(interactTouch.GetTouchedObject())) { grabEnabledState++; } } else { grabPrecognitionTimer = grabPrecognition; if (createRigidBodyWhenNotTouching) { interactTouch.ToggleControllerRigidBody(true); } } }
private void Update() { if (controllerAttachPoint == null) { SetControllerAttachPoint(); } if (createRigidBodyWhenNotTouching && grabbedObject == null) { if (!interactTouch.IsRigidBodyForcedActive() && interactTouch.IsRigidBodyActive() != controllerEvents.grabPressed) { interactTouch.ToggleControllerRigidBody(controllerEvents.grabPressed); } } if (grabPrecognitionTimer >= Time.time) { if (GetGrabbableObject() != null) { AttemptGrabObject(); if (GetGrabbedObject() != null) { grabPrecognitionTimer = 0f; } } } }
protected virtual void ToggleRigidbody(Collider collider, bool state) { if (isEnabled || !state) { if (activateTrackedCollider) { VRTK_ControllerTrackedCollider trackedCollider = collider.GetComponentInParent <VRTK_ControllerTrackedCollider>(); if (trackedCollider != null) { trackedCollider.ToggleColliders(state); EmitEvent(state, trackedCollider.interactTouch); } } if (activateInteractTouch) { VRTK_InteractTouch touch = collider.GetComponentInParent <VRTK_InteractTouch>(); if (touch != null) { touch.ToggleControllerRigidBody(state, state); EmitEvent(state, touch); } } } }
private void Update() { // 如果连接点还没有值,设置连接点 if (controllerAttachPoint == null) { SetControllerAttachPoint(); } // 如果勾选了createRigidBodyWhenNotTouching,当手柄按下抓取按钮时没有碰到一个可交互的物体,那么为手柄添加一个刚体组件,让手柄可以推开其他刚体对象. if (createRigidBodyWhenNotTouching && grabbedObject == null) { // 如果抓取按钮是按下的,而手柄刚体组件的isKinematic为true,或者抓取按钮没有按下,但是手柄刚体组件的isKinematic为false if (interactTouch.IsRigidBodyActive() != controllerEvents.grabPressed) { // 抓取按钮按下时,设手柄刚体组件的isKinematic为false,抓取按钮没有按下时,设手柄刚体组件的isKinematic为true interactTouch.ToggleControllerRigidBody(controllerEvents.grabPressed); } } // 即使没有按下按钮,也可以尝试抓取物体 if (grabPrecognitionTimer >= Time.time) { if (GetGrabbableObject() != null) { AttemptGrabObject(); if (GetGrabbedObject() != null) { grabPrecognitionTimer = 0f; } } } }
protected virtual void CreateNonTouchingRigidbody() { if (createRigidBodyWhenNotTouching && grabbedObject == null && interactTouch != null) { if (!interactTouch.IsRigidBodyForcedActive() && interactTouch.IsRigidBodyActive() != grabPressed) { interactTouch.ToggleControllerRigidBody(grabPressed); } } }
// Token: 0x060010EF RID: 4335 RVA: 0x00063A7C File Offset: 0x00061C7C protected virtual void ToggleRigidbody(Collider collider, bool state) { VRTK_InteractTouch componentInParent = collider.GetComponentInParent <VRTK_InteractTouch>(); if (componentInParent != null && (this.isEnabled || !state)) { componentInParent.ToggleControllerRigidBody(state, state); this.EmitEvent(state, componentInParent); } }
private void CreateNonTouchingRigidbody() { if (createRigidBodyWhenNotTouching && grabbedObject == null) { if (!interactTouch.IsRigidBodyForcedActive() && interactTouch.IsRigidBodyActive() != controllerEvents.grabPressed) { interactTouch.ToggleControllerRigidBody(controllerEvents.grabPressed); } } }
protected virtual void ToggleRigidbody(Collider collider, bool state) { VRTK_InteractTouch touch = collider.GetComponentInParent <VRTK_InteractTouch>(); if (touch != null && (isEnabled || !state)) { touch.ToggleControllerRigidBody(state, state); EmitEvent(state, touch); } }
private void AttemptGrabObject() { if (IsValidGrab()) { if (interactTouch.GetTouchedObject().GetComponent <VRTK_InteractableObject>().AttachIsTrackObject()) { GrabTrackedObject(); } else { GrabInteractedObject(); } if (!IsObjectHoldOnGrab(interactTouch.GetTouchedObject())) { grabEnabledState++; } if (grabbedObject) { var rumbleAmount = grabbedObject.GetComponent <VRTK_InteractableObject>().rumbleOnGrab; if (!rumbleAmount.Equals(Vector2.zero)) { controllerActions.TriggerHapticPulse((ushort)rumbleAmount.y, (int)rumbleAmount.x, 0.05f); } } } else { grabPrecognitionTimer = grabPrecognition; if (createRigidBodyWhenNotTouching) { interactTouch.ToggleControllerRigidBody(true); } } }