Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (m_GrabAction.GetStateDown(m_Pose.inputSource))
        {
            if (m_CurrentInteractable == null)
            {
                Pickup(); //BUG: Can take the last object out of gallery multiple times
            }
            else
            {
                Drop();
            }
        }

        if (m_SecondaryAction.GetStateUp(m_Pose.inputSource))
        {
            DoSecondary();
        }

        if (m_PushAction.GetAxis(m_Pose.inputSource) != 0f)
        {
            DoPrimary();
        }
        else if (m_Cancontroller != null)
        {
            m_Cancontroller.onSprayStop();
        }
    }
Пример #2
0
 private void touchDetection(SteamVR_Input_Sources handType, bool isLeft)
 {
     if (grabPinchAction.GetStateUp(handType))
     {
         Debug.Log("Button released");
         if (isLeft)
         {
             setLeftTriggerDown(false);
         }
         else
         {
             setRightTriggerDown(false);
         }
     }
     if (grabPinchAction.GetLastStateDown(handType))
     {
         Debug.Log("Button down");
         if (isLeft)
         {
             setLeftTriggerDown(true);
         }
         else
         {
             setRightTriggerDown(true);
         }
     }
 }
Пример #3
0
    //플레이어 VR이동
    private void VRMove()
    {
        Vector2 pos;
        float   moveX = 0;
        float   moveZ = 0;

        if (trackPadClick.GetState(leftHand))
        {
            pos   = trackPadPosition.GetAxis(leftHand);
            moveX = pos.x;
            moveZ = pos.y;
        }
        else if (trackPadClick.GetStateUp(leftHand))
        {
            moveX = 0;
            moveZ = 0;
        }
        Vector3 moveHorizontal = transform.right * moveX;
        Vector3 moveVertical   = transform.forward * moveZ;

        velocity = (moveHorizontal + moveVertical).normalized * speed;
        if (velocity.magnitude <= 0.01f)
        {
            isWalk = false;
        }
        else if (!isRun)
        {
            isWalk = true;
        }
        rig.MovePosition(transform.position + velocity * Time.deltaTime);
        animator.SetBool("Run", isRun);
        currentRifle.animator.SetBool("Run", isRun);
        animator.SetBool("Walk", isWalk);
        currentRifle.animator.SetBool("Walk", isWalk);
    }
Пример #4
0
    public override void Process()
    {
        // reset data, set camera
        m_Data.Reset();
        m_Data.position = new Vector2(m_Camera.pixelWidth / 2.0f, m_Camera.pixelHeight / 2.0f);

        // raycast
        eventSystem.RaycastAll(m_Data, m_RaycastResultCache);
        m_Data.pointerCurrentRaycast = FindFirstRaycast(m_RaycastResultCache);
        m_CurrentObject = m_Data.pointerCurrentRaycast.gameObject;

        // clear
        m_RaycastResultCache.Clear();

        // hover
        HandlePointerExitAndEnter(m_Data, m_CurrentObject);

        // press
        if (m_ClickAction.GetStateDown(m_TargetSource))
        {
            ProcessPress(m_Data);
        }

        // release
        if (m_ClickAction.GetStateUp(m_TargetSource))
        {
            ProcessRelease(m_Data);
        }
    }
Пример #5
0
 // Update is called once per frame
 void Update()
 {
     if (GameManager.Instance.playerPlatform == PlayerPlatform.OCULUS)
     {
         if (handSide == HandSide.LEFT && OVRInput.GetUp(OVRInput.Button.PrimaryIndexTrigger))
         {
             spawner.ThrowCurrentBall();
         }
         if (handSide == HandSide.RIGHT && OVRInput.GetUp(OVRInput.Button.SecondaryIndexTrigger))
         {
             spawner.ThrowCurrentBall();
         }
     }
     else if (GameManager.Instance.playerPlatform == PlayerPlatform.EDITOR)
     {
         if (Input.GetKeyUp(KeyCode.Space))
         {
             spawner.ThrowCurrentBall();
         }
     }
     else if (GameManager.Instance.playerPlatform == PlayerPlatform.STEAMVR)
     {
         if (click.GetStateUp(handPose.inputSource))
         {
             spawner.ThrowCurrentBall();
         }
     }
 }
 // Update is called once per frame
 void Update()
 {
     if (_action.GetStateUp(_handType))
     {
         _rosSocket.CallService <std_srvs.EmptyRequest, std_srvs.EmptyResponse>(_service, ServiceCallHandler, new std_srvs.EmptyRequest());
     }
 }
