Exemplo n.º 1
0
    // Update is called once per frame
    private void Update()
    {
        CalculateMovement();
        // If grab button is pressed
        if (m_GrabAction.GetStateDown(m_Pose.inputSource))
        {
            if (m_CurrentInteractable != null)
            {
                Drop();
                return;
            }
            Pickup();
        }

        /*
         * if (m_GrabAction.GetStateUp(m_Pose.inputSource)) {
         *  print(m_Pose.inputSource + " Grab Up");
         *  Drop();
         * }*/
        if (m_UseAction.GetStateDown(m_Pose.inputSource))
        {
            //print(m_Pose.inputSource + " Use Down");
            if (m_CurrentInteractable != null)
            {
                m_CurrentInteractable.Action();
            }
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        //Debug.Log(isPlaying);
        if (ChangeState.GetStateDown(handType))
        {
            isPlaying = !isPlaying;
        }
        debugtext.text = "state:" + isPlaying.ToString();


        if (!isPlaying)
        {
            navMesh.velocity  = Vector3.zero;
            navMesh.isStopped = true;
            return;
        }
        else
        {
            navMesh.isStopped = false;
            if (idx >= destinations.Length)
            {
                navMesh.velocity  = Vector3.zero;
                navMesh.isStopped = true;
                return;
            }

            if (Vector3.Distance(Player.position, destinations[idx].transform.position) < 0.8f)
            {
                particle = destinations[idx].transform.GetChild(0).gameObject.GetComponent <ParticleSystem>();
                if (particle.isPlaying)
                {
                    particle.Stop();//前のパーティクルをストップ
                }
                idx++;
            }

            if (idx >= destinations.Length)
            {
                navMesh.velocity  = Vector3.zero;
                navMesh.isStopped = true;
                return;
            }

            navMesh.SetDestination(destinations[idx].transform.position);
            particle = destinations[idx].transform.GetChild(0).gameObject.GetComponent <ParticleSystem>();
            if (!particle.isPlaying)
            {
                particle.Play();
            }
            //Debug.Log(idx);
        }
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        trackpad = trackpadAction.GetAxis(laserInput);
        if (laserAction.GetStateDown(laserInput))
        {
            ShowLaser();
        }
        else if (laserAction.GetStateUp(laserInput))
        {
            HideLaser();
        }


        if (laserActive)
        {
            Vector3 raydir = laser.transform.position - transform.position;
            if (Physics.Raycast(transform.position, raydir, out hit, Mathf.Infinity))
            {
                if (grabAction.GetStateDown(laserInput))
                {
                    if (hit.collider.gameObject.CompareTag("Metal") || hit.collider.gameObject.layer == LayerMask.NameToLayer("Metal"))
                    {
                        hitGameObject = hit.collider.gameObject;
                        hitGameObject.GetComponent <Rigidbody>().useGravity = false;

                        grabPoint.transform.position = hitGameObject.transform.position;
                    }
                }
            }
        }

        if (grabAction.GetStateUp(laserInput) && hitGameObject != null)
        {
            Rigidbody hitRigidbody = hitGameObject.GetComponent <Rigidbody>();
            hitRigidbody.useGravity = true;
            hitRigidbody.AddForce(grabPoint.transform.position - hitGameObject.transform.position, ForceMode.Impulse);
            hitGameObject = null;
        }

        if (hitGameObject != null)
        {
            if (((grabPoint.transform.position - transform.position).magnitude >= minDistance) || trackpad.y > 0f)
            {
                grabPoint.transform.Translate(
                    dragSpeed * Time.deltaTime * trackpad.y *
                    (grabPoint.transform.position - transform.position).normalized, Space.World);
            }

            //hitGameObject.transform.position = grabPoint.transform.position;
            hitGameObject.transform.Translate((chaseSpeed) * Time.deltaTime * (grabPoint.transform.position - hitGameObject.transform.position), Space.World);
        }
    }
Exemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        if (prevButton != null)
        {
            OnPointerOut(prevButton);
            prevButton = null;
        }

        ray = new Ray(controller.position, controller.forward);

        if (Physics.Raycast(ray, out hit, maxDistance, layerButton))
        {
            line.SetPosition(1, new Vector3(0, 0, hit.distance));

            OnPointerIn(hit.collider.gameObject);
            prevButton = hit.collider.gameObject;

            if (trigger.GetStateDown(hand))
            {
                ExecuteEvents.Execute(hit.collider.gameObject,
                                      new PointerEventData(EventSystem.current), ExecuteEvents.pointerClickHandler);
            }
        }
        else
        {
            line.SetPosition(1, new Vector3(0, 0, maxDistance));
        }

        if (hand == SteamVR_Input_Sources.RightHand)
        {
            if (Physics.Raycast(ray, out hit, maxDistance, 1 << 10))
            {
                // 레이저 길이 조정
                line.SetPosition(1, new Vector3(0, 0, hit.distance));

                // 포인터의 위치 변경
                crossHair.transform.position = hit.point + (Vector3.up * 0.05f);
                crossHair.transform.rotation = Quaternion.LookRotation(hit.normal);
                crossHair.SetActive(true);

                if (teleport.GetStateUp(hand))
                {
                    SteamVR_Fade.Start(Color.black, 0.0f);
                    StartCoroutine(Teleport(hit.point));
                }
            }
            else
            {
                crossHair.SetActive(false);
            }
        }
    }
Exemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        print(isHeld);
        timer += Time.deltaTime;

        if (handhere && isHeld == false)
        {
            if (gripAction.GetStateDown(SteamVR_Input_Sources.RightHand) || gripAction.GetStateDown(SteamVR_Input_Sources.LeftHand))
            {
                pickupAudio.GetComponent <AudioSource>().enabled = true;
                StartCoroutine(pickupSound());
                isHeld = true;
                //var rotationVec = transform.rotation.eulerAngles;
                //rotationVec.x = 0;
                //rotationVec.y = 80;
                //rotationVec.z = 0;
                //transform.rotation = Quaternion.Euler(rotationVec);
                //transform.SetParent(rightHand.gameObject.transform, false);
                transform.rotation = rightHand.gameObject.transform.rotation;
                transform.position = rightHand.gameObject.transform.position;
                transform.parent   = rightHand.gameObject.transform;
                if ((topTarget.GetComponent <targetScript>().gamestarted == false) && (botTarget.GetComponent <targetScript>().gamestarted == false))
                {
                    topTarget.GetComponent <targetScript>().gunPickup = true;
                    botTarget.GetComponent <targetScript>().gunPickup = true;
                }
            }
        }

        /*if (isHeld)
         * {
         *  var rotvec = rightHand.gameObject.transform.rotation.eulerAngles;
         *  //rotvec.x = rightHand.transform.rotation.x + 45;
         *  //rotvec.y = rightHand.transform.rotation.y - 90;
         *  //rotvec.z = rightHand.transform.rotation.z - 90;
         *  transform.rotation = Quaternion.Euler(rotvec);
         * }*/

        if (isHeld)
        {
            if (timer > timeBetweenBullets && TriggerPress.GetStateDown(SteamVR_Input_Sources.RightHand))
            {
                shoot();
            }
            if (dropGrip.GetStateDown(SteamVR_Input_Sources.RightHand) || dropGrip.GetStateDown(SteamVR_Input_Sources.LeftHand))
            {
                transform.parent = null;
                isHeld           = false;
                gameObject.transform.position = originalPos;
            }
        }
    }
