void OnTriggerEnter(Collider col)
    {
        Debug.Log(col.gameObject.tag + " , " + col.gameObject.name + " , " + (col.gameObject.GetComponent <SteamVR_TrackedObject>() ? "attached" : "missing script"));
        if (col.gameObject.GetComponent <SteamVR_TrackedObject>())
        {
            SteamVR_TrackedObject     trackedObject = col.gameObject.GetComponent <SteamVR_TrackedObject>();
            SteamVR_Controller.Device controller    = SteamVR_Controller.Input((int)trackedObject.index);

            Debug.Log(controller.GetState().ulButtonPressed + " , " + controller.GetPressDown(EVRButtonId.k_EButton_SteamVR_Trigger) + " , " + controller.GetPress(EVRButtonId.k_EButton_SteamVR_Trigger));
        }

        if (col.gameObject.tag == "Player" && col.gameObject.GetComponent <SteamVR_TrackedObject>())
        {
            SteamVR_TrackedObject trackedObject = col.gameObject.GetComponent <SteamVR_TrackedObject>();

            SteamVR_Controller.Device controller = SteamVR_Controller.Input((int)trackedObject.index);

            if (controller.GetPress(EVRButtonId.k_EButton_SteamVR_Trigger))
            {
                doorOpen = true;
                DoorsAnim("Openning");
            }
        }

        //if (col.gameObject.tag == "Player" && triggerButtonDown)
        //{
        //    doorOpen = true;
        //    DoorsAnim("Openning");
        //}
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        SteamVR_Controller.Device device = SteamVR_Controller.Input((int)wand.index);
        if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
        {
            Vector3 vel1  = transform.position - wand.transform.position;
            float   lVel1 = vel1.magnitude;
            vel1.Normalize();

            Vector3 vel  = device.velocity;
            float   lVel = vel.magnitude;
            float   dot  = Vector3.Dot(vel, vel1);

            float triggerPress = device.GetState().rAxis1.x;              //get how much trigger is pressed!

            vel1 = -1f * triggerPress * vel1 * lVel * (-dot + 1);
            ball.AddForce(vel1);
            SpringJoint j = GetComponent <SpringJoint>();
            j.spring = 1 * triggerPress;
        }
        else
        {
            SpringJoint j = GetComponent <SpringJoint>();
            j.spring = 0;
        }
        line.SetPosition(0, transform.position);
        line.SetPosition(1, wand.transform.position);
    }
    private void QueryControllers()
    {
        hasHandTriggerBeenPressed  = false;
        hasHandTriggerBeenReleased = false;

        if (isVRPlayer)
        {
            //handTriggerVal = handDevice.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger) ? 1f : 0;
            handTriggerVal = handDevice.GetState().rAxis1.x;
            Debug.Log("HTRIGGER: " + handTriggerVal);
            //shieldTriggerVal = shieldDevice.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger) ? 1f : 0;
            shieldTriggerVal = shieldDevice.GetState().rAxis1.x;
        }
        else
        {
            handTriggerVal   = Input.GetKey(KeyCode.Space) ? 1f : 0f;
            shieldTriggerVal = Input.GetKey(KeyCode.LeftShift) ? 1f : 0f;
        }

        if (!isHandTriggerPressed)
        {
            if (handTriggerVal > 0)
            {
                isHandTriggerPressed      = true;
                hasHandTriggerBeenPressed = true;
            }
        }
        else
        {
            if (handTriggerVal <= 0)
            {
                isHandTriggerPressed       = false;
                hasHandTriggerBeenReleased = true;
            }
        }
    }