Пример #7
0
    public override void Process()
    {
        // Reset data, set camera
        _data.Reset();
        _data.position = new Vector2(_camera.pixelWidth / 2, _camera.pixelHeight / 2);

        // Raycast
        eventSystem.RaycastAll(_data, m_RaycastResultCache);
        _data.pointerCurrentRaycast = FindFirstRaycast(m_RaycastResultCache);
        _currentObject = _data.pointerCurrentRaycast.gameObject;

        // Clear
        m_RaycastResultCache.Clear();

        // Hover
        HandlePointerExitAndEnter(_data, _currentObject);

        // Press
        if (_clickAction.GetStateDown(_targetSource))
        {
            ProcessPress(_data);
        }

        // Release
        if (_clickAction.GetStateUp(_targetSource))
        {
            ProcessRelease(_data);
        }
    }
Пример #8
0
    void Update()
    {
        Hand hand = GameManager.Instance.GetHand();

        if (!hand)
        {
            return;
        }

        if (teleportAction.GetStateDown(hand.handType))
        {
            GameManager.Instance.pointers.SetColor(Color.red);
        }
        if (teleportAction.GetStateUp(hand.handType))
        {
            RaycastHit rayInfo = GameManager.Instance.pointers.CreateRaycast(30);

            if (rayInfo.collider.tag == "Floor")
            {
                Player.instance.transform.position = rayInfo.point;
            }

            GameManager.Instance.pointers.SetColor(Color.black);
        }
    }
Пример #9
0
        private IEnumerator UpdateCor()
        {
            float t = 0.0f;

            while ((t += Time.deltaTime) < time)
            {
                TimeEvent.Invoke(t / time);
                yield return(new WaitForEndOfFrame());
            }
            TimeEvent.Invoke(1.0f);
            yield return(new WaitUntil(() => teleportAction.GetStateUp(SteamVR_Input_Sources.Any)));

            yield return(new WaitUntil(() => teleportAction.GetStateUp(SteamVR_Input_Sources.Any)));

            OnClickEvent.Invoke();
        }
Пример #10
0
 void FixedUpdate()
 {
     if (m_TeleportAction.GetStateUp(m_TargetSource))
     {
         Teleport();
     }
 }
    void ListenForPickupButtonPress()
    {
        if (extendHandButton.GetStateDown(pose.inputSource))
        {
            //Debug.Log("Pressed: " + extendHandButton.fullPath + " on " + pose.inputSource);
            atExtendedDistance = !atExtendedDistance;
        }

        if (extendHandButton.GetStateUp(pose.inputSource))
        {
            //Debug.Log("Released: " + extendHandButton.fullPath + " on " + pose.inputSource);
        }



        if (grabTrigger.GetStateDown(pose.inputSource))
        {
            PickUpObject();
        }

        if (grabTrigger.GetStateUp(pose.inputSource))
        {
            DropObject();
        }

        // Debug.LogError("Axis value is : " + single.axis);
    }