Exemplo n.º 6
0
    // Update is called once per frame
    void Update()
    {
        if (Physics.Raycast(tr.position, tr.forward, out hit, maxDistance))
        {
            // 라인의 끝점의 위치를 레이캐스팅한 지점의 좌표로 변경
            line.SetPosition(1, new Vector3(0, 0, hit.distance));

            line.enabled = true;

            if (teleport.GetStateDown(rightHand))
            {
                pointer.SetActive(true);
            }
            else if (teleport.GetState(rightHand))
            {
                line.material.color        = clickedColor;
                pointer.transform.position = hit.point + (hit.normal * 0.01f);
                pointer.transform.rotation = Quaternion.LookRotation(hit.normal);
            }
            else if (teleport.GetStateUp(rightHand))
            {
                line.material.color = color;
                pointer.SetActive(false);
                if (hit.transform.gameObject.layer == 8) //ground
                {
                    SteamVR_Fade.Start(Color.black, 0);
                    StartCoroutine(this.Teleport(hit.point));
                }
            }
            else if (hit.transform.CompareTag("Item"))
            {
                item = hit.transform.gameObject;
                if (trigger.GetState(rightHand)) // 오른손 트리거 - 직접 아이템을 끌어 옴
                {
                    line.material.color     = clickedColor;
                    item.transform.position = Vector3.Lerp(item.transform.position, transform.position, Time.deltaTime * 2);
                    dist = Vector3.Distance(item.transform.position, TriggerPoint.transform.position);
                    if (dist <= 1.5f)
                    {
                        item.transform.position = TriggerPoint.transform.position;
                        isTrigger = true;
                        item.GetComponent <Item>().IsGrabed = true;
                    }
                }
                line.material.color = color;
            }
        }
        if (isTrigger == true)
        {
            TriggerItem();
        }
    }
Exemplo n.º 7
0
    private void Update()
    {
        //pointer function
        if (isteleporting)
        {
            m_Pointer.SetActive(m_HasPosition);
            m_HasPosition = UpdatePointer();
        }
        //pinch Down
        if (m_pinchAction.GetStateDown(m_Pose.inputSource))
        {
            //print(m_Pose.inputSource + "Trigger Down");

            if (m_CurrentInteractable != null)
            {
                m_CurrentInteractable.Action();
                return;
            }

            Pickup();
        }
        if (m_pinchAction.GetStateUp(m_Pose.inputSource))
        {
            Drop();
        }

        if (m_touchpadAction.GetStateUp(m_Pose.inputSource) && isteleporting)
        {
            TryTeleport();
        }
        //pinch Up


        //grip Down
        if (m_gripAction.GetStateDown(m_Pose.inputSource))
        {
            //print(m_Pose.inputSource + "grip dwon");
            showup();
        }

        //grip Up
        if (m_gripAction.GetStateUp(m_Pose.inputSource))
        {
            //print(m_Pose.inputSource + "dismiss");
            dismiss();
        }
        //keyboard input
        if (Input.GetButtonDown("Fire3"))
        {
            ChangeQuestionText();
        }
    }
Exemplo n.º 8
0
    private void PistolGrab()
    {
        //Debug.Log("Pistol Grap!!");

        attachPos = pistolAttachPos;

        GripObject();

        if (isGrabbing && ClimbAction.GetStateDown(inputSource))
        {
            attachObject.GetComponent <Pistol_02>().Fire();
        }
    }