Beispiel #4
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (cont == null)//set controller
        {
            cont = GetComponentInParent <Hand>().controller;
        }
        else
        {
            if (speedImmune > 0)
            {
                speedImmune--;
            }
            if (punchBuffer > 0)
            {
                punchBuffer--;
            }
            if (cont.GetHairTriggerDown())
            {
                punchBuffer = punchWaiter + 1;
            }
            if (cont.GetPressDown(Valve.VR.EVRButtonId.k_EButton_Axis0))
            {
                lFist = null;
                rFist = null;
            }


            if (lFist == null || reSync)
            {
                if (cont == SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.FarthestLeft)))
                {
                    lFist = this;
                }
                if (cont == SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.FarthestRight)))
                {
                    rFist = lFist;
                    rFist = this;
                }
            }
            if (rFist == null || reSync)
            {
                if (cont == SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.FarthestRight)))
                {
                    rFist = this;
                }
                if (cont == SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.FarthestLeft)))
                {
                    lFist = rFist;
                    lFist = this;
                }
            }
            if (rFist == this)
            {// right fist stuff
                if (speedImmune > 0)
                {
                    speedImmune--;
                }


                if (cont.GetState().rAxis0.x >= .1f || cont.GetState().rAxis0.x <= -.1f)//rotate here
                {
                    rigidScript.Rig3D.transform.Rotate(new Vector3(0, 1, 0), cont.GetState().rAxis0.x * 2f);
                }
                transform.GetChild(0).localScale = new Vector3(-50, -50, 50);//boxing glove scale
            }
            else
            {
                //setup for movement
                Vector3 ovel = rigidScript.Rig3D.velocity;
                Vector3 vel  = rigidScript.Rig3D.velocity;
                Vector2 axis = new Vector3(cont.GetState().rAxis0.x, cont.GetState().rAxis0.y);

                float y = vel.y;
                ovel.y = 0;
                vel.y  = 0;

                if (GroundScript.OnGround)
                {
                    if (axis.sqrMagnitude > .01f)
                    {
                        rigidScript.Rig3D.useGravity = false;
                        if (axis.x < 0)     //left
                        {
                            if (axis.y < 0) //backwards
                            {
                                vel += Vector3.ClampMagnitude(GroundScript.Back.normalized * Mathf.Abs(axis.y) + GroundScript.Left.normalized * Mathf.Abs(axis.x), (GroundScript.OnGround) ? Acceleration : .08f) * axis.magnitude;
                            }
                            else//forwards
                            {
                                vel += Vector3.ClampMagnitude(GroundScript.Forward.normalized * Mathf.Abs(axis.y) + GroundScript.Left.normalized * Mathf.Abs(axis.x), (GroundScript.OnGround) ? Acceleration : .08f) * axis.magnitude;
                            }
                        }
                        else//right
                        {
                            if (axis.y < 0)//backwards
                            {
                                vel += Vector3.ClampMagnitude(GroundScript.Back.normalized * Mathf.Abs(axis.y) + GroundScript.Right.normalized * Mathf.Abs(axis.x), (GroundScript.OnGround) ? Acceleration : .08f) * axis.magnitude;
                            }
                            else//forwards
                            {
                                vel += Vector3.ClampMagnitude(GroundScript.Forward.normalized * Mathf.Abs(axis.y) + GroundScript.Right.normalized * Mathf.Abs(axis.x), (GroundScript.OnGround) ? Acceleration : .08f) * axis.magnitude;
                            }
                        }
                    }
                    else
                    {
                        rigidScript.Rig3D.useGravity = true;
                    }
                }
                else
                {
                    vel += Vector3.ClampMagnitude(Head.lookDir * axis.y + Head.rightDir * axis.x, (GroundScript.OnGround) ? Acceleration : .12f) * axis.magnitude;

                    vel += Vector3.ClampMagnitude(Head.lookDir * axis.y + Head.rightDir * axis.x, (GroundScript.OnGround) ? Acceleration : .12f) * axis.magnitude;
                }
                if (vel.magnitude > MoveSpeed * axis.sqrMagnitude && ovel.magnitude > vel.magnitude)
                {
                    //this is where we move
                    vel.y = y;

                    if (GroundScript.OnGround)
                    {
                        rigidScript.Rig3D.velocity = vel * .9f;//NOW WITH 10 PERCENT TIGHTER TURNS
                    }
                }
                else if (Vector3.Dot(axis, vel) > MoveSpeed)
                {
                    //this is so we dont break velocity cap
                }
                else
                {
                    //this is also a valid move condiditon
                    vel.y = y;

                    rigidScript.Rig3D.velocity = vel;
                }
                transform.GetChild(0).localScale = new Vector3(-50, -50, -50);//fist scale
            }



            if (punchTimer > 0)//this is where we set the fists ideal location to the punch destination
            {
                idealPoint = new Vector3(0, -maxDist / 2, -.065f + maxDist / 2);
                punchTimer--;
                punchWaiter = 20;
            }
            else
            {
                if (punchWaiter > 0)//this is where we wait to punch
                {
                    punchWaiter--;
                    if (transform.localPosition == idealPoint && punchWaiter < 19)
                    {
                        punchWaiter = 0;
                    }
                }
                else if (punchBuffer > 0)//this is where we punch
                {
                    canLaunch  = true;
                    punchTimer = 20;
                    if (whoosh != null)
                    {
                        whoosh.pitch = Random.Range(0.8f, 1.2f); // randomizes pitch
                        whoosh.Play();                           // plays whoosh sound when punch
                    }
                }
                idealPoint = new Vector3(0, 0, -.065f);
            }



            transform.localPosition = transform.localPosition + Vector3.ClampMagnitude(idealPoint - transform.localPosition, maxSpeed);

            if (cont.GetPress(Valve.VR.EVRButtonId.k_EButton_Grip) && Physics.Raycast(transform.position - (transform.forward - transform.up).normalized * .1f, transform.forward - transform.up, maxDist))
            {
                for (int i = 0; i < transform.childCount; i++)
                {
                    if (transform.GetChild(i).CompareTag("Projection"))
                    {
                        transform.GetChild(i).gameObject.SetActive(true);
                    }
                }
            }
            else
            {
                for (int i = 0; i < transform.childCount; i++)
                {
                    if (transform.GetChild(i).CompareTag("Projection"))
                    {
                        transform.GetChild(i).gameObject.SetActive(false);
                    }
                }
            }
            if (cont.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis1).x > .01 && Physics.Raycast(transform.position - (transform.forward - transform.up).normalized * .1f, transform.forward - transform.up, out info, .4f))
            {
                if (info.transform.tag == "playButton")
                {
                    Scene currentScene = SceneManager.GetActiveScene();
                    SceneManager.LoadScene((currentScene.buildIndex + 1) % SceneManager.sceneCountInBuildSettings);
                }
                if (info.transform.tag == "Enemy")
                {
                    Destroy(info.transform.gameObject);
                }
                if (info.transform.tag == "Missile")
                {
                    Destroy(info.transform.gameObject);
                }
                if (info.transform.tag != "Boost" && info.transform.tag != "enemy" && info.transform.name != "Player" && canLaunch)
                {
                    canLaunch = false;
                    cont.TriggerHapticPulse(3000, Valve.VR.EVRButtonId.k_EButton_Axis4);
                    Vector3 vel = rigidScript.Rig3D.velocity;
                    vel.y = 0;
                    if ((vel + ((transform.forward - transform.up).normalized * -.3f / Time.deltaTime * .55f)).magnitude < vel.magnitude)
                    {
                        vel += ((transform.forward - transform.up).normalized * -.3f / Time.deltaTime * .55f) * 2;
                    }
                    else
                    {
                        vel += ((transform.forward - transform.up).normalized * -.3f / Time.deltaTime * .55f);
                    }

                    punchTimer = 0;
                    rigidScript.Rig3D.velocity = vel;
                    if (info.collider.gameObject.tag == "Pillar")
                    {
                        rigidScript.Rig3D.AddForce(((transform.forward - transform.up).normalized * -.3f / Time.deltaTime * 800f * 2));
                    }

                    if (punch != null)
                    {
                        punch.pitch = Random.Range(0.8f, 1.2f);
                        punch.Play();
                    }
                }
            }
        }
        if (speedImmune > 0)
        {
            rigidScript.Rig3D.velocity = Vector3.ClampMagnitude(rigidScript.Rig3D.velocity, 25 * speedImmune * speedImmune);
        }
        else
        {
            rigidScript.Rig3D.velocity = Vector3.ClampMagnitude(rigidScript.Rig3D.velocity, 25);
        }

        prevLocalPos = transform.localPosition;
        prevpos      = transform.position;

        ////////////Wind Sounds///////////
        if (wind != null)
        {
            if (GroundScript.OnGround)
            {
                wind.volume -= 0.5f * Time.deltaTime; // fade out
            }

            else if (rigidScript.Rig3D.velocity.magnitude != 0)
            {
                wind.volume = (rigidScript.Rig3D.velocity.magnitude / 25); // wind volume depends on velocity
            }


            else
            {
                wind.volume -= 0.2f * Time.deltaTime; // fade out
            }
        }
        /////////Footstep Sounds/////////
        if (foot1 != null)
        {
            int num = Random.Range(1, 3);
            if (GroundScript.OnGround && rigidScript.Rig3D.velocity.magnitude > 1.0f && rigidScript.Rig3D.velocity.magnitude < 5.0f && timeForSteps > 50.0f) // walking speed
            {
                foot1.pitch = Random.Range(0.8f, 1.2f);
                foot1.Play();
                timeForSteps = 0;
            }

            else if (GroundScript.OnGround && rigidScript.Rig3D.velocity.magnitude >= 5.0f && timeForSteps > 25.0f) // running speed
            {
                foot1.pitch = Random.Range(0.8f, 1.2f);
                foot1.Play();
                timeForSteps = 0;
            }
            timeForSteps++;
        }
        //////////Landing Sound///////////
        if (wind != null)
        {
            if (GroundScript.OnGround == false)
            {
                wasInAir = true;
            }

            if (GroundScript.OnGround == true && wasInAir == true)
            {
                landing.Play();
                wasInAir = false;
            }
        }
    }