Пример #12
0
    // Update is called once per frame
    private void Update()
    {
        // Down
        if (m_GrabAction.GetStateDown(m_Pose.inputSource))
        {
            Pulse(0, 75, 1, SteamVR_Input_Sources.RightHand); // doesn't work atm
            Debug.Log("haptic feedback");

            print(m_Pose.inputSource + "Trigger down");
            if (current != null && GetNearestGameObject() != null)
            {
                pm.backupInput(GetNearestGameObject().name);

                GetNearestGameObject().GetComponent <MeshRenderer>().material = tapped;
                Userinput.Add(GetNearestGameObject());
            }

            //call method Input();
            //Pickup();
        }
        //Up
        if (m_GrabAction.GetStateUp(m_Pose.inputSource))
        {
            print(m_Pose.inputSource + "Trigger up");
            //Drop();
        }
    }
        /// <summary>
        /// Обработка события. Этот метод ведёт себя как Update.
        /// </summary>
        public override void Process()
        {
            // Обновляем данные события
            eventData.Reset();

            // Позиция луча - в середине того, что видит камера
            eventData.position = new Vector2(Camera.pixelWidth / 2, Camera.pixelHeight / 2);

            // Определяем объект, на который наведён луч
            eventSystem.RaycastAll(eventData, m_RaycastResultCache);
            eventData.pointerCurrentRaycast = FindFirstRaycast(m_RaycastResultCache);
            currentObject = eventData.pointerCurrentRaycast.gameObject;

            // Очищаем кеш Raycast
            m_RaycastResultCache.Clear();

            // Обработка события наведения луча
            HandlePointerExitAndEnter(eventData, currentObject);

            // Обработка события нажатия кнопки
            if (ClickAction.GetStateDown(TargetSource))
            {
                ProcessPress(eventData);
            }

            // Обработка события отпускания кнопки
            if (ClickAction.GetStateUp(TargetSource))
            {
                ProcessRelease(eventData);
            }
        }
Пример #14
0
    // Update is called once per frame
    void Update()
    {
        if (hadGrabed)                                           //如果手上有东西
        {
            if (triggerAction.GetStateUp(holdHand.handType))     //是否松开扳机
            {
                grabTarget.transform.parent     = grabOldParent; //复位
                grabTarget.collider.enabled     = true;
                grabTarget.rigidbody.useGravity = true;
                hadGrabed = false;
            }

            return;
        }

        foreach (Hand hand in Player.instance.hands)
        {
            if (triggerAction.GetStateDown(hand.handType))                            //如果该手按下了扳机
            {
                RaycastHit rayInfo = GameManager.Instance.pointers.CreateRaycast(30); //发送射线

                if (rayInfo.collider.tag == "Throwable")                              //如果射线目标是"Throwable"标签的物体
                {
                    if (!hadGrabed)                                                   //手上没有东西
                    {
                        Grab(rayInfo);                                                //抓起东西
                        holdHand = hand;
                    }
                }
            }
        }
    }
Пример #15
0
 void Update()
 {
     //왼손 컨트롤러의 트리거 버튼을 클릭했을 떄 생성
     if (trigger.GetStateDown(leftHand))
     {
         Debug.Log("Clicked Trigger Button");
         haptic.Execute(0.2f, 0.3f, 120.0f, 0.5f, leftHand);
     }
     //오른손 컨트롤러
     if (trigger.GetStateUp(rightHand))
     {
         Debug.Log("Released Trigger Button");
     }
     //트랙패드 클릭
     if (trackPadClick.GetStateDown(any))
     {
         Debug.Log("TrackPad Click");
     }
     //트랙패드 터치 d
     if (trackPadTouch.GetState(any))
     {
         Vector2 pos = trackPadPosition.GetAxis(any);
         Debug.Log($"Touch pos x={pos.x}/y={pos.y}");
     }
 }
