public override void Process() { // Reset data, set camera m_Data.Reset(); m_Data.position = new Vector2(m_Camera.pixelWidth / 2, m_Camera.pixelHeight / 2); //Raycast eventSystem.RaycastAll(m_Data, m_RaycastResultCache); m_Data.pointerCurrentRaycast = FindFirstRaycast(m_RaycastResultCache); m_CurrentObject = m_Data.pointerCurrentRaycast.gameObject; //Clear Raycast m_RaycastResultCache.Clear(); //Handle Hover States HandlePointerExitAndEnter(m_Data, m_CurrentObject); //Press if (m_ClickAction.GetLastStateDown(m_TargetSource)) { ProcessPress(m_Data); } //Release if (m_ClickAction.GetLastStateUp(m_TargetSource)) { ProcessRelease(m_Data); } }
private void Update() { if (isFading) { return; } isHandInArea = playerBody.isHeadInArea ? Mathf.Abs(transform.localPosition.x) < playerBody.currentPlayfieldSize.x / 2.0f && Mathf.Abs(transform.localPosition.z) < playerBody.currentPlayfieldSize.z / 2.0f : false; if (isHandInArea) // is the hand within the playspace { if (grabAction.GetLastStateDown(hand) && holdAction.GetState(hand)) { if (collidingObject) { GrabObject(); } } } if (grabAction.GetLastStateUp(hand)) { if (GetComponent <FixedJoint>() != null) { ReleaseObject(); } } }
private void Update() { if (grabObject.GetStateDown(inputSource) && collidingObject && !holdingObject && collidingObject.GetComponent <Rigidbody>()) { if ((useTag && collidingObject.tag == tag) || !useTag) { holdJoint = gameObject.AddComponent <FixedJoint>(); holdJoint.breakForce = float.PositiveInfinity; holdJoint.breakTorque = float.PositiveInfinity; holdJoint.connectedBody = collidingObject.GetComponent <Rigidbody>(); holdingObject = collidingObject; holdingObject.SendMessage("Grab", SendMessageOptions.DontRequireReceiver); } } if (grabObject.GetLastStateUp(inputSource) && holdingObject) { holdJoint.connectedBody = null; Destroy(holdJoint); holdingObject.SendMessage("Release", SendMessageOptions.DontRequireReceiver); holdingObject.GetComponent <Rigidbody>().velocity = pose.GetVelocity(); holdingObject.GetComponent <Rigidbody>().angularVelocity = pose.GetAngularVelocity(); holdingObject = null; } }
// Update is called once per frame void Update() { if (gripAction.GetLastStateDown(handType)) { if (collidingObject && collidingObject.tag != "Bubble") { GrabObject(); } } if (gripAction.GetLastStateUp(handType)) { if (objectInHand) { ReleaseObject(); } } if (swapAction.GetState(SteamVR_Input_Sources.LeftHand) && swapAction.GetState(SteamVR_Input_Sources.RightHand) && !swapped) { print("Swapped"); swapped = true; ControllerActionScript controlScript = GetComponent <ControllerActionScript>(); controlScript.enabled = !controlScript.enabled; LaserScript laserScript = GetComponent <LaserScript>(); laserScript.enabled = !laserScript.enabled; } else if (!swapAction.GetState(SteamVR_Input_Sources.LeftHand) && !swapAction.GetState(SteamVR_Input_Sources.RightHand) && swapped) { print("deswap"); swapped = false; } }
private void CalculateMovement() { //Figure out movement orientation Vector3 orientationEuler = new Vector3(0, transform.eulerAngles.y, 0); Quaternion orientation = Quaternion.Euler(orientationEuler); Vector3 movement = Vector3.zero; //if not moving if (m_MovePress.GetLastStateUp(SteamVR_Input_Sources.Any)) { m_Speed = 0; } //if button pressed if (m_MovePress.state) { //Add,clamp m_Speed += m_MoveValue.axis.y * m_Sensitivity; m_Speed = Mathf.Clamp(m_Speed, -m_MaxSpeed, m_MaxSpeed); //Orientation movement += orientation * (m_Speed * Vector3.forward) * Time.deltaTime; } //Apply m_CharacterController.Move(movement); }
// Update is called once per frame void Update() { if (teleportAction.GetState(handType)) { RaycastHit hit; if (Physics.Raycast(controllerPose.transform.position, transform.forward, out hit, 100, teleportMask)) { hitPoint = hit.point; ShowLaser(hit); reticle.SetActive(true); teleportReticleTransform.position = hitPoint + teleportReticleOffset; shouldTeleport = true; } } else { laser.SetActive(false); reticle.SetActive(false); } if (teleportAction.GetLastStateUp(handType) && shouldTeleport) { Teleport(); } }
// Update is called once per frame void Update() { if (teleportAction.GetLastStateDown(handType)) { if (ControllerUseEvent != null) { ControllerUseEvent("positionReset", handType.ToString(), "down"); } DecideOnResetType("position"); } if (teleportAction.GetLastStateUp(handType)) { if (ControllerUseEvent != null) { ControllerUseEvent("positionReset", handType.ToString(), "up"); } } if (menuAction.GetLastStateDown(handType)) { if (ControllerUseEvent != null) { ControllerUseEvent("rotationReset", handType.ToString(), "down"); } DecideOnResetType("rotation"); } if (menuAction.GetLastStateUp(handType)) { if (ControllerUseEvent != null) { ControllerUseEvent("rotationReset", handType.ToString(), "up"); } } }
void CalculateMovement() { if (m_Head == null || m_CameraRig == null) { return; } // Figure out movement orientation Vector3 orientationEuler = new Vector3(0, m_Head.eulerAngles.y, 0); Quaternion orientation = Quaternion.Euler(orientationEuler); Vector3 movement = Vector3.zero; // If not moving if (m_MovePress.GetLastStateUp(SteamVR_Input_Sources.Any)) { m_Speed = Vector2.zero; } // If button pressed if (m_MovePress.state) { // Add and clamp m_Speed += new Vector2(m_MoveValue.axis.x, m_MoveValue.axis.y) * m_Sensitivity; m_Speed = Vector2.ClampMagnitude(m_Speed, m_MaxSpeed); // Orientation movement += orientation * (m_Speed.y * Vector3.forward + m_Speed.x * Vector3.right); } // Apply m_RigidBody.velocity = movement * m_Velocity * Time.deltaTime; }
// Update is called once per frame void Update() { if (grabPinchAction.GetLastStateUp(handType)) { print("switch"); SwitchHand(); } }
private void Update() { if (XRDevice.isPresent) { if (grabPinchAction.GetStateDown(handType)) { // Set that fireflies should follow shouldFollow = true; // Make controller glowing if (!isGlowing) { Glow(true); } // Set start position of drag dragStartPosition = transform.position; } else if (grabPinchAction.GetLastStateUp(handType)) { // Set that fireflies should not follow shouldFollow = false; // Deactivate controller glowing if (isGlowing) { Glow(false); } // Reset values of seperation ResetDrag(); } // Logic for seperating if (dragStartPosition != null && firefliesHitted != null) { float dragDistance = Vector3.Distance(transform.position, (Vector3)dragStartPosition); var allowed = FirefliesHelper.Instance.RequestSeperating(GetInstanceID(), firefliesHitted.GetInstanceID()); if (dragDistance > minSeperationDragDistance && allowed) { firefliesHitted.Seperate(); } } } else if (moveWithMouse) { Vector3 temp = Input.mousePosition; temp.z = Input.mousePosition.z + 2; transform.position = Camera.main.ScreenToWorldPoint(temp); } else { shouldFollow = false; } }
// Update is called once per frame void Update() { if (trigger.GetLastStateUp(thisHand)) { Drop(); } if (trigger.GetStateDown(thisHand)) { Grab(); } }
// Update is called once per frame void Update() { if (gameManager.GameStarted) { Wand wand = FindObjectOfType <Wand>(); if (castMagic.GetStateDown(SteamVR_Input_Sources.RightHand)) { GameObject go = new GameObject(); currLine = go.AddComponent <LineRenderer>(); currLine.startWidth = 0.05f; currLine.endWidth = 0.05f; currLine.material = lineMat; currLine.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; audioSource.clip = pressClip; audioSource.Play(); //talk to logan's wand wand.StartCasting(); numClicks = 0; } else if (castMagic.GetLastStateUp(SteamVR_Input_Sources.Any)) { wand.StopCasting(); //audioSource.clip = releaseClip; //audioSource.Play(); } else if (castMagic.GetState(SteamVR_Input_Sources.RightHand)) { GameObject magic = Instantiate(particleMagic, spawnPoint.transform.position, Quaternion.identity); magic.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); if (currLine == null) { return; } currLine.positionCount = numClicks + 1; currLine.SetPosition(numClicks, spawnPoint.transform.position); numClicks++; } } else { if (castMagic.GetStateDown(SteamVR_Input_Sources.Any)) { audioSource.clip = magicBlast; audioSource.Play(); GameObject magic = Instantiate(particleBlast, spawnPoint.transform.position, Quaternion.identity); magic.transform.localScale = new Vector3(0.05f, 0.05f, 0.05f); magic.GetComponent <Rigidbody>().AddForce(transform.up * 350); } } }
void Update() { //// 1 //if (teleportAction.GetState(handType)) //{ RaycastHit hit; if (TeleportAction.GetState(SteamVR_Input_Sources.Any)) { laser.SetActive(false); } // 2 if (Physics.Raycast(controllerPose.transform.position, transform.forward, out hit, 100) && !TeleportAction.GetState(SteamVR_Input_Sources.Any)) { grabbable = hit.transform.gameObject; if ((grabbable.GetComponent("Throwable")) != null) { print(grabbable); } else { grabbable = null; } hitPoint = hit.point; ShowLaser(hit); } ShowLaser(hit); // 1 if (grabAction.GetLastStateDown(handType)) { if (grabbable) { print(grabbable); GrabObject(); } } // 2 if (grabAction.GetLastStateUp(handType)) { if (objectInHand) { ReleaseObject(); } } //} //else // 3 //{ // laser.SetActive(false); //} }
// Update is called once per frame private void Update() { //Pointer m_HasPosition = UpdatePointer(); M_Pointer.SetActive(m_HasPosition); //Teleport if (m_TeleportAction.GetLastStateUp(m_Pose.inputSource)) { TryTeleport(); } }
void Update() { if (grabAction.GetLastStateDown(handType)) { controller.moveType = MoveCtrl.MoveType.LOOK_AT; } if (grabAction.GetLastStateUp(handType)) { controller.moveType = MoveCtrl.MoveType.DAYDREAM; } }
/** Updates cooldown, toggles menu on click. */ void Update() { if (_swapCooldown > 0) { _swapCooldown--; } if (m_OpenMenu.GetLastStateUp(m_TargetSource)) { SetPauseMenu(!pauseCanvas.gameObject.activeSelf); } }
private void Update() { if (photonView.IsMine) { m_HasPosition = UpdatePointer(); M_Pointer.SetActive(m_HasPosition); // Teleport if (m_TeleportAction.GetLastStateUp(m_Pose.inputSource)) { TryTeleport(); } } }
private void Update() { if (grabGripAction.GetLastStateDown(handType)) { if (collidingObject) { GrabObject(); } } if (grabGripAction.GetLastStateUp(handType) && objectInHand) { ReleaseObject(); } }
void FixedUpdate() { if (move.GetLastStateDown(handType)) { DpadNorthDown(); } if (move.GetLastStateUp(handType)) { DpadNorthUp(); } if (rotateRight.GetLastStateUp(handType)) { DpadEastDown(); } if (rotateRight.GetLastStateUp(handType)) { DpadEastUp(); } if (rotateLeft.GetLastStateUp(handType)) { DpadWestDown(); } if (rotateLeft.GetLastStateUp(handType)) { DpadWestUp(); } _playerRotation = playerCamera.transform.localRotation.y; player.GetComponent <Rigidbody>().transform.Rotate(0.0f, _playerRotation * _playerRotationSpeed, 0.0f); player.GetComponent <Rigidbody>().transform.Translate(_playerPosition * _playerSpeed * Time.deltaTime); }
// Update is called once per frame void Update() { if (inVRMode == false) { return; } hasPosition = UpdatePointer(); pointer.SetActive(hasPosition); if (teleportAction.GetLastStateUp(pose.inputSource)) { TryTeleport(); } }
// Update is called once per frame void Update() { float targetLength = m_defaultLength; RaycastHit hit = CreateRaycast(targetLength); Vector3 endPos = transform.position + transform.forward * targetLength; if (hit.collider != null) { endPos = hit.point; } coolDown -= Time.deltaTime; m_LineRenderer.enabled = coolDown > 0; m_LineRenderer.SetPosition(0, transform.position); m_LineRenderer.SetPosition(1, endPos); if (m_ClickAction.GetLastStateDown(m_TargetSource)) { ButtonFunctions bf; if (coolDown > 0) { if (hit.collider != null) { Debug.Log("Click Hit " + hit.collider.gameObject.name); if ((bf = hit.collider.GetComponent <ButtonFunctions>()) != null) { Debug.Log("Click Sent " + hit.collider.gameObject.name); bf.OnClick(); } } } coolDown = 5; } if (m_ClickAction.GetLastStateUp(m_TargetSource)) { //ProcessRelease(m_Data); } }
void Update() { if (Index_Finger.GetLastStateDown(Hand_type)) { print("XXXX" + Hand_type); } if (Index_Finger.GetLastState(Hand_type)) { print("XXXX" + Hand_type); Laser.SetActive(true); } if (Index_Finger.GetLastStateUp(Hand_type)) { print("XXXX" + Hand_type); Laser.SetActive(false); } }
//#if ZED_STEAM_VR #if ZED_SVR_2_0_INPUT /// <summary> /// Checks the button state of a given SteamVR boolean action. /// </summary> /// <param name="state">Whether to check if the button/action is just pressed, just released, or is being held down.</param> protected bool CheckSteamVRBoolActionState(SteamVR_Action_Boolean action, ControllerButtonState buttonstate) { switch (buttonstate) { case ControllerButtonState.Down: return(action.GetLastStateDown(GetSteamVRInputSource())); case ControllerButtonState.Held: return(action.GetLastState(GetSteamVRInputSource())); case ControllerButtonState.Up: return(action.GetLastStateUp(GetSteamVRInputSource())); default: return(false); } }
void Update() { RaycastHit hit; if (Physics.Raycast(_controllerPose.transform.position, transform.forward, out hit, 100f, _layerMask)) { if (!ReferenceEquals(_hitObject, hit.collider.gameObject)) { if (_hitObject != null) { Highlight(_hitObject, false); } Highlight(hit.collider.gameObject, true); } _hitObject = hit.collider.gameObject; } else { if (_hitObject) { Highlight(_hitObject, false); _hitObject = null; } } if (_grabAction.GetLastStateDown(_handType)) { if (_collidingObject && InLayerMask(_collidingObject)) { Highlight(_hitObject, false); GrabObject(); } } else if (_grabAction.GetLastStateUp(_handType)) { if (_objectInHand) { ReleaseObject(); } } }
// Update is called once per frame void Update() { //Debug.Log(sword); if (grabAction.GetLastStateDown(handType)) { if (collidingObject) { GrabObject(); } } if (grabAction.GetLastStateUp(handType)) { if (objectInHand) { //sword.OffGrap(); } } }
// Update is called once per frame void Update() { //잡기 버튼 누를때 if (grabAction.GetLastStateDown(hand)) { if (willObject) { GrabObject(); } } if (grabAction.GetLastStateUp(hand)) { if (grabObject) { ReleaseObject(); } } }
// Update is called once per frame void Update() { if (grabAction.GetLastStateDown(handType)) { if (collidingObj) { GrabObject(); } } if (grabAction.GetLastStateUp(handType)) { if (objInHand) { ReleaseObject(); } } }
// Update is called once per frame void Update() { if (grabAction.GetLastStateDown(handType)) { //print("grab action?"); if (collidingObject) { GrabObject(); //print("Grabed?"); } } if (grabAction.GetLastStateUp(handType)) { if (objectInHand) { ReleaseObject(); } } }
// Update is called once per frame void Update() { // we attempt to release an holded object if (grabAction.GetLastStateUp(handType)) { if (objectInHand) { if (objectInHand.GetComponent <GrablableObject>() != null) { objectInHand.GetComponent <GrablableObject>().Release(controllerPose); objectInHand = null; } else { ReleaseStandardObject(); } } } }
// Update is called once per frame void Update() { // 1 if (grabAction.GetLastStateDown(handType)) { warshot(); if (collidingObject) { } } // 2 if (grabAction.GetLastStateUp(handType)) { if (objectInHand) { } } }