Beispiel #5
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (Global.mode == 1 && Global.isTips == 0)
        {
            if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad) && Global.MenuState == 0)
            {
                float xx = device.GetState().rAxis0.x;
                float yy = device.GetState().rAxis0.y;
                Debug.Log(xx + "," + yy);
                if (xx < 1 && xx > 0.5 && yy < 0.5 && yy > -0.5)
                {
                    selectState = selectState + 1;
                    if ((selectState % 6) == 0)
                    {
                        Destroy(spawnObj);
                        spawnObj = createTriangle();
                    }
                    else if ((selectState % 6) == 1)
                    {
                        Destroy(spawnObj);
                        spawnObj = createFourAngle();
                    }
                    else if ((selectState % 6) == 2)
                    {
                        Destroy(spawnObj);
                        spawnObj = createFiveAngle();
                    }
                    else if ((selectState % 6) == 3)
                    {
                        Destroy(spawnObj);
                        spawnObj = createSixAngle();
                    }
                    else if ((selectState % 6) == 4)
                    {
                        Destroy(spawnObj);
                        spawnObj = createEightAngle();
                    }
                    else if ((selectState % 6) == 5)
                    {
                        Destroy(spawnObj);
                        spawnObj = createSixteenAngle();
                    }
                }
                else if (xx < -0.5 && xx > -1 && yy < 0.5 && yy > -0.5)
                {
                    if (selectState == 0)
                    {
                        selectState = 4;
                    }
                    selectState = selectState - 1;
                    if ((selectState % 6) == 0)
                    {
                        Destroy(spawnObj);
                        spawnObj = createTriangle();
                    }
                    else if ((selectState % 6) == 1)
                    {
                        Destroy(spawnObj);
                        spawnObj = createFourAngle();
                    }
                    else if ((selectState % 6) == 2)
                    {
                        Destroy(spawnObj);
                        spawnObj = createFiveAngle();
                    }
                    else if ((selectState % 6) == 3)
                    {
                        Destroy(spawnObj);
                        spawnObj = createSixAngle();
                    }
                    else if ((selectState % 6) == 4)
                    {
                        Destroy(spawnObj);
                        spawnObj = createEightAngle();
                    }
                    else if ((selectState % 6) == 5)
                    {
                        Destroy(spawnObj);
                        spawnObj = createSixteenAngle();
                    }
                }
                if (xx < 0.5 && xx > -0.5 && yy < 1 && yy > 0.5)
                {
                    SacleIncrease();
                }
                if (xx < 0.5 && xx > -0.5 && yy < -0.5 && yy > -1)
                {
                    SacleDecrease();
                }
            }

            if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger) && Global.MenuState == 0)
            {
                if (deviceleft.GetPress(SteamVR_Controller.ButtonMask.Trigger))
                {
                    if (spawnObj != null)
                    {
                        combinenum++;
                        if (combinenum == 1)
                        {
                            Obj            = NewObject(spawnObj);
                            origntransform = Obj.transform;
                            Obj.GetComponent <FaceEditor>().connectPoionts(spawnObj);
                        }
                        else if (combinenum > 1)
                        {
                            Obj.GetComponent <FaceEditor>().disConnectPoints(spawnObj);
                            Obj = NewObject(spawnObj);
                            Obj.transform.parent = origntransform.transform;
                            Obj.GetComponent <FaceEditor>().connectPoionts(spawnObj);
                        }
                    }
                }
                else
                {
                    if (spawnObj != null)
                    {
                        if (iscreate == 0)
                        {
                            iscreate = 1;
                            Obj      = NewObject(spawnObj);
                            Obj.GetComponent <FaceEditor>().connectPoionts(spawnObj);
                        }
                        else if (iscreate == 1)
                        {
                            iscreate = 0;
                            if (Obj != null)
                            {
                                Obj.GetComponent <FaceEditor>().disConnectPoints(spawnObj);
                                Obj.AddComponent <MeshCollider>();
                                Obj.GetComponent <MeshCollider>().convex    = true;
                                Obj.GetComponent <MeshCollider>().isTrigger = true;
                            }
                        }
                    }
                }
            }
            if (deviceleft.GetPressUp(SteamVR_Controller.ButtonMask.Trigger))
            {
                combinenum = 0;
                Obj.GetComponent <FaceEditor>().disConnectPoints(spawnObj);
                Obj = CombineObject(origntransform.gameObject);
                Obj.AddComponent <MeshCollider>();
                Obj.GetComponent <MeshCollider>().convex    = true;
                Obj.GetComponent <MeshCollider>().isTrigger = true;
            }

            if (spawnObj != null)
            {
                FixedJoint fixedjoint = spawn.GetComponent <FixedJoint>();
                fixedjoint.connectedBody = spawnObj.GetComponent <Rigidbody>();
            }
        }
    }