Пример #16
0
    public override void Process()
    {
        // 카메라 중간 위치
        m_Data.Reset();
        m_Data.position = new Vector2(m_Camera.pixelWidth / 2, m_Camera.pixelHeight / 2);

        // 레이저에 닿은 UI 찾음
        // BaseInputModule 에서 제공,
        eventSystem.RaycastAll(m_Data, m_RaycastResultCache);
        m_Data.pointerCurrentRaycast = FindFirstRaycast(m_RaycastResultCache);  // 현재 이벤트와 연관된 RacastResult
        m_CurrentObject = m_Data.pointerCurrentRaycast.gameObject;              // 레이저로 가리키는 오브젝트

        m_RaycastResultCache.Clear();

        // 입출력 이벤트 전송
        // 호버링(마우스 포인터가 해당 컨트롤 위에 있음)
        HandlePointerExitAndEnter(m_Data, m_CurrentObject);

        // 터치패드 누를 때
        if (m_ClickAction.GetStateDown(m_TargetSource))
        {
            ProcessPress(m_Data);
        }

        // 터치패드 뗄 때
        if (m_ClickAction.GetStateUp(m_TargetSource))
        {
            ProcessRelease(m_Data);
        }
    }
Пример #17
0
    void CalculateMovement()
    {
        // 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.GetStateUp(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);
    }
Пример #18
0
    public void Interacted()
    {
        if (grabbing.GetStateDown(pose.inputSource) || Input.GetKeyDown("r"))
        {
            PickUp();
            pressing = true;
        }

        if (current != null)
        {
            if (current.gameObject.tag == "ObjetoSuelto")
            {
                if (grabbing.GetStateUp(pose.inputSource) || Input.GetKeyUp("r"))
                {
                    Drop();
                    pressing = false;
                }
            }
            else if (current.gameObject.tag == "ObjetoInventario")
            {
                if (gripping.GetStateDown(pose.inputSource) || Input.GetKeyUp("r"))
                {
                    Drop();
                    griped = true;
                }

                if (gripping.GetStateUp(pose.inputSource) || Input.GetKeyUp("r"))
                {
                    griped = false;
                }
            }
        }
    }
Пример #19
0
    // Update is called once per frame
    void Update()
    {
        // 1
        if (teleportAction.GetState(handType))
        {
            RaycastHit hit;

            // 2
            if (Physics.Raycast(controllerPose.transform.position, transform.forward, out hit, 100, teleportMask))
            {
                hitPoint = hit.point;
                ShowLaser(hit);
                // 1
                reticle.SetActive(true);
                // 2
                teleportReticleTransform.position = hitPoint + teleportReticleOffset;
                // 3
                shouldTeleport = true;
            }
        }
        else         // 3
        {
            laser.SetActive(false);
            reticle.SetActive(false);
        }

        if (teleportAction.GetStateUp(handType) && shouldTeleport)
        {
            Teleport();
        }
    }
Пример #20
0
    private void Update()
    {
        if (pinch.GetStateUp(bp.inputSource) && isHolding)
        {
            foreach (Transform child in this.transform)
            {
                //Checks each child in controller to see if any object is picked up and drops it
                if (child.tag == "Ammo")
                {
                    child.transform.parent = GameObject.Find("Baseballs").transform;
                    child.GetComponent <Rigidbody>().detectCollisions = true;
                    child.GetComponent <Rigidbody>().useGravity       = true;
                    child.GetComponent <Rigidbody>().AddForce(new Vector3(bp.GetVelocity().x *throwStrength, bp.GetVelocity().y * 50, bp.GetVelocity().z *throwStrength));
                    isHolding = false;
                    Destroy(child.gameObject, 5.0f);
                }
            }
        }

        /*if (model.transform.Find("trigger") != null)
         * {
         *  model.transform.Find("trigger").GetComponent<MeshRenderer>().material = defaultMat;
         *  model.transform.Find("trigger").GetComponent<MeshRenderer>().material.SetColor("_Color", new Color(0, 0, 1, 1));
         * }*/
    }
