protected IEnumerator UseEnumerator() { var wait = new WaitForSeconds(m_intervalTime); var controllerEvent = m_interUse.GetComponent <VRTK_ControllerEvents>(); if (controllerEvent != null) { while (true) { if (controllerEvent.touchpadTouched && m_detectValueChangeCoroutine == null) { m_detectValueChangeCoroutine = StartCoroutine(DetectValueChangeEnumerator()); } if (!controllerEvent.touchpadTouched && m_detectValueChangeCoroutine != null) { StopCoroutine(m_detectValueChangeCoroutine); m_detectValueChangeCoroutine = null; } if (m_interUse.IsUseButtonPressed() && !m_interObj.IsTouched()) { m_interObj.ForceStopInteracting(); //m_interUse.enabled = true; // m_interUse = null; break; } yield return(wait); } } }
public void ForceDropIfNeeded() { if (!ControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.GripPress)) { _vio.ForceStopInteracting(); } }
// Update is called once per frame void Update() { GameObject tape_model = GameObject.Find("tape_model"); if (tape_model.GetComponent <VRTK_InteractableObject>().IsGrabbed()) { tape_model.transform.localPosition = new Vector3(0.0f, -0.03535533f, 0.03535534f); tape_model.transform.localRotation = Quaternion.Euler(-45.0f, 0.0f, 0.0f); } // let the grabbed point be vertical to tape start_point.transform.localRotation = Quaternion.Euler(90.0f, 0.0f, 0.0f); VRTK_InteractableObject tape = GetComponent <VRTK_InteractableObject>(); // if(tape.IsGrabbed()) if (tape.IsUsing()) { string path = "[VRTK_SDKManager]/SDKSetups/SteamVR/[CameraRig]/Controller (left)/LeftController/VRTK_BasicHand/GrabAttachPoint"; // string path = "[VRTK_SDKManager]/SDKSetups/SteamVR/[CameraRig]/Controller (left)/LeftController/GrabAttachPoint"; start_point.position = GameObject.Find(path).transform.position; Vector3 vector_x = transform.right * -1; Vector3 current_vector = start_point.position - end_point.position; float angle = Vector3.Angle(vector_x, current_vector); if (angle > 30.0f) { Debug.Log("angle is out of range"); tape.ForceStopInteracting(); GameObject grabbed = GameObject.Find("grabbedBtn"); grabbed.transform.localPosition = init_pos; } } float curLength = getCurrentLength(); if (curLength >= target_tape_length) { scissor.SetActive(true); StaticData.setShowScissor(true); } else { scissor.SetActive(false); StaticData.setShowScissor(false); } lineRederer.SetPosition(0, start_point.position); lineRederer.SetPosition(1, end_point.position); }
private void FixedUpdate() { if (isGrabbed) { if (photonView.IsMine) { SetPositionAndRotation(); } else { interactableObject.ForceStopInteracting(); transform.rotation = Quaternion.identity; } } }
public void AttachObject(GameObject obj, Transform slot) { if (obj.GetComponent <Weapon_Magazine>() != null && !IsMagCompatible(obj.GetComponent <Weapon_Magazine>().magazineID)) { return; } VRTK_InteractableObject interactableObject = obj.GetComponent <VRTK_InteractableObject>(); if (interactableObject != null) { interactableObject.ForceStopInteracting(); } float insertTime = Time.time; float insertLength = Vector3.Distance(obj.transform.position, slot.position); ToggleObjectPhysics(obj.gameObject); StartCoroutine(MovetoPosition(obj.transform, slot, true, insertLength, insertTime)); AttachDetachController(obj, true); }
void Update() { if (OverMaxRangeAction == Action.ResetToEndPointOnUngrab && io.IsGrabbed()) { return; } if (OverMaxRangeAction == Action.ResetBothToStart) { if (Vector3.Distance(transform.position, startPos1) > MaxRange || Vector3.Distance(End.position, startPos2) > MaxRange) { if (reset) { SpawnWrongPartcile(); Unsnap(transform.parent); Unsnap(End.transform.parent); io.ForceStopInteracting(); io2.ForceStopInteracting(); transform.position = startPos1; End.transform.position = startPos2; transform.rotation = startRot1; End.transform.rotation = startRot2; if (StopVelocity) { GetComponent <Rigidbody>().velocity = Vector3.zero; End.gameObject.GetComponent <Rigidbody>().velocity = Vector3.zero; } } else if (!corutine) { StartCoroutine(StartReset()); } } } else if (Vector3.Distance(End.position, transform.position) > MaxRange) { if (reset) { io.ForceStopInteracting(); if (OverMaxRangeAction == Action.ResetBothToMiddle) { SpawnWrongPartcile(); Unsnap(transform.parent); Unsnap(End.transform.parent); io2.ForceStopInteracting(); var a = Vector3.Lerp(transform.position, End.position, 1f / 3); var b = Vector3.Lerp(transform.position, End.position, 2f / 3); transform.position = a; End.position = b; if (StopVelocity) { GetComponent <Rigidbody>().velocity = Vector3.zero; End.gameObject.GetComponent <Rigidbody>().velocity = Vector3.zero; } } else //Action.ResetToEndPointOnUngrab and Action.ResetToEndPoint { SpawnWrongPartcile(); Unsnap(transform.parent); transform.position = End.position; transform.rotation = End.rotation; if (StopVelocity) { GetComponent <Rigidbody>().velocity = Vector3.zero; } } } else if (!corutine) { StartCoroutine(StartReset()); } } }
public void UnGrab() { Interactions.ForceStopInteracting(); }