Beispiel #6
0
 // Update is called once per frame
 void FixedUpdate()
 {
     if (Global.start > 0 && Global.isTips == 0)
     {
         if (Global.mode == -1)
         {
             toptips.gameObject.SetActive(false);
             bottomtips.gameObject.SetActive(false);
             lefttips.gameObject.SetActive(false);
             righttips.gameObject.SetActive(false);
         }
         else if (Global.mode == 0)
         {
             if (device.GetTouch(SteamVR_Controller.ButtonMask.Touchpad) && Global.MenuState == 0)
             {
                 float xx = device.GetState().rAxis0.x;
                 float yy = device.GetState().rAxis0.y;
                 if (xx < 1 && xx > 0.5 && yy < 0.5 && yy > -0.5)
                 {
                     toptips.gameObject.SetActive(false);
                     bottomtips.gameObject.SetActive(false);
                     lefttips.gameObject.SetActive(false);
                     righttips.gameObject.SetActive(true);
                     righttips.gameObject.GetComponentInChildren <Text>().text = "向右变换物体";
                 }
                 else if (xx < -0.5 && xx > -1 && yy < 0.5 && yy > -0.5)
                 {
                     toptips.gameObject.SetActive(false);
                     bottomtips.gameObject.SetActive(false);
                     lefttips.gameObject.SetActive(true);
                     righttips.gameObject.SetActive(false);
                     lefttips.gameObject.GetComponentInChildren <Text>().text = "向左变换物体";
                 }
                 else if (xx < 0.5 && xx > -0.5 && yy < 1 && yy > 0.5)
                 {
                     toptips.gameObject.SetActive(true);
                     bottomtips.gameObject.SetActive(false);
                     lefttips.gameObject.SetActive(false);
                     righttips.gameObject.SetActive(false);
                     toptips.gameObject.GetComponentInChildren <Text>().text = "变大物体";
                 }
                 else if (xx < 0.5 && xx > -0.5 && yy < -0.5 && yy > -1)
                 {
                     toptips.gameObject.SetActive(false);
                     bottomtips.gameObject.SetActive(true);
                     lefttips.gameObject.SetActive(false);
                     righttips.gameObject.SetActive(false);
                     bottomtips.gameObject.GetComponentInChildren <Text>().text = "变小物体";
                 }
             }
         }
         else if (Global.mode == 1)
         {
             if (device.GetTouch(SteamVR_Controller.ButtonMask.Touchpad) && Global.MenuState == 0)
             {
                 float xx = device.GetState().rAxis0.x;
                 float yy = device.GetState().rAxis0.y;
                 if (xx < 1 && xx > 0.5 && yy < 0.5 && yy > -0.5)
                 {
                     toptips.gameObject.SetActive(false);
                     bottomtips.gameObject.SetActive(false);
                     lefttips.gameObject.SetActive(false);
                     righttips.gameObject.SetActive(true);
                     righttips.gameObject.GetComponentInChildren <Text>().text = "向右变换物体";
                 }
                 else if (xx < -0.5 && xx > -1 && yy < 0.5 && yy > -0.5)
                 {
                     toptips.gameObject.SetActive(false);
                     bottomtips.gameObject.SetActive(false);
                     lefttips.gameObject.SetActive(true);
                     righttips.gameObject.SetActive(false);
                     lefttips.gameObject.GetComponentInChildren <Text>().text = "向左变换物体";
                 }
                 else if (xx < 0.5 && xx > -0.5 && yy < 1 && yy > 0.5)
                 {
                     toptips.gameObject.SetActive(true);
                     bottomtips.gameObject.SetActive(false);
                     lefttips.gameObject.SetActive(false);
                     righttips.gameObject.SetActive(false);
                     toptips.gameObject.GetComponentInChildren <Text>().text = "变大物体";
                 }
                 else if (xx < 0.5 && xx > -0.5 && yy < -0.5 && yy > -1)
                 {
                     toptips.gameObject.SetActive(false);
                     bottomtips.gameObject.SetActive(true);
                     lefttips.gameObject.SetActive(false);
                     righttips.gameObject.SetActive(false);
                     bottomtips.gameObject.GetComponentInChildren <Text>().text = "变小物体";
                 }
             }
         }
         else if (Global.mode == 3)
         {
             if (device.GetTouch(SteamVR_Controller.ButtonMask.Touchpad) && Global.MenuState == 0)
             {
                 float xx = device.GetState().rAxis0.x;
                 float yy = device.GetState().rAxis0.y;
                 if (xx < 1 && xx > 0.5 && yy < 0.5 && yy > -0.5)
                 {
                     toptips.gameObject.SetActive(false);
                     bottomtips.gameObject.SetActive(false);
                     lefttips.gameObject.SetActive(false);
                     righttips.gameObject.SetActive(true);
                     righttips.gameObject.GetComponentInChildren <Text>().text = "复制物体";
                 }
                 else if (xx < -0.5 && xx > -1 && yy < 0.5 && yy > -0.5)
                 {
                     toptips.gameObject.SetActive(false);
                     bottomtips.gameObject.SetActive(false);
                     lefttips.gameObject.SetActive(true);
                     righttips.gameObject.SetActive(false);
                     lefttips.gameObject.GetComponentInChildren <Text>().text = "选择合并物体";
                 }
                 else if (xx < 0.5 && xx > -0.5 && yy < 1 && yy > 0.5)
                 {
                     toptips.gameObject.SetActive(true);
                     bottomtips.gameObject.SetActive(false);
                     lefttips.gameObject.SetActive(false);
                     righttips.gameObject.SetActive(false);
                     toptips.gameObject.GetComponentInChildren <Text>().text = "变大物体";
                 }
                 else if (xx < 0.5 && xx > -0.5 && yy < -0.5 && yy > -1)
                 {
                     toptips.gameObject.SetActive(false);
                     bottomtips.gameObject.SetActive(true);
                     lefttips.gameObject.SetActive(false);
                     righttips.gameObject.SetActive(false);
                     bottomtips.gameObject.GetComponentInChildren <Text>().text = "变小物体";
                 }
             }
         }
         if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
         {
             toptips.gameObject.SetActive(false);
             bottomtips.gameObject.SetActive(false);
             lefttips.gameObject.SetActive(false);
             righttips.gameObject.SetActive(false);
         }
     }
 }
