/// <summary> /// The PointerActive method determines if the ui pointer beam should be active based on whether the pointer alias is being held and whether the Hold Button To Use parameter is checked. /// </summary> /// <returns>Returns `true` if the ui pointer should be currently active.</returns> public virtual bool PointerActive() { if (activationMode == ActivationMethods.AlwaysOn || autoActivatingCanvas != null) { return(true); } else if (activationMode == ActivationMethods.HoldButton) { return(IsActivationButtonPressed()); } else { pointerClicked = false; if (IsActivationButtonPressed() && !lastPointerPressState) { pointerClicked = true; } lastPointerPressState = (controllerEvents != null ? controllerEvents.IsButtonPressed(activationButton) : false); if (pointerClicked) { beamEnabledState = !beamEnabledState; } return(beamEnabledState); } }
private void DoTouchpadAxisChanged(object sender, ControllerInteractionEventArgs e) { controllerEvents = (VRTK_ControllerEvents)sender; if (moveOnButtonPress != VRTK_ControllerEvents.ButtonAlias.Undefined && !controllerEvents.IsButtonPressed(moveOnButtonPress)) { touchAxis = Vector2.zero; controllerEvents = null; return; } var axis = e.touchpadAxis; var norm = axis.normalized; var mag = axis.magnitude; if (axis.y < verticalDeadzone && axis.y > -verticalDeadzone) { axis.y = 0; } else { axis.y = (norm * ((mag - verticalDeadzone) / (1 - verticalDeadzone))).y; } if (axis.x < horizontalDeadzone && axis.x > -horizontalDeadzone) { axis.x = 0; } else { axis.x = (norm * ((mag - horizontalDeadzone) / (1 - horizontalDeadzone))).x; } touchAxis = axis; }
private void DoTouchpadAxisChanged(object sender, ControllerInteractionEventArgs e) { controllerEvents = (VRTK_ControllerEvents)sender; if (moveOnButtonPress != VRTK_ControllerEvents.ButtonAlias.Undefined && !controllerEvents.IsButtonPressed(moveOnButtonPress)) { touchAxis = Vector2.zero; controllerEvents = null; return; } touchAxis = e.touchpadAxis; }
// Update is called once per frame void Update() { VRTK.VRTK_ControllerEvents l_hand = lHand.GetComponent <VRTK.VRTK_ControllerEvents>(); VRTK.VRTK_ControllerEvents r_hand = rHand.GetComponent <VRTK.VRTK_ControllerEvents>(); bool l_buttonOne = l_hand.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.ButtonOnePress); bool r_buttonOne = r_hand.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.ButtonOnePress); if (l_buttonOne || r_buttonOne) { Debug.Log("pressed"); SceneManager.LoadScene("Rail Scene", LoadSceneMode.Additive); } }
// Update is called once per frame void Update() { if (movingUp > 3) { movingUp = 1; } VRTK.VRTK_ControllerEvents l_hand = lHand.GetComponent <VRTK.VRTK_ControllerEvents>(); VRTK.VRTK_ControllerEvents r_hand = rHand.GetComponent <VRTK.VRTK_ControllerEvents>(); bool l_buttonOne = l_hand.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.ButtonOnePress); bool r_buttonOne = r_hand.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.ButtonOnePress); if ((Input.GetKey("a") || l_buttonOne || r_buttonOne) && (enable < 0.1)) { if (movingUp < 0) { movingUp = 2.1f; } else { movingUp += 2.1f; enable = 1; } } enable -= Time.deltaTime; movingUp -= Time.deltaTime; if (movingUp > 0.0) { if (transform.position.y < 6) { transform.position += Vector3.up * upSpeed * Time.deltaTime; } else { movingUp = 0; enable = 3; } } else { if (transform.position.y > -5.5f) { movingUp = 0; transform.position -= Vector3.up * Time.deltaTime; } } }
/* * void Start() * { * Debug.Log("Start"); * }*/ // Update is called once per frame void Update() { if (controllerEvents.IsButtonPressed(toggleButton)) { Debug.Log("pressed."); if (enable) { myLight.enabled = !myLight.enabled; } enable = false; } else { enable = true; } }
// Update is called once per frame void Update() { VRTK.VRTK_ControllerEvents l_hand = lHand.GetComponent <VRTK.VRTK_ControllerEvents>(); VRTK.VRTK_ControllerEvents r_hand = rHand.GetComponent <VRTK.VRTK_ControllerEvents>(); bool triggerA = l_hand.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.TriggerPress); bool triggerB = r_hand.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.TriggerPress); if (triggerA && triggerB) { velocity += (-2 * Time.deltaTime); } if (player.GetComponent <gameStat>().inPlay) { transform.Translate(Vector3.forward * velocity * Time.deltaTime); } }
// Update is called once per frame void Update() { VRTK.VRTK_ControllerEvents l_hand = lHand.GetComponent <VRTK.VRTK_ControllerEvents>(); if (!inPlay) { bool l_buttonOne = l_hand.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.ButtonOnePress); if (l_buttonOne) { stage.transform.position = new Vector3(0.44f, 0, -28.743f); player.transform.position = new Vector3(0.44f, 0, -22.5f); for (int i = 0; i < titans.Count; i++) { titans[i].SetActive(true); } stage.GetComponent <rail>().velocity = -10; inPlay = true; } } }
// Update is called once per frame void Update() { VRTK.VRTK_ControllerEvents l_hand = lHand.GetComponent <VRTK.VRTK_ControllerEvents>(); VRTK.VRTK_ControllerEvents r_hand = rHand.GetComponent <VRTK.VRTK_ControllerEvents>(); bool l_buttonTwo = l_hand.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.ButtonTwoPress); bool r_buttonTwo = r_hand.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.ButtonTwoPress); if (l_buttonTwo) { if (transform.position.x >= -2.5) { transform.position -= new Vector3(dodge_factor, 0, 0); } } if (r_buttonTwo) { if (transform.position.x <= 2.5) { transform.position += new Vector3(dodge_factor, 0, 0); } } }
void UpdateEventListener() { bool curActiveBtnPress = controller.IsButtonPressed(activationButton); if (OnPointerActive != null && (curActiveBtnPress != lastActiveBtnPress)) { OnPointerActive(curActiveBtnPress); } lastActiveBtnPress = curActiveBtnPress; bool curSelectBtnPress = controller.IsButtonPressed(selectionButton); if (OnPointerSelect != null && (curSelectBtnPress != lastSelectBtnPress)) { OnPointerSelect(curSelectBtnPress); } lastSelectBtnPress = curSelectBtnPress; }
protected virtual void Update() { multiplyMovement = (controllerEvents && movementMultiplierButton != VRTK_ControllerEvents.ButtonAlias.Undefined && controllerEvents.IsButtonPressed(movementMultiplierButton)); CheckControllerState(controllerLeftHand, leftController, ref leftSubscribed, ref previousLeftControllerState); CheckControllerState(controllerRightHand, rightController, ref rightSubscribed, ref previousRightControllerState); }
private void Update() { multiplySpeed = (controllerEvents && speedMultiplierButton != VRTK_ControllerEvents.ButtonAlias.Undefined && controllerEvents.IsButtonPressed(speedMultiplierButton)); }
private bool ValidPrimaryButton() { return(controllerEvents && (primaryActivationButton == VRTK_ControllerEvents.ButtonAlias.Undefined || controllerEvents.IsButtonPressed(primaryActivationButton))); }
void Update() { // calcul de la progression du fondu au noir float oldProgression = blackoutProgression; if (viewmasterObject.IsGrabbed()) { float distance = 999; foreach (Transform anchorPoint in viewmasterObjectAnchors) { distance = Mathf.Min(distance, Vector3.Distance(anchorPoint.position, Camera.main.transform.position)); } float range = maxDistance - minDistance; blackoutProgression = (distance - minDistance) / range; } else { blackoutProgression += Time.deltaTime; } blackoutProgression = Mathf.Clamp(blackoutProgression, 0, 1); Color matCol = blackoutMesh.material.color; matCol.a = 1 - blackoutProgression * .9f; blackoutMesh.material.color = matCol; renderCam.enabled = blackoutProgression <= 1; if (blackoutProgression < 1 && oldProgression >= 1) { // calcul de la position de l'image en fonction de la tête du joueur portraitOrientation.localPosition = renderCam.transform.localPosition + new Vector3(0, -.1f, 0); portraitOrientation.localRotation = Quaternion.Euler( portraitOrientation.localEulerAngles.x, renderCam.transform.localEulerAngles.y, portraitOrientation.localEulerAngles.z); // désactivation TP teleportHandler.enabled = false; } else if (blackoutProgression >= 1 && oldProgression < 1) { teleportHandler.enabled = true; } // calcul de la progression du fondu de l'image if (blackoutProgression <= 0) { canvasProgression += Time.deltaTime; } else { canvasProgression -= Time.deltaTime * 7; } canvasProgression = Mathf.Clamp(canvasProgression, 0, 1); portraitsGroup.alpha = canvasProgression; if (blackoutProgression <= 0) { float angleBetweenPictures = 30; if (currentClip != null) { angleBetweenPictures = 180f / currentClip.images.Length; } // float angleBetweenPictures = 30; // à n'utiliser que si l'autre n'est pas assez intuitif GameObject grabbingObj = viewmasterObject.GetGrabbingObject(); if (grabbingObj != null) { VRTK.VRTK_ControllerEvents eventCtrl = grabbingObj.GetComponent <VRTK.VRTK_ControllerEvents>(); lastControllerActions = grabbingObj.GetComponent <VRTK.VRTK_ControllerActions>(); if (eventCtrl != null) { // on est en train de visionner l'image, on récupère la manette en train de tenir le VM afin de récupérer les swipes sur le pavé tactile eventCtrl.axisFidelity = 5; bool wasPressing = pressingButton; pressingButton = eventCtrl.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.Touchpad_Touch); if (pressingButton && !wasPressing) { lastRotation = eventCtrl.GetTouchpadAxisAngle(); } float trigger = eventCtrl.GetTriggerAxis(); if (trigger != 1) { ignoreTrigger = false; } if (trigger == 1 && !ignoreTrigger) { ignoreTrigger = true; autoMoveToNextPicture = true; StartCoroutine(TriggerHapticCoroutine()); } if (pressingButton && trigger == 0 && false) { float oldPortraitRotation = currentPortraitRotation; // en train de faire un swipe float currentPadRotation = eventCtrl.GetTouchpadAxisAngle(); if (lastRotation - currentPadRotation < 180 && lastRotation - currentPadRotation > -180) { currentPortraitRotation += (lastRotation - currentPadRotation) * rotateSensitivity; } if (lastControllerActions != null && ((int)(currentPadRotation) / 35) != ((int)(lastRotation) / 35)) { lastControllerActions.TriggerHapticPulse(.05f); } if (currentPortraitRotation > angleBetweenPictures / 2 && oldPortraitRotation < angleBetweenPictures / 2) { StartCoroutine(TriggerHapticCoroutine()); } if (currentPortraitRotation < -angleBetweenPictures / 2 && oldPortraitRotation > -angleBetweenPictures / 2) { StartCoroutine(TriggerHapticCoroutine()); } lastRotation = currentPadRotation; } } } if (!pressingButton || autoMoveToNextPicture) { if (autoMoveToNextPicture) { currentPortraitRotation += Time.deltaTime * (angleBetweenPictures + .01f - currentPortraitRotation) * 10; } else { // retour à l'image la plus proche if (currentPortraitRotation > angleBetweenPictures / 2) { currentPortraitRotation += Time.deltaTime * (angleBetweenPictures + .01f - currentPortraitRotation) * 10; } else if (currentPortraitRotation < -angleBetweenPictures / 2) { currentPortraitRotation += Time.deltaTime * -(angleBetweenPictures + .01f + currentPortraitRotation) * 10; } else { currentPortraitRotation -= Time.deltaTime * currentPortraitRotation * 10; } } } if (currentPortraitRotation > angleBetweenPictures) { currentPortraitRotation -= angleBetweenPictures; nextImage(); } if (currentPortraitRotation < -angleBetweenPictures) { currentPortraitRotation += angleBetweenPictures; previousImage(); } // rotation de l'image leftImageTransform.transform.localRotation = Quaternion.Euler(0, 0, currentPortraitRotation); rightImageTransform.transform.localRotation = Quaternion.Euler(0, 0, currentPortraitRotation); leftImageTransformNext.transform.localRotation = Quaternion.Euler(0, 0, currentPortraitRotation + angleBetweenPictures); leftImageTransformPrev.transform.localRotation = Quaternion.Euler(0, 0, currentPortraitRotation - angleBetweenPictures); rightImageTransformNext.transform.localRotation = Quaternion.Euler(0, 0, currentPortraitRotation + angleBetweenPictures); rightImageTransformPrev.transform.localRotation = Quaternion.Euler(0, 0, currentPortraitRotation - angleBetweenPictures); } else { // rotation du disque du grabbable, pas de la vue. GameObject grabbingObj = viewmasterObject.GetGrabbingObject(); if (grabbingObj != null) { VRTK.VRTK_ControllerEvents eventCtrl = grabbingObj.GetComponent <VRTK.VRTK_ControllerEvents>(); lastControllerActions = grabbingObj.GetComponent <VRTK.VRTK_ControllerActions>(); if (eventCtrl != null) { // on est en train de visionner l'image, on récupère la manette en train de tenir le VM afin de récupérer les swipes sur le pavé tactile eventCtrl.axisFidelity = 5; bool wasPressing = pressingButton; pressingButton = eventCtrl.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.Touchpad_Touch); if (pressingButton && !wasPressing) { lastRotation = eventCtrl.GetTouchpadAxisAngle(); } if (pressingButton && false) { // en train de faire un swipe float currentPadRotation = eventCtrl.GetTouchpadAxisAngle(); if (lastRotation - currentPadRotation < 180 && lastRotation - currentPadRotation > -180) { currentClipRotation += (lastRotation - currentPadRotation) * rotateSensitivity; } if (lastControllerActions != null && ((int)(currentPadRotation) / 275) != ((int)(lastRotation) / 275)) { triggerAnimator.SetTrigger("Trigger"); } lastRotation = currentPadRotation; viewmasterGrabbableClipRotation.transform.localRotation = Quaternion.Euler(currentClipRotation, 0, 0); } } } } }
protected virtual void Update() { multiplyMovement = (controllerEvents && movementMultiplierButton != VRTK_ControllerEvents.ButtonAlias.Undefined && controllerEvents.IsButtonPressed(movementMultiplierButton)); }