Exemplo n.º 9
0
    private ControllerState controllerEvents()
    {
#if SteamVR_Legacy
        if (Controller1.GetHairTriggerDown())
        {
            return(ControllerState.TRIGGER_DOWN1);
        }
        if (Controller1.GetHairTriggerUp())
        {
            return(ControllerState.TRIGGER_UP1);
        }
        if (Controller2.GetHairTriggerDown())
        {
            return(ControllerState.TRIGGER_DOWN2);
        }
        if (Controller2.GetHairTriggerUp())
        {
            return(ControllerState.TRIGGER_UP2);
        }
#elif SteamVR_2
        if (m_controllerPress.GetStateDown(trackedObj1.inputSource))
        {
            return(ControllerState.TRIGGER_DOWN1);
        }
        if (m_controllerPress.GetStateUp(trackedObj1.inputSource))
        {
            return(ControllerState.TRIGGER_UP1);
        }
        if (m_controllerPress.GetStateDown(trackedObj2.inputSource))
        {
            return(ControllerState.TRIGGER_DOWN2);
        }
        if (m_controllerPress.GetStateUp(trackedObj2.inputSource))
        {
            return(ControllerState.TRIGGER_UP2);
        }
#endif
        return(ControllerState.NONE);
    }
 // Update is called once per frame
 void Update()
 {
     if (Trigger.GetStateDown(HandType))
     {
         Debug.Log("Pull Trigger Down");
         hand.GrabBox();
     }
     else if (Trigger.GetStateUp(HandType))
     {
         Debug.Log("Pull Trigger Up");
         hand.ReleaseBox();
     }
 }
 // Update is called once per frame
 void Update()
 {
     if (Grab.GetState(SteamVR_Input_Sources.Any) || Grab.GetStateDown(SteamVR_Input_Sources.Any) && spawn.Inst != null)
     {
         obj = spawn.Inst;
         obj.transform.position = spawn.targetTransform.position;
         obj.transform.rotation = spawn.targetTransform.rotation;
     }
     if (Grab.GetStateUp(SteamVR_Input_Sources.Any))
     {
         spawn.Inst = null;
     }
 }
Exemplo n.º 12
0
 private void OnRightActionChange(SteamVR_Action_Boolean actionIn, SteamVR_Input_Sources inputSource, bool newValue)
 {
     if (isRight.GetStateDown(hand.handType))
     {
         Debug.Log("Right down");
         moveHorizontal += 1f;
     }
     if (isRight.GetStateUp(hand.handType))
     {
         Debug.Log("Right up");
         moveHorizontal -= 1f;
     }
 }
Exemplo n.º 13
0
 private void OnBackActionChange(SteamVR_Action_Boolean actionIn, SteamVR_Input_Sources inputSource, bool newValue)
 {
     if (isBack.GetStateDown(hand.handType))
     {
         Debug.Log("Back down");
         moveVertical -= 1f;
     }
     if (isBack.GetStateUp(hand.handType))
     {
         Debug.Log("Forward up");
         moveVertical += 1f;
     }
 }
Exemplo n.º 14
0
 public void HoldOpenReleaseUpdate(CustomHand hand)
 {
     if (UpperButtonClick.GetStateUp(hand.handType))
     {
         holdOpenReleaseClick = false;
     }
     if (!holdOpenReleaseClick && UpperButtonClick.GetStateDown(hand.handType))
     {
         manualReload.enabled  = true;
         manualReload.holdOpen = false;
         holdOpenReleaseClick  = true;
     }
 }
Exemplo n.º 15
0
 private void UpdateButton()
 {
     if (trigger.GetStateDown(handType))
     {
         moving = true;
     }
     if (trigger.GetStateUp(handType))
     {
         moving          = false;
         lastLocation[0] = Vector3.zero;
         lastLocation[1] = Vector3.zero;
     }
 }
Exemplo n.º 16
0
 // Update is called once per frame
 void Update()
 {
     if (FireAction.GetStateDown(handType))
     {
         Debug.Log("Fire Button Pressed from controller");
         gun.Fire();
     }
     if (Input.GetKeyDown("space"))
     {
         Debug.Log("Fire Button Pressed from spacebar");
         gun.Fire();
     }
 }
Exemplo n.º 17
0
    // Update is called once per frame
    void Update()
    {
        Physics.Raycast(m_Pose.poseAction.localPosition, Vector3.forward, out hit, 15f);

        if (hit.collider.gameObject.tag == "VRUI")
        {
            if (m_GrabAction.GetStateDown(m_Pose.inputSource))
            {
                print(m_Skeleton.inputSource + "Trigger Down");
                //hit.collider.gameObject.GetComponent<Button>().
            }
        }
    }
