private void FixedUpdate() { lastVelocity = (trackedHand.position - lastPos) / Time.fixedDeltaTime; lastPos = trackedHand.position; ReadDeviceInputs(); UpdateHovering(); UpdateIgnoreCollision(); if (input_grip > .5f && isEmpty && hovering && !lastgrip) { if (hovering.CanAttach(this, out _)) { Attach(hovering, hoveringHitPosition, hoveringHitRotation); } } lastgrip = input_grip > .5f; if (input_trigger > .5f && isEmpty && hovering && !lasttrigger) { if (hovering.CanInteract(this, out _)) { hovering.OnInteract(); } } bool isEmpty_tmp = isEmpty; foreach (var b in enableWhenEmpty) { if (b && b.enabled != isEmpty_tmp) { b.enabled = isEmpty_tmp; } } }
public void Debug_Attach() { if (debug_attach.CanAttach(this, out _)) { Attach(debug_attach, position, rotation); input_grip = 1; } }
public void Attach(XRInteractable interactable, Vector3 handAttachPositionWS, Quaternion handAttachRotationWS) { if (!interactable.CanAttach(this, out _)) { return; } DetachIfAny(); attached = interactable; foreach (var c in attached.GetComponentsInChildren <Collider>()) { IgnoreCollider(c); } interactable.OnAttach(this, handAttachPositionWS, handAttachRotationWS); SendHapticImpulse(hapticSettings.attachStrength, hapticSettings.attachDuration); }