Пример #21
0
    public override void Process()
    {
        //Reset data, set camera
        data.Reset();
        data.position = new Vector2(cam.pixelWidth / 2, cam.pixelHeight / 2);

        //Raycast
        eventSystem.RaycastAll(data, m_RaycastResultCache);
        data.pointerCurrentRaycast = FindFirstRaycast(m_RaycastResultCache);
        currentObject = data.pointerCurrentRaycast.gameObject;

        //Clear Raycast
        m_RaycastResultCache.Clear();

        //Handle hover states
        HandlePointerExitAndEnter(data, currentObject);

        //Press input
        if (clickAction.GetStateDown(targetSource))
        {
            ProcessPress(data);
        }

        //Release input
        if (clickAction.GetStateUp(targetSource))
        {
            ProcessPress(data);
        }
    }
Пример #22
0
 private void HandleButton(SteamVR_Action_Boolean actionIn, SteamVR_Input_Sources hand, bool newState)
 {
     //Debug.Log($"{hand} down is {actionIn.GetStateDown(hand)}");
     if (actionIn.GetStateDown(hand))
     {
         if (hand == SteamVR_Input_Sources.LeftHand)
         {
             _leftDown = true;
         }
         else if (hand == SteamVR_Input_Sources.RightHand)
         {
             _rightDown = true;
         }
     }
     else if (actionIn.GetStateUp(hand))
     {
         if (hand == SteamVR_Input_Sources.LeftHand)
         {
             _leftDown = false;
         }
         else if (hand == SteamVR_Input_Sources.RightHand)
         {
             _rightDown = false;
         }
     }
 }
Пример #23
0
        public override void OnUpdate()
        {
            switch (gripType)
            {
            case setGripType.getPress:
                var padDown = booleanAction.GetState(device);
                if (padDown)
                {
                    Fsm.Event(sendEvent);
                }
                storeResult.Value = padDown;
                break;

            case setGripType.getPressUp:
                var padDownUp = booleanAction.GetStateUp(device);

                if (padDownUp)
                {
                    Fsm.Event(sendEvent);
                }
                storeResult.Value = padDownUp;
                break;

            case setGripType.getPressDown:
                var padDownDown = booleanAction.GetStateDown(device);

                if (padDownDown)
                {
                    Fsm.Event(sendEvent);
                }
                storeResult.Value = padDownDown;
                break;
            }
        }