Exemplo n.º 18
0
 // when the grip is pressed/released enable/disable the laser
 void onGrab(SteamVR_Action_In actionIn)
 {
     if (GrabAction.GetStateDown(hand.handType))
     {
         l.Destroy();
         showLine = false;
     }
     if (GrabAction.GetStateUp(hand.handType))
     {
         l        = new LineDrawer();
         showLine = true;
     }
 }
 // Update is called once per frame
 void Update()
 {
     if (PullOutAction.GetStateDown(SteamVR_Input_Sources.RightHand))
     {
         //Vector3 target = (Vector3.forward * 50f);
         //RightController.transform.position = Vector3.SmoothDamp(transform.position, target, ref velocity, smoothTime);
         RightController.transform.Translate(Vector3.forward * 2f);
     }
     if (PullInAction.GetStateDown(SteamVR_Input_Sources.RightHand))
     {
         RightController.transform.position = originalRight;
     }
 }
Exemplo n.º 20
0
    // Update is called once per frame
    void Update()
    {
        if (spawnMode == WFSpawnMode.Editor && button1Press.GetStateDown(leftOrRightHand))
        {
            Debug.Log("Spawn Wifi Pressed");
            var latLongAlt = Api.Instance.SpacesApi.WorldToGeographicPoint(player.transform.position);

            var wifi = Instantiate(spawnWifiObj) as GameObject;
            wifi.GetComponent <GeographicTransform>().SetPosition(latLongAlt.GetLatLong());
            wifi.GetComponent <GeographicTransform>().SetElevation(latLongAlt.GetAltitude());

            var marker = wifi.GetComponent <WifiMarker>();
            marker.markerData.Latitude  = (float)latLongAlt.GetLatitude();
            marker.markerData.Longitude = (float)latLongAlt.GetLongitude();
            marker.markerData.Altitude  = (float)latLongAlt.GetAltitude();
            marker.markerData.name      = "marker " + wifiMarkers.Count;

            marker.EnabledWifiSignaler();
            marker.SetTextName();

            wifiMarkers.Add(marker);
            dataStore.markerData.Add(marker.markerData);
            //Api.Instance.SetOriginPoint(latLongAlt);
        }


        if (spawnMode == WFSpawnMode.Auto && button1Press.GetStateDown(leftOrRightHand))
        {
            var latLongAlt = Api.Instance.SpacesApi.WorldToGeographicPoint(player.transform.position);
            var genMarker  = Instantiate(spawnGenericMarker) as GameObject;
            genMarker.GetComponent <GeographicTransform>().SetPosition(latLongAlt.GetLatLong());
            genMarker.GetComponent <GeographicTransform>().SetElevation(latLongAlt.GetAltitude());
        }

        if (button2Press.GetStateDown(leftOrRightHand))
        {
            foreach (var marker in wifiMarkers)
            {
                markersEnabled = !markersEnabled;

                if (markersEnabled)
                {
                    marker.EnabledWifiSignaler();
                }
                else
                {
                    marker.DisableWifiSignaler();
                }
            }
        }
    }
Exemplo n.º 21
0
    void CheckInputs()
    {
        VRTriggerInputLeft = StrafeLeftInput.GetAxis(LeftHand.handType);

        VRTriggerInputRight = StrafeRightInput.GetAxis(RightHand.handType);

        if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.Joystick1Button1) ||
            BoostInput.GetStateDown(RightHand.handType) && leftThrustCurrent > 0)
        {
            boostPressed = true;
        }

        if (Input.GetKeyUp(KeyCode.W) || Input.GetKeyUp(KeyCode.Joystick1Button1) ||
            BoostInput.GetStateUp(RightHand.handType))
        {
            boostPressed = false;
        }

        horizontalInputKB = Input.GetAxis("Horizontal");

        if (Input.GetJoystickNames().Length > 2)
        {
            horizontalInputJS = Input.GetAxis("HorizontalStick");

            if (Input.GetAxis("L2") == -1f)
            {
                L2state = 0f;
            }
            else if (Input.GetAxis("L2") < 0)
            {
                L2state = (1f - Mathf.Abs(Input.GetAxis("L2"))) / 2;
            }
            else
            {
                L2state = (1f + Input.GetAxis("L2")) / 2;
            }

            if (Input.GetAxis("R2") == -1f)
            {
                R2state = 0f;
            }
            else if (Input.GetAxis("R2") < 0)
            {
                R2state = (1f - Mathf.Abs(Input.GetAxis("R2"))) / 2;
            }
            else
            {
                R2state = (1f + Input.GetAxis("R2")) / 2;
            }
        }
    }