Beispiel #7
0
 // Update is called once per frame
 void FixedUpdate()
 {
     if (Global.mode == 3 && Global.isTips == 0)
     {
         if (deviceleft.GetHairTrigger())
         {
             if (Global.handGripObj != null)
             {
                 if (!Global.selectObjDict.Contains(Global.handGripObj))
                 {
                     Global.selectObjDict.Add(Global.handGripObj);
                 }
                 foreach (GameObject g in Global.selectObjDict)
                 {
                     g.transform.parent = Global.handGripObj.transform;
                 }
                 if (device.GetHairTrigger())
                 {
                     FixedJoint fixedjoint = handjoint.GetComponent <FixedJoint>();
                     fixedjoint.connectedBody = Global.handGripObj.GetComponent <Rigidbody>();
                 }
                 if (device.GetHairTriggerUp())
                 {
                     FixedJoint fixedjoint = handjoint.GetComponent <FixedJoint>();
                     fixedjoint.connectedBody = null;
                 }
                 if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
                 {
                     float xx = device.GetState().rAxis0.x;
                     float yy = device.GetState().rAxis0.y;
                     if (xx < -0.5 && xx > -1 && yy < 0.5 && yy > -0.5)
                     {
                         Global.handGripObj.AddComponent <CombineMesh>();
                         Global.selectObjDict.Clear();
                     }
                 }
             }
             else
             {
                 foreach (GameObject g in Global.selectObjDict)
                 {
                     g.transform.parent = Global.sceneSet[Global.sceneSet.Count - 1].transform;
                 }
                 FixedJoint fixedjoint = handjoint.GetComponent <FixedJoint>();
                 fixedjoint.connectedBody = null;
             }
             foreach (GameObject g in Global.selectObjDict)
             {
                 g.GetComponent <Renderer>().material.color = new Color(200, 255, 0);
             }
         }
         else
         {
             foreach (GameObject g in Global.selectObjDict)
             {
                 g.GetComponent <Renderer>().material.color = new Color(255, 255, 255);
             }
             foreach (GameObject g in Global.selectObjDict)
             {
                 g.transform.parent = Global.sceneSet[Global.sceneSet.Count - 1].transform;
             }
             Global.selectObjDict.Clear();
             if (device.GetPress(SteamVR_Controller.ButtonMask.Trigger))
             {
                 if (Global.handGripObj != null)
                 {
                     FixedJoint fixedjoint = handjoint.GetComponent <FixedJoint>();
                     fixedjoint.connectedBody = Global.handGripObj.GetComponent <Rigidbody>();
                 }
                 else if (Global.handGripObj == null)
                 {
                     FixedJoint fixedjoint = handjoint.GetComponent <FixedJoint>();
                     fixedjoint.connectedBody = null;
                 }
             }
             if (device.GetPressUp(SteamVR_Controller.ButtonMask.Trigger))
             {
                 FixedJoint fixedjoint = handjoint.GetComponent <FixedJoint>();
                 fixedjoint.connectedBody = null;
             }
             if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
             {
                 float xx = device.GetState().rAxis0.x;
                 float yy = device.GetState().rAxis0.y;
                 // Debug.Log(xx+","+yy);
                 if (xx < 1 && xx > 0.5 && yy < 0.5 && yy > -0.5)
                 {
                     if (Global.handGripObj != null)
                     {
                         GameObject copyobj    = Copy(Global.handGripObj);
                         FixedJoint fixedjoint = handjoint.GetComponent <FixedJoint>();
                         fixedjoint.connectedBody = copyobj.GetComponent <Rigidbody>();
                     }
                     else if (Global.handGripObj == null)
                     {
                         FixedJoint fixedjoint = handjoint.GetComponent <FixedJoint>();
                         fixedjoint.connectedBody = null;
                     }
                 }
                 else if (xx < -0.5 && xx > -1 && yy < 0.5 && yy > -0.5)
                 {
                 }
                 if (xx < 0.5 && xx > -0.5 && yy < 1 && yy > 0.5)
                 {
                     SacleIncrease(Global.handGripObj);
                 }
                 if (xx < 0.5 && xx > -0.5 && yy < -0.5 && yy > -1)
                 {
                     SacleDecrease(Global.handGripObj);
                 }
             }
         }
     }
 }