Пример #24
0
    private void Update()
    {
        if (disableOnTeleport)
        {
            if (teleportButton.GetStateDown(SteamVR_Input_Sources.Any))
            {
                for (int i = 0; i < pointsholder.Length; i++)
                {
                    if (transform.GetChild(i) != null)
                    {
                        isActive[i] = transform.GetChild(i).gameObject.activeSelf;
                        transform.GetChild(i).gameObject.SetActive(false);
                    }
                }
            }
            else if (teleportButton.GetStateUp(SteamVR_Input_Sources.Any))
            {
                for (int i = 0; i < pointsholder.Length; i++)
                {
                    if (transform.GetChild(i) != null)
                    {
                        transform.GetChild(i).gameObject.SetActive(isActive[i]);
                    }
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            SaveBuild();
        }
    }
Пример #25
0
    private void CalculateMovement()
    {
        // Figure out movement orientation
        var orientationEuler = new Vector3(0, _head.eulerAngles.y, 0);
        var orientation      = Quaternion.Euler(orientationEuler);
        var movement         = Vector3.zero;

        // If not moving
        if (MovePress.GetStateUp(SteamVR_Input_Sources.LeftHand))
        {
            _speed = 0;
        }

        if (MovePress.state)
        {
            // Add, clamp
            _speed += MoveValue.axis.y * Sensitivity;
            _speed  = Mathf.Clamp(_speed, -MaxSpeed, MaxSpeed);

            // Orientation
            movement += orientation * (_speed * Vector3.forward) * Time.deltaTime;
        }

        var finalPosition = new Vector3(movement.x + Player.position.x, Player.position.y, movement.z + Player.position.z);

        Player.position = finalPosition;
    }
Пример #26
0
    // Update is called once per frame
    void Update()
    {
        // 왼손 컨트롤러 트리거를 눌렀을 때
        if (trigger.GetStateDown(leftHand))
        {
            Debug.Log("click left trigger");
            haptic.Execute(0.2f, 0.5f, 200.0f, 1f, leftHand); //웨이팅 타임 지속시간, 주파수, 진폭
        }

        //오른손 컨트롤러 트리거를 눌렀다가 떼었을때
        if (trigger.GetStateUp(rightHand))
        {
            Debug.Log("Released Triiger button");
            haptic.Execute(0.2f, 0.5f, 200.0f, 1f, rightHand); //웨이팅 타임 지속시간, 주파수, 진폭
        }

        if (trackPadCilck.GetStateDown(any))
        {
            Debug.Log("TrackPad Click");
        }

        if (trackPadTouch.GetState(any))
        {
            Vector2 pos = trackPadPosition.GetAxis(any);
            Debug.Log($"Touch pos x= {pos.x}/y={pos.y}");
        }
    }
Пример #27
0
    // Update is called once per frame
    void Update()
    {
        if (grabObject == null)
        {
            return;
        }

        if (isTouched && trigger.GetStateDown(rightHand))
        {
            grabObject.transform.SetParent(tr);
            grabObject.GetComponent <Rigidbody>().isKinematic = true;
        }

        if (trigger.GetStateUp(rightHand))
        {
            grabObject.transform.SetParent(null);
            //Vector3 _velocity = SteamVR_Actions.default_Pose.velocity;
            Vector3 _velocity = SteamVR_Actions.default_Pose.GetVelocity(rightHand);
            var     rb        = grabObject.GetComponent <Rigidbody>();
            rb.isKinematic = false;
            rb.velocity    = _velocity;

            grabObject = null;
            isTouched  = false;
        }
    }
Пример #28
0
    private void CalculateMovement()
    {
        //figure out movement orientation
        //Vector3 orientationEuler = new Vector3(0, transform.eulerAngles.y, 0); //for HandleHead
        Vector3    orientationEuler = new Vector3(0, m_Head.eulerAngles.y, 0); //without HandleHead
        Quaternion orientation      = Quaternion.Euler(orientationEuler);
        Vector3    movement         = Vector3.zero;

        //if not moving
        if (m_MovePress.GetStateUp(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; //for HandleHead
            movement += orientation * (m_Speed * Vector3.forward); //without HandleHead
        }

        //Gravity //without HandleHead
        movement.y -= m_Gravity * Time.deltaTime;

        //apply
        //m_CharacterController.Move(movement); //without HandleHead
        m_CharacterController.Move(movement * Time.deltaTime);
    }
Пример #29
0
    // Update is called once per frame
    void Update()
    {
        if (teleportAction.GetState(handType))
        {
            RaycastHit hit;

            if (Physics.Raycast(transform.position, transform.forward, out hit, 100, teleportMask))
            {
                if (hit.collider.tag != "NoTel")
                {
                    hitPoint = hit.point;
                    ShowLaser(hit);
                    reticle.SetActive(true);
                    teleportReticleTransform.position = hitPoint + teleportReticleOffset;
                    shouldTeleport = true;
                }
            }
        }
        else
        {
            laser.SetActive(false);
            reticle.SetActive(false);
        }
        if (teleportAction.GetStateUp(handType) && shouldTeleport)
        {
            Teleport();
        }
    }
    private void Update()
    {
        if (interactable.attachedToHand)
        {
            if (toggleButton.GetStateDown(interactable.attachedToHand.handType))
            {
                if (sfx)
                {
                    PlaySoundPressed();
                }

                if (button)
                {
                    button.localPosition = pressed;
                }
            }
            if (toggleButton.GetStateUp(interactable.attachedToHand.handType))
            {
                if (button)
                {
                    button.localPosition = origin;
                }

                if (sfx)
                {
                    PlaySoundReleased();
                }

                Toggle();
            }
        }
    }