private void CheckForInteractionObject() { Collider[] overlappedColliders = Physics.OverlapSphere(snapColliderOrigin.position, snapColliderOrigin.lossyScale.x / 2f); // 1 foreach (Collider overlappedCollider in overlappedColliders) // 2 { if (overlappedCollider.CompareTag("InteractionObject") && overlappedCollider.GetComponent <RWVR_InteractionObject>().IsFree()) // 3 { objectBeingInteractedWith = overlappedCollider.GetComponent <RWVR_InteractionObject>(); // 4 objectBeingInteractedWith.OnTriggerWasPressed(this); // 5 return; // 6 } } }
public void ShootArrow() { GameObject arrow = Instantiate(realArrowPrefab, transform.position, transform.rotation); float distance = Vector3.Distance(transform.position, attachedArrow.position); arrow.GetComponent <Rigidbody>().velocity = arrow.transform.forward * distance * maxShootSpeed * velocity; AudioSource.PlayClipAtPoint(fireSound, transform.position); RWVR_InteractionObject rwvrobj = GetComponent <RWVR_InteractionObject>(); //Debug.Log(rwvrobj.currentController.ToString()); rwvrobj.currentController.Vibrate(3500); arrow.GetComponent <RealArrow>().Launch(); arrow.transform.GetComponentInChildren <ParticleSystem>().gameObject.SetActive(true); Disarm(); }
void Update() { if (Controller.GetHairTriggerDown()) { CheckForInteractionObject(); } if (Controller.GetHairTrigger()) { if (objectBeingInteractedWith) { objectBeingInteractedWith.OnTriggerIsBeingPressed(this); } } if (Controller.GetHairTriggerUp()) { if (objectBeingInteractedWith) { objectBeingInteractedWith.OnTriggerWasReleased(this); objectBeingInteractedWith = null; } } }
void Update() { if (Controller.GetPressUp(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad)) { CheckForInteractionObject(); } if (Controller.GetPress(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad)) { if (objectBeingInteractedWith) { objectBeingInteractedWith.OnTriggerIsBeingPressed(this); } } if (Controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad)) { if (objectBeingInteractedWith) { objectBeingInteractedWith.OnTriggerWasReleased(this); objectBeingInteractedWith = null; } } }
public void SwitchInteractionObjectTo(RWVR_InteractionObject interactionObject) // 2 { objectBeingInteractedWith = interactionObject; // 3 objectBeingInteractedWith.OnTriggerWasPressed(this); // 4 }
void Update() { if (Controller.GetHairTriggerDown()) { CheckForInteractionObject(); } if (Controller.GetHairTrigger()) { if (objectBeingInteractedWith) { objectBeingInteractedWith.OnTriggerIsBeingPressed(this); } } if (Controller.GetHairTriggerUp()) { if (objectBeingInteractedWith) { objectBeingInteractedWith.OnTriggerWasReleased(this); objectBeingInteractedWith = null; } } //跳转显微镜场景 if (GameManager._Instance.isCanToMicroscope) { if (Controller.GetPressDown(SteamVR_Controller.ButtonMask.Axis0)) { MyTween myTween = new MyTween(); myTween.OnHalfComplete(() => { GameManager._Instance.isCanToMicroscope = false; GameManager._Instance.currentScenceID = ScenceID.Microscope; SceneManager.LoadScene("Microscope"); }); GameManager._Instance.PlayEffect(1); ScreenFade.Instance.SceneFade(myTween); } } //跳转实验室场景 if (GameManager._Instance.isCanTo2019) { if (Controller.GetPressDown(SteamVR_Controller.ButtonMask.Axis0)) { MyTween myTween = new MyTween(); myTween.OnHalfComplete(() => { GameManager._Instance.isCanTo2019 = false; GameManager._Instance.currentScenceID = ScenceID.Mian; SceneManager.LoadScene("2019"); }); GameManager._Instance.PlayEffect(1); ScreenFade.Instance.SceneFade(myTween); } } if (GameManager._Instance.isMicroscope) { if (Controller.GetPressDown(SteamVR_Controller.ButtonMask.Axis0)) { GameManager._Instance.isMicroscope = false; Microscope_Manager._Instance.Play(); } } }