Beispiel #8
0
    void Update()
    {
        if (cont != null)
        {
            if (heldItem != null)//held item stuff here
            {
                if (cont != null && cont.GetPressDown(Valve.VR.EVRButtonId.k_EButton_Grip) && grabTimer < 1)
                {
                    heldItem.transform.parent = null;
                    heldItem = null;
                }

                if (heldItem.GetComponent <Blaster>() != null)
                {
                    Blaster gun = heldItem.GetComponent <Blaster>();

                    if (cont.GetHairTrigger())
                    {
                        bool blasted = false;
                        for (int i = 0; i < heldItem.transform.childCount; i++)
                        {
                            if (heldItem.transform.GetChild(i).CompareTag("FirePoint"))
                            {
                                blasted = true;
                                gun.Blast(heldItem.transform.GetChild(i).transform.position, null, 100f);
                            }
                        }
                        if (!blasted)
                        {
                            gun.Blast(null, 100f);
                        }
                    }
                }
            }
            if (cont.Equals(SteamVR_Controller.DeviceRelation.Leftmost) && GroundScript.OnGround)//left hand stuff goes here
            {
                Rigidbody Rig3D = Scenemanager.Player.GetComponent <Rigidbody>();
                Vector3   ovel  = Rig3D.velocity;
                Vector3   vel   = Rig3D.velocity;
                Vector2   axis  = new Vector3(cont.GetState().rAxis0.x, cont.GetState().rAxis0.y);
                float     y     = vel.y;
                if (GroundScript.OnGround && cont.GetPressDown(Valve.VR.EVRButtonId.k_EButton_Dashboard_Back) && jumpTimer > 29)
                {
                    vel.y     = 5f;
                    jumpTimer = 0;
                }
                ovel.y = 0;
                vel.y  = 0;

                vel += Vector3.ClampMagnitude(Head.head.transform.forward * axis.y + Rig3D.transform.right * axis.x, .3f * axis.magnitude);
                if (vel.magnitude > 6f * axis.magnitude && ovel.magnitude > vel.magnitude)
                {
                    vel.y          = y;
                    Rig3D.velocity = vel;
                }
                else if (vel.magnitude > 6 * axis.magnitude)
                {
                }
                else
                {
                    vel.y          = y;
                    Rig3D.velocity = vel;
                }
            }
            if (cont.Equals(SteamVR_Controller.DeviceRelation.Rightmost))//right hand stuff here
            {
                Scenemanager.Player.transform.Rotate(new Vector3(0, 10, 0) * cont.GetState().rAxis0.x);
            }
        }
        else
        {
            cont = GetComponentInParent <Hand>().controller;
        }
    }