Exemplo n.º 22
0
    public void customUpdate(CustomHand hand)
    {
        if (triggerClick.GetStateUp(hand.handType))
        {
            isClick = false;
        }
        switch (typeShoot)
        {
        case TypeShoot.Semi:

            if (!isClick && triggerClick.GetStateDown(hand.handType))
            {
                if (manualReload.typeReload == ManualReload.TypeReload.Revolver)
                {
                    manualReload.RevolverNextBullet();
                }
                if (manualReload.reloadFinish && primitiveWeapon.Shoot())
                {
                    isClick = true;
                    if (manualReload.typeReload == ManualReload.TypeReload.Slider)
                    {
                        manualReload.enabled = true;
                    }
                }
            }
            break;

        case TypeShoot.Automatic:
            if (triggerClick.GetState(hand.handType) && manualReload.reloadFinish && primitiveWeapon.Shoot())
            {
                if (manualReload.typeReload == ManualReload.TypeReload.Slider)
                {
                    manualReload.enabled = true;
                }
            }
            break;

        default:
            break;
        }

        Axis = triggerAxis.GetAxis(hand.handType);

        transform.localEulerAngles = new Vector3(Mathf.Lerp(angle.x, angle.y, Axis), 0);


        if (manualReload.typeReload == ManualReload.TypeReload.Revolver)
        {
            manualReload.CustomRevolverUpdate();
        }
    }
Exemplo n.º 23
0
    // Update is called once per frame
    void Update()
    {
        if (Trigger.GetStateDown(HandType))
        {
            Debug.Log("Pull Trigger Down");

            if (roomba.open)
            {
                roomba.MoveForward();
            }
        }
        else if (Trigger.GetStateUp(HandType))
        {
            Debug.Log("Pull Trigger Up");

            if (roomba.open)
            {
                roomba.Stop();
            }
        }
        else if (Trigger.GetState(HandType))
        {
            Debug.Log("Pull Trigger");
            HapticAction.Execute(1, 0, 100, 75, HandType);
        }
        else if (Grip.GetStateUp(HandType))
        {
            Debug.Log("Grip");

            if (roomba.open)
            {
                roomba.MoveBack();
            }
        }
        else if (TrackPad.GetStateUp(HandType))
        {
            Debug.Log("Click TrackPad");

            if (roomba.open)
            {
                roomba.Stop();
            }
        }

        /*
         * Debug.Log(VC.GetMovingVector().magnitude*1000);
         *
         * inputSpeed = (int)VC.GetVelosityMagnitude();
         * outputSpeed = (int)(inputSpeed * CDratio);
         */
    }
Exemplo n.º 24
0
 // Update is called once per frame
 void Update()
 {
     if (trackingObj)
     {
         if (placeButton.GetStateDown(InputMan.rightHand))
         {
             StartCoroutine(ClearTrackingObject());
         }
         else
         {
             ToggleGridSnap();
             ToggleRotationSnap();
             RaycastHit hit;
             Ray        ray      = new Ray(hand.position, hand.forward);
             Vector3    placePos = hand.transform.forward * 5;
             if (snappingPosition)
             {
                 if (Physics.Raycast(ray, out hit, 1000, snapMask))
                 {
                     placePos = hit.transform.position;
                     trackingObj.transform.position = placePos;
                 }
             }
             else
             {
                 if (Physics.Raycast(ray, out hit, 1000, nonSnapMask))
                 {
                     placePos = hit.point;
                     trackingObj.transform.position = placePos;
                 }
             }
             float rotateAmount = rotateButton.GetAxis(InputMan.rightHand).x;
             if (snappingRotation)
             {
                 if (rotatePress.GetStateDown(InputMan.rightHand))
                 {
                     rotateAmount  = Mathf.RoundToInt(rotateAmount);
                     rotateAmount *= rotateTurnAmount;
                     trackingObj.transform.Rotate(new Vector3(0, rotateAmount, 0));
                 }
             }
             else
             {
                 if (rotatePress.GetState(InputMan.rightHand))
                 {
                     trackingObj.transform.Rotate(new Vector3(0, rotateAmount, 0));
                 }
             }
         }
     }
 }