Beispiel #9
0
 // Update is called once per frame
 void FixedUpdate()
 {
     if (Global.mode == 0 && Global.isTips == 0)
     {
         if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad) && Global.MenuState == 0)
         {
             float xx = device.GetState().rAxis0.x;
             float yy = device.GetState().rAxis0.y;
             Debug.Log(xx + "," + yy);
             if (xx < 1 && xx > 0.5 && yy < 0.5 && yy > -0.5)
             {
                 selectState = selectState + 1;
                 if ((selectState % 4) == 0)
                 {
                     Destroy(spawnObj);
                     spawnObj = createCube();
                 }
                 else if ((selectState % 4) == 1)
                 {
                     Destroy(spawnObj);
                     spawnObj = createSphere();
                 }
                 else if ((selectState % 4) == 2)
                 {
                     Destroy(spawnObj);
                     spawnObj = createCylinder();
                 }
                 else if ((selectState % 4) == 3)
                 {
                     Destroy(spawnObj);
                     spawnObj = createTone();
                 }
             }
             else if (xx < -0.5 && xx > -1 && yy < 0.5 && yy > -0.5)
             {
                 if (selectState == 0)
                 {
                     selectState = 4;
                 }
                 selectState = selectState - 1;
                 if ((selectState % 4) == 0)
                 {
                     Destroy(spawnObj);
                     spawnObj = createCube();
                 }
                 else if ((selectState % 4) == 1)
                 {
                     Destroy(spawnObj);
                     spawnObj = createSphere();
                 }
                 else if ((selectState % 4) == 2)
                 {
                     Destroy(spawnObj);
                     spawnObj = createCylinder();
                 }
                 else if ((selectState % 4) == 3)
                 {
                     Destroy(spawnObj);
                     spawnObj = createTone();
                 }
             }
             else if (xx < 0.5 && xx > -0.5 && yy < 1 && yy > 0.5)
             {
                 SacleIncrease();
                 Debug.Log("2");
             }
             else if (xx < 0.5 && xx > -0.5 && yy < -0.5 && yy > -1)
             {
                 SacleDecrease();
                 Debug.Log("3");
             }
         }
         if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger) && Global.MenuState == 0)
         {
             if (spawnObj != null)
             {
                 Obj = NewObject(spawnObj);
             }
         }
         if (spawnObj != null)
         {
             FixedJoint fixedjoint = spawn.GetComponent <FixedJoint>();
             fixedjoint.connectedBody = spawnObj.GetComponent <Rigidbody>();
         }
     }
 }