Exemplo n.º 25
0
 public override void Process()
 {
     base.Process();
     // Press
     if (m_Click.GetStateDown(m_Source))
     {
         Press();
     }
     // Release
     if (m_Click.GetStateUp(m_Source))
     {
         Release();
     }
 }
Exemplo n.º 26
0
 private void Update()
 {
     if (grabAction.GetStateDown(SteamVR_Input_Sources.Any))
     {
         if (sequenceEnded)
         {
             CreateRandomSequence(sequenceLength + 1);
         }
         else
         {
             CreateRandomSequence(sequenceLength);
         }
     }
 }
Exemplo n.º 27
0
 //달리기
 private void Run()
 {
     if (grip.GetStateDown(leftHand) && isWalk)
     {
         isWalk = false;
         isRun  = true;
         speed  = runSpeed;
     }
     else if (grip.GetStateUp(leftHand))
     {
         isRun = false;
         speed = walkSpeed;
     }
 }
Exemplo n.º 28
0
    void Update()
    {
        if (xButton.GetStateDown(SteamVR_Input_Sources.LeftHand))
        {
            metro.transform.localPosition    = transform.localPosition + transform.forward * 0.5f;
            metro.transform.localEulerAngles = transform.localEulerAngles;
        }

        if (yButton.GetStateDown(SteamVR_Input_Sources.LeftHand))
        {
            recorderGroup.transform.localPosition    = transform.localPosition + transform.forward * 0.5f;
            recorderGroup.transform.localEulerAngles = transform.localEulerAngles;
        }
    }
Exemplo n.º 29
0
    public bool Shoot()
    {
        if (_fireAction.GetStateDown(_pose.inputSource) && Time.time > nextFire)
        {
            gunShot.Play();

            Debug.Log("Parent Forward Vector: " + Parent.transform.forward);
            nextFire = Time.time + firerate;

            StartCoroutine(FireEffect());

            RaycastHit hit  = new RaycastHit();
            Ray        shot = new Ray(Barrel.transform.position, Parent.transform.forward);
            laser.SetPosition(0, Barrel.transform.position);

            if (Physics.Raycast(shot, out hit, laserRange))
            {
                laser.SetPosition(1, hit.point);

                if (hit.collider.tag == "Enemy")
                {
                    if (hit.collider.gameObject.layer == LayerMask.NameToLayer("GoldRegi"))
                    {
                        Destroy(hit.transform.gameObject);
                    }
                    else
                    {
                        hit.transform.gameObject.GetComponent <AgentHealth>().DoDamage(1);
                    }
                }
                else if (hit.collider.tag == "PowerUp")
                {
                    Destroy(hit.transform.gameObject);
                }
                else if (hit.collider.tag == "MenuItem")
                {
                    hit.transform.gameObject.GetComponent <IMenuItem>().Activate();
                }
            }
            else
            {
                laser.SetPosition(1, Barrel.transform.position + (laserRange * Parent.transform.forward));
            }
            return(true);
        }



        return(false);
    }
Exemplo n.º 30
0
 protected bool IsClench()
 {
     if (Interactable.attachedToHand)
     {
         var hand      = Interactable.attachedToHand.handType;
         var GripPinch = GrabPinch.GetStateDown(hand) && GrabGrip.GetState(hand);
         var PinchGrip = GrabPinch.GetState(hand) && GrabGrip.GetStateDown(hand);
         if (GripPinch || PinchGrip)
         {
             return(true);
         }
     }
     return(false);
 }