Example #1
0
    protected virtual void Update()
    {
        if (useProfileData)
        {
            if (InitialPose == null)
            {
                // Save the initial pose so it can be recovered if useProfileData
                // is turned off later.
                InitialPose = new OVRPose()
                {
                    position    = CameraRig.transform.localPosition,
                    orientation = CameraRig.transform.localRotation
                };
            }

            var p = CameraRig.transform.localPosition;
            if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.EyeLevel)
            {
                p.y = OVRManager.profile.eyeHeight - (0.5f * Controller.height) + Controller.center.y;
            }
            else if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.FloorLevel)
            {
                p.y = -(0.5f * Controller.height) + Controller.center.y;
            }
            CameraRig.transform.localPosition = p;
        }
        else if (InitialPose != null)
        {
            // Return to the initial pose if useProfileData was turned off at runtime
            CameraRig.transform.localPosition = InitialPose.Value.position;
            CameraRig.transform.localRotation = InitialPose.Value.orientation;
            InitialPose = null;
        }
    }
Example #2
0
    protected virtual void Update()
    {
        if (useProfileHeight)
        {
            if (InitialPose == null)
            {
                InitialPose = new OVRPose()
                {
                    position    = CameraController.transform.localPosition,
                    orientation = CameraController.transform.localRotation
                };
            }

            var p = CameraController.transform.localPosition;
            p.y = OVRManager.profile.eyeHeight - 0.5f * Controller.height;
            p.z = OVRManager.profile.eyeDepth;
            CameraController.transform.localPosition = p;
        }
        else if (InitialPose != null)
        {
            CameraController.transform.localPosition = InitialPose.Value.position;
            CameraController.transform.localRotation = InitialPose.Value.orientation;
            InitialPose = null;
        }

        UpdateMultiFrame();        //get kinect data

        UpdateMovement();          //get keyboard input


        Vector3 moveDirection = Vector3.zero;

        float motorDamp = (1.0f + (Damping * SimulationRate * Time.deltaTime));

        MoveThrottle.x /= motorDamp;
        MoveThrottle.y /= motorDamp;
        MoveThrottle.z /= motorDamp;

        moveDirection += MoveThrottle * SimulationRate * Time.deltaTime;

        Vector3 predictedXZ = Vector3.Scale((Controller.transform.localPosition + moveDirection), new Vector3(1, 0, 1));

        // Move contoller
        Controller.Move(moveDirection);

        Vector3 actualXZ = Vector3.Scale(Controller.transform.localPosition, new Vector3(1, 0, 1));

        if (predictedXZ != actualXZ)
        {
            MoveThrottle += (actualXZ - predictedXZ) / (SimulationRate * Time.deltaTime);
        }
    }
    // Update is called once per frame
    void Update()
    {
        float playerHeight = 0.0f;

        if (deviceController != null)
        {
            CVirtDevice virtDevice = deviceController.GetDevice();
            if (virtDevice != null)
            {
                // Get Virtualizer raw inputs
                /////////////////////////////
                Vector3 virtOrientation = virtDevice.GetPlayerOrientation();
                float   virtHeight      = virtDevice.GetPlayerHeight();
                Vector3 virtDirection   = virtDevice.GetMovementDirection();
                float   virtSpeed       = virtDevice.GetMovementSpeed();

                // Turn
                ///////
                Quaternion rotation = new Quaternion();
                rotation.SetLookRotation(virtOrientation, Vector3.up);
                forwardDirection.localRotation = rotation;

                // Hip Height
                /////////
                playerHeight = virtHeight / 100.0f;

                // Move Character
                /////////////////
                if (virtSpeed != 0.0f)
                {
                    virtSpeed = virtSpeed * movementSpeedMultiplier;

                    if (characterController != null)
                    {
                        this.characterController.SimpleMove((forwardDirection.TransformDirection(virtDirection)).normalized * virtSpeed);
                    }
                }
            }
        }

        if (useProfileHeight)
        {
            if (initialPose == null)
            {
                initialPose = new OVRPose()
                {
                    position    = cameraController.transform.localPosition,
                    orientation = cameraController.transform.localRotation
                };
            }

            var p = cameraController.transform.localPosition;
            p.y = (OVRManager.profile.eyeHeight - 0.5f * characterController.height) + playerHeight;
            p.z = OVRManager.profile.eyeDepth;
            cameraController.transform.localPosition = p;
        }
        else if (initialPose != null)
        {
            cameraController.transform.localPosition = initialPose.Value.position;
            cameraController.transform.localRotation = initialPose.Value.orientation;
            initialPose = null;
        }
    }
    protected virtual void Update()
    {
        if (useProfileData)
        {
            if (InitialPose == null)
            {
                // Save the initial pose so it can be recovered if useProfileData
                // is turned off later.
                InitialPose = new OVRPose()
                {
                    position = CameraRig.transform.localPosition,
                    orientation = CameraRig.transform.localRotation
                };
            }

            var p = CameraRig.transform.localPosition;
            p.y = OVRManager.profile.eyeHeight - 0.5f * Controller.height
                + Controller.center.y;
            CameraRig.transform.localPosition = p;
        }
        else if (InitialPose != null)
        {
            // Return to the initial pose if useProfileData was turned off at runtime
            CameraRig.transform.localPosition = InitialPose.Value.position;
            CameraRig.transform.localRotation = InitialPose.Value.orientation;
            InitialPose = null;
        }

        /*if (Input.GetKey (KeyCode.Space)) {
            Controller.attachedRigidbody.drag -= 0.1f;
        } else {
            if (Controller.attachedRigidbody.drag < 10f) {
                Controller.attachedRigidbody.drag += 0.1f;
            }
        }*/

        UpdateMovement();

        Vector3 moveDirection = Vector3.zero;

        float motorDamp = (1.0f + (Damping * SimulationRate * Time.deltaTime));

        MoveThrottle.x /= motorDamp;
        MoveThrottle.y = (MoveThrottle.y > 0.0f) ? (MoveThrottle.y / motorDamp) : MoveThrottle.y;
        MoveThrottle.z /= motorDamp;

        moveDirection += MoveThrottle * SimulationRate * Time.deltaTime;
        //moveDirection += Vector3.forward * TrackSpeedMult * Time.deltaTime;

        // Gravity
        if (Controller.isGrounded && FallSpeed <= 0)
            FallSpeed = ((Physics.gravity.y * (GravityModifier * 0.002f)));
        else
            FallSpeed += ((Physics.gravity.y * (GravityModifier * 0.002f)) * SimulationRate * Time.deltaTime);

        moveDirection.y += FallSpeed * SimulationRate * Time.deltaTime;

        // Offset correction for uneven ground
        float bumpUpOffset = 0.0f;

        if (Controller.isGrounded && MoveThrottle.y <= transform.lossyScale.y * 0.001f)
        {
            bumpUpOffset = Mathf.Max(Controller.stepOffset, new Vector3(moveDirection.x, 0, moveDirection.z).magnitude);
            moveDirection -= bumpUpOffset * Vector3.up;
        }

        Vector3 predictedXZ = Vector3.Scale((Controller.transform.localPosition + moveDirection), new Vector3(1, 0, 1));

        // Move controller
        moveDirection.x = 0;
        Controller.Move(moveDirection);

        Vector3 actualXZ = Vector3.Scale(Controller.transform.localPosition, new Vector3(1, 0, 1));
        actualXZ.x = fixedX;
        predictedXZ.x = fixedX;

        if (predictedXZ != actualXZ)
            MoveThrottle += (actualXZ - predictedXZ) / (SimulationRate * Time.deltaTime);

        Vector3 resetX = new Vector3 (fixedX, transform.position.y);
        resetX.z = transform.position.z;
        transform.position = resetX;
    }
Example #5
0
    // Token: 0x06003A16 RID: 14870 RVA: 0x00125684 File Offset: 0x00123A84
    protected virtual void Update()
    {
        if (this.useProfileData)
        {
            OVRPose?initialPose = this.InitialPose;
            if (initialPose == null)
            {
                this.InitialPose = new OVRPose?(new OVRPose
                {
                    position = this.CameraRig.transform.localPosition,
                    orientation = this.CameraRig.transform.localRotation
                });
            }
            Vector3 localPosition = this.CameraRig.transform.localPosition;
            if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.EyeLevel)
            {
                localPosition.y = OVRManager.profile.eyeHeight - 0.5f * this.Controller.height + this.Controller.center.y;
            }
            else if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.FloorLevel)
            {
                localPosition.y = -(0.5f * this.Controller.height) + this.Controller.center.y;
            }
            this.CameraRig.transform.localPosition = localPosition;
        }
        else
        {
            OVRPose?initialPose2 = this.InitialPose;
            if (initialPose2 != null)
            {
                this.CameraRig.transform.localPosition = this.InitialPose.Value.position;
                this.CameraRig.transform.localRotation = this.InitialPose.Value.orientation;
                this.InitialPose = null;
            }
        }
        this.UpdateMovement();
        Vector3 vector = Vector3.zero;
        float   num    = 1f + this.Damping * this.SimulationRate * Time.deltaTime;

        this.MoveThrottle.x = this.MoveThrottle.x / num;
        this.MoveThrottle.y = ((this.MoveThrottle.y <= 0f) ? this.MoveThrottle.y : (this.MoveThrottle.y / num));
        this.MoveThrottle.z = this.MoveThrottle.z / num;
        vector += this.MoveThrottle * this.SimulationRate * Time.deltaTime;
        if (this.Controller.isGrounded && this.FallSpeed <= 0f)
        {
            this.FallSpeed = Physics.gravity.y * (this.GravityModifier * 0.002f);
        }
        else
        {
            this.FallSpeed += Physics.gravity.y * (this.GravityModifier * 0.002f) * this.SimulationRate * Time.deltaTime;
        }
        vector.y += this.FallSpeed * this.SimulationRate * Time.deltaTime;
        if (this.Controller.isGrounded && this.MoveThrottle.y <= base.transform.lossyScale.y * 0.001f)
        {
            float   stepOffset = this.Controller.stepOffset;
            Vector3 vector2    = new Vector3(vector.x, 0f, vector.z);
            float   d          = Mathf.Max(stepOffset, vector2.magnitude);
            vector -= d * Vector3.up;
        }
        Vector3 vector3 = Vector3.Scale(this.Controller.transform.localPosition + vector, new Vector3(1f, 0f, 1f));

        this.Controller.Move(vector);
        Vector3 vector4 = Vector3.Scale(this.Controller.transform.localPosition, new Vector3(1f, 0f, 1f));

        if (vector3 != vector4)
        {
            this.MoveThrottle += (vector4 - vector3) / (this.SimulationRate * Time.deltaTime);
        }
    }
    protected virtual void Update()
    {
        if (useProfileHeight)
        {
            if (InitialPose == null)
            {
                InitialPose = new OVRPose() {
                    position = CameraController.transform.localPosition,
                    orientation = CameraController.transform.localRotation
                };
            }

            var p = CameraController.transform.localPosition;
            p.y = OVRManager.profile.eyeHeight - 0.5f * Controller.height;
            p.z = OVRManager.profile.eyeDepth;
            CameraController.transform.localPosition = p;
        }
        else if (InitialPose != null)
        {
            CameraController.transform.localPosition = InitialPose.Value.position;
            CameraController.transform.localRotation = InitialPose.Value.orientation;
            InitialPose = null;
        }

        UpdateMovement();

        Vector3 moveDirection = Vector3.zero;

        float motorDamp = (1.0f + (Damping * SimulationRate * Time.deltaTime));

        MoveThrottle.x /= motorDamp;
        MoveThrottle.y = (MoveThrottle.y > 0.0f) ? (MoveThrottle.y / motorDamp) : MoveThrottle.y;
        MoveThrottle.z /= motorDamp;

        moveDirection += MoveThrottle * SimulationRate * Time.deltaTime;

        // Gravity
        if (Controller.isGrounded && FallSpeed <= 0)
            FallSpeed = ((Physics.gravity.y * (GravityModifier * 0.002f)));
        else
            FallSpeed += ((Physics.gravity.y * (GravityModifier * 0.002f)) * SimulationRate * Time.deltaTime);

        moveDirection.y += FallSpeed * SimulationRate * Time.deltaTime;

        // Offset correction for uneven ground
        float bumpUpOffset = 0.0f;

        if (Controller.isGrounded && MoveThrottle.y <= 0.001f)
        {
            bumpUpOffset = Mathf.Max(Controller.stepOffset, new Vector3(moveDirection.x, 0, moveDirection.z).magnitude);
            moveDirection -= bumpUpOffset * Vector3.up;
        }

        Vector3 predictedXZ = Vector3.Scale((Controller.transform.localPosition + moveDirection), new Vector3(1, 0, 1));

        // Move contoller
        Controller.Move(moveDirection);
        // Stop controller after movement;
        Stop();

        Vector3 actualXZ = Vector3.Scale(Controller.transform.localPosition, new Vector3(1, 0, 1));

        if (predictedXZ != actualXZ)
            MoveThrottle += (actualXZ - predictedXZ) / (SimulationRate * Time.deltaTime);
    }
Example #7
0
    protected virtual void UpdateController()
    {
        if (useProfileData)
        {
            if (InitialPose == null)
            {
                // Save the initial pose so it can be recovered if useProfileData
                // is turned off later.
                InitialPose = new OVRPose()
                {
                    position    = CameraRig.transform.localPosition,
                    orientation = CameraRig.transform.localRotation
                };
            }

            var p = CameraRig.transform.localPosition;
            if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.EyeLevel)
            {
                p.y = OVRManager.profile.eyeHeight - (0.5f * Controller.height) + Controller.center.y;
            }
            else if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.FloorLevel)
            {
                p.y = -(0.5f * Controller.height) + Controller.center.y;
            }
            CameraRig.transform.localPosition = p;
        }
        else if (InitialPose != null)
        {
            // Return to the initial pose if useProfileData was turned off at runtime
            CameraRig.transform.localPosition = InitialPose.Value.position;
            CameraRig.transform.localRotation = InitialPose.Value.orientation;
            InitialPose = null;
        }

        CameraHeight = CameraRig.centerEyeAnchor.localPosition.y;

        if (CameraUpdated != null)
        {
            CameraUpdated();
        }

        UpdateMovement();

        Vector3 moveDirection = Vector3.zero;

        float motorDamp = (1.0f + (Damping * SimulationRate * Time.deltaTime));

        MoveThrottle.x /= motorDamp;
        MoveThrottle.y /= motorDamp;
        MoveThrottle.z /= motorDamp;

        moveDirection += MoveThrottle * SimulationRate * Time.deltaTime;

        if (PreCharacterMove != null)
        {
            PreCharacterMove();
            Teleported = false;
        }

        Vector3 predictedXYZ = Controller.transform.localPosition + moveDirection;

        // Move contoller
        Controller.Move(moveDirection);
        Vector3 actualXYZ = Controller.transform.localPosition;

        if (predictedXYZ != actualXYZ)
        {
            MoveThrottle += (actualXYZ - predictedXYZ) / (SimulationRate * Time.deltaTime);
        }
    }
Example #8
0
    protected virtual void Update()
    {
        if (useProfileHeight)
        {
            if (InitialPose == null)
            {
                InitialPose = new OVRPose()
                {
                    position    = CameraController.transform.localPosition,
                    orientation = CameraController.transform.localRotation
                };
            }

            var p = CameraController.transform.localPosition;
            p.y = 0.5f * Controller.height;
            p.z = OVRManager.profile.eyeDepth;
            CameraController.transform.localPosition = p;
        }
        else if (InitialPose != null)
        {
            CameraController.transform.localPosition = InitialPose.Value.position;
            CameraController.transform.localRotation = InitialPose.Value.orientation;
            InitialPose = null;
        }

        UpdateMovement();

        Vector3 moveDirection = Vector3.zero;

        float motorDamp = (1.0f + (Damping * SimulationRate * Time.deltaTime));

        MoveThrottle.x /= motorDamp;
        MoveThrottle.y  = (MoveThrottle.y > 0.0f) ? (MoveThrottle.y / motorDamp) : MoveThrottle.y;
        MoveThrottle.z /= motorDamp;

        moveDirection += MoveThrottle * SimulationRate * Time.deltaTime;

        // Gravity
        if (Controller.isGrounded && FallSpeed <= 0)
        {
            FallSpeed = ((Physics.gravity.y * (GravityModifier * 0.002f)));
        }
        else
        {
            FallSpeed += ((Physics.gravity.y * (GravityModifier * 0.002f)) * SimulationRate * Time.deltaTime);
        }

        moveDirection.y += FallSpeed * SimulationRate * Time.deltaTime;

        // Offset correction for uneven ground
        float bumpUpOffset = 0.0f;

        if (Controller.isGrounded && MoveThrottle.y <= 0.001f)
        {
            bumpUpOffset   = Mathf.Max(Controller.stepOffset, new Vector3(moveDirection.x, 0, moveDirection.z).magnitude);
            moveDirection -= bumpUpOffset * Vector3.up;
        }

        Vector3 predictedXZ = Vector3.Scale((Controller.transform.localPosition + moveDirection), new Vector3(1, 0, 1));

        // Move contoller
        Controller.Move(moveDirection);

        Vector3 actualXZ = Vector3.Scale(Controller.transform.localPosition, new Vector3(1, 0, 1));

        if (predictedXZ != actualXZ)
        {
            MoveThrottle += (actualXZ - predictedXZ) / (SimulationRate * Time.deltaTime);
        }
    }
    protected override void OnUpdate()
    {
        base.OnUpdate();

        if ( m_isPlayerDead )
            return;
        if ( m_isClear )
        {
            m_DeadFade.color += new Color( 0, 0, 0, 0.6f * Time.deltaTime );
            if ( m_DeadFade.color.a >= 1.0f )
            {
                Application.LoadLevel( "01.Title" );
            }
        }
        if ( useProfileData )
        {
            if ( InitialPose == null )
            {
                // Save the initial pose so it can be recovered if useProfileData
                // is turned off later.
                InitialPose = new OVRPose()
                {
                    position = CameraRig.transform.localPosition,
                    orientation = CameraRig.transform.localRotation
                };
            }

            var p = CameraRig.transform.localPosition;
            p.y = OVRManager.profile.eyeHeight - 0.5f * Controller.height
                + Controller.center.y;
            CameraRig.transform.localPosition = p;
        }
        else if ( InitialPose != null )
        {
            // Return to the initial pose if useProfileData was turned off at runtime
            CameraRig.transform.localPosition = InitialPose.Value.position;
            CameraRig.transform.localRotation = InitialPose.Value.orientation;
            InitialPose = null;
        }

        UpdateMovement();
        m_pPlayer.Control();
        LockUIProcess();

        float Speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
        ProgressStepCycle( Speed );

        Vector3 moveDirection = Vector3.zero;

        float motorDamp = ( 1.0f + ( Damping * SimulationRate * Time.deltaTime ) );

        MoveThrottle.x /= motorDamp;
        MoveThrottle.y = ( MoveThrottle.y > 0.0f ) ? ( MoveThrottle.y / motorDamp ) : MoveThrottle.y;
        MoveThrottle.z /= motorDamp;

        moveDirection += MoveThrottle * SimulationRate * Time.deltaTime;

        // Gravity
        if ( Controller.isGrounded && FallSpeed <= 0 )
            FallSpeed = ( ( Physics.gravity.y * ( GravityModifier * 0.002f ) ) );
        else
            FallSpeed += ( ( Physics.gravity.y * ( GravityModifier * 0.002f ) ) * SimulationRate * Time.deltaTime );

        moveDirection.y += FallSpeed * SimulationRate * Time.deltaTime;

        // Offset correction for uneven ground
        float bumpUpOffset = 0.0f;

        if ( Controller.isGrounded && MoveThrottle.y <= 0.001f )
        {
            bumpUpOffset = Mathf.Max( Controller.stepOffset, new Vector3( moveDirection.x, 0, moveDirection.z ).magnitude );
            moveDirection -= bumpUpOffset * Vector3.up;
        }

        Vector3 predictedXZ = Vector3.Scale( ( Controller.transform.localPosition + moveDirection ), new Vector3( 1, 0, 1 ) );

        // Move contoller
        Controller.Move( moveDirection );

        Vector3 actualXZ = Vector3.Scale( Controller.transform.localPosition, new Vector3( 1, 0, 1 ) );

        if ( predictedXZ != actualXZ )
            MoveThrottle += ( actualXZ - predictedXZ ) / ( SimulationRate * Time.deltaTime );
    }
Example #10
0
    protected virtual void UpdateController()
    {
        Vector3 originalPosition = this.transform.position;

        if (useProfileData)
        {
            if (InitialPose == null)
            {
                // Save the initial pose so it can be recovered if useProfileData
                // is turned off later.
                InitialPose = new OVRPose()
                {
                    position    = CameraRig.transform.localPosition,
                    orientation = CameraRig.transform.localRotation
                };
            }

            var p = CameraRig.transform.localPosition;
            if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.EyeLevel)
            {
                p.y = OVRManager.profile.eyeHeight - (0.5f * Controller.height) + Controller.center.y;
            }
            else if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.FloorLevel)
            {
                p.y = -(0.5f * Controller.height) + Controller.center.y;
            }
            CameraRig.transform.localPosition = p;
        }
        else if (InitialPose != null)
        {
            // Return to the initial pose if useProfileData was turned off at runtime
            CameraRig.transform.localPosition = InitialPose.Value.position;
            CameraRig.transform.localRotation = InitialPose.Value.orientation;
            InitialPose = null;
        }

        CameraHeight = CameraRig.centerEyeAnchor.localPosition.y;

        if (CameraUpdated != null)
        {
            CameraUpdated();
        }

        UpdateMovement();

        Vector3 moveDirection = Vector3.zero;

        float motorDamp = (1.0f + (Damping * SimulationRate * Time.deltaTime));

        MoveThrottle.x /= motorDamp;
        MoveThrottle.y  = (MoveThrottle.y > 0.0f) ? (MoveThrottle.y / motorDamp) : MoveThrottle.y;
        MoveThrottle.z /= motorDamp;

        moveDirection += MoveThrottle * SimulationRate * Time.deltaTime;


        // Gravity
        if (!APPLY_GARVITY || IsClimbing)
        {
            FallSpeed = 0;
        }
        else
        {
            if (Controller.isGrounded && FallSpeed <= 0)
            {
                FallSpeed = ((Physics.gravity.y * (GravityModifier * 0.002f)));
            }
            else
            {
                FallSpeed += ((Physics.gravity.y * (GravityModifier * 0.002f)) * SimulationRate * Time.deltaTime);
            }

            float adjustFallSpeed = FallSpeed * SimulationRate * Time.deltaTime;

            if (hangTime == DateTime.MinValue)
            {
                if (moveDirection.y > 0 && (moveDirection.y + adjustFallSpeed) < 0 && hangTime == DateTime.MinValue && doHangTime)
                {
                    hangTime = DateTime.Now.AddMilliseconds(500);
                }
                else
                {
                    moveDirection.y += adjustFallSpeed;
                }
            }
            else if (hangTime < DateTime.Now)
            {
                hangTime         = DateTime.MinValue;
                moveDirection.y += adjustFallSpeed;
                doHangTime       = false;
            }
        }


        if (Controller.isGrounded && MoveThrottle.y <= transform.lossyScale.y * 0.001f)
        {
            // Offset correction for uneven ground
            float bumpUpOffset = Mathf.Max(Controller.stepOffset, new Vector3(moveDirection.x, 0, moveDirection.z).magnitude);
            moveDirection -= bumpUpOffset * Vector3.up;
        }

        if (PreCharacterMove != null)
        {
            PreCharacterMove();
            Teleported = false;
        }

        if (IsClimbing)
        {
            moveDirection.y = 0;
            moveDirection.z = 0;
        }

        Vector3 predictedXZ = Vector3.Scale((Controller.transform.localPosition + moveDirection), new Vector3(1, 0, 1));

        // Move contoller
        Controller.Move(moveDirection);
        Vector3 actualXZ = Vector3.Scale(Controller.transform.localPosition, new Vector3(1, 0, 1));

        if (predictedXZ != actualXZ)
        {
            MoveThrottle += (actualXZ - predictedXZ) / (SimulationRate * Time.deltaTime);
        }
    }
Example #11
0
	protected virtual void Update()
	{
		if (useProfileData)
		{
			if (InitialPose == null)
			{
				// Save the initial pose so it can be recovered if useProfileData
				// is turned off later.
				InitialPose = new OVRPose()
				{
					position = CameraRig.transform.localPosition,
					orientation = CameraRig.transform.localRotation
				};
			}

			var p = CameraRig.transform.localPosition;
			p.y = OVRManager.profile.eyeHeight - 0.5f * Controller.height
				+ Controller.center.y;
			CameraRig.transform.localPosition = p;
		}
		else if (InitialPose != null)
		{
			// Return to the initial pose if useProfileData was turned off at runtime
			CameraRig.transform.localPosition = InitialPose.Value.position;
			CameraRig.transform.localRotation = InitialPose.Value.orientation;
			InitialPose = null;
		}

		UpdateMovement();

		// Button A: Reset the transform to initial position and rotation
		if (Input.GetButtonDown("Fire1")) {
			transform.position = new Vector3 (0.0f,0.0f,0.0f);
			transform.rotation = Quaternion.identity;
		}


		// Button B: reinitialize randomly
		if (Input.GetButtonDown("Fire2")) {
			string[] methodString = {"PCA", "t-SNE", "Isomap", "MDS"};
			embeddingCode += 1;
			embeddingCode = embeddingCode % numEmbeddings;
			doEmbedding(embeddingCode);

			text = GameObject.Find("Text").GetComponent <Text> ();
			text.text = "Method: " + methodString[embeddingCode];
		}

		Vector3 moveDirection = Vector3.zero;

		float motorDamp = (1.0f + (Damping * SimulationRate * Time.deltaTime));

		MoveThrottle.x /= motorDamp;
		MoveThrottle.y = (MoveThrottle.y > 0.0f) ? (MoveThrottle.y / motorDamp) : MoveThrottle.y;
		MoveThrottle.z /= motorDamp;

		moveDirection += MoveThrottle * SimulationRate * Time.deltaTime;

		// Gravity
		if (Controller.isGrounded && FallSpeed <= 0)
			FallSpeed = ((Physics.gravity.y * (GravityModifier * 0.002f)));
		else
			FallSpeed += ((Physics.gravity.y * (GravityModifier * 0.002f)) * SimulationRate * Time.deltaTime);

		moveDirection.y += FallSpeed * SimulationRate * Time.deltaTime;

		// Offset correction for uneven ground
		float bumpUpOffset = 0.0f;

        if (Controller.isGrounded && MoveThrottle.y <= transform.lossyScale.y * 0.001f)
		{
			bumpUpOffset = Mathf.Max(Controller.stepOffset, new Vector3(moveDirection.x, 0, moveDirection.z).magnitude);
			moveDirection -= bumpUpOffset * Vector3.up;
		}

		Vector3 predictedXZ = Vector3.Scale((Controller.transform.localPosition + moveDirection), new Vector3(1, 0, 1));

		// Move contoller
		Controller.Move(moveDirection);

		Vector3 actualXZ = Vector3.Scale(Controller.transform.localPosition, new Vector3(1, 0, 1));

		if (predictedXZ != actualXZ)
			MoveThrottle += (actualXZ - predictedXZ) / (SimulationRate * Time.deltaTime);
	}
Example #12
0
        void Update()
        {
            if (!calibratedCameraPose.HasValue)
            {
                if (!OVRPlugin.Media.GetInitialized())
                {
                    return;
                }

                OVRPlugin.CameraIntrinsics cameraIntrinsics;
                OVRPlugin.CameraExtrinsics cameraExtrinsics;

                if (OVRPlugin.GetMixedRealityCameraInfo(0, out cameraExtrinsics, out cameraIntrinsics))
                {
                    calibratedCameraPose = cameraExtrinsics.RelativePose.ToOVRPose();
                }
                else
                {
                    return;
                }
            }

            OVRPose cameraStagePoseInUnits = calibratedCameraPose.Value;

            // Converting position from meters to decimeters (unit used by Open Brush)
            cameraStagePoseInUnits.position *= App.METERS_TO_UNITS;

            // Workaround to fix the OVRExtensions.ToWorldSpacePose() and
            // OVRComposition.ComputeCameraWorldSpacePose() calls when computing
            // the Mixed Reality foreground and background camera positions.
            OVRPose headPose = OVRPose.identity;

            Vector3    pos;
            Quaternion rot;

            if (OVRNodeStateProperties.GetNodeStatePropertyVector3(Node.Head,
                                                                   NodeStatePropertyType.Position, OVRPlugin.Node.Head, OVRPlugin.Step.Render, out pos))
            {
                headPose.position = pos;
            }

            if (OVRNodeStateProperties.GetNodeStatePropertyQuaternion(Node.Head,
                                                                      NodeStatePropertyType.Orientation, OVRPlugin.Node.Head, OVRPlugin.Step.Render, out rot))
            {
                headPose.orientation = rot;
            }

            OVRPose headPoseInUnits = OVRPose.identity;

            headPoseInUnits.position    = headPose.position * App.METERS_TO_UNITS;
            headPoseInUnits.orientation = headPose.orientation;

            OVRPose stageToLocalPose = OVRPlugin.GetTrackingTransformRelativePose(
                OVRPlugin.TrackingOrigin.Stage).ToOVRPose();

            OVRPose stageToLocalPoseInUnits = OVRPose.identity;

            stageToLocalPoseInUnits.position    = stageToLocalPose.position * App.METERS_TO_UNITS;
            stageToLocalPoseInUnits.orientation = stageToLocalPose.orientation;

            OVRPose cameraWorldPoseInUnits = headPoseInUnits.Inverse() * stageToLocalPoseInUnits *
                                             cameraStagePoseInUnits;
            OVRPose cameraStagePoseFix = stageToLocalPose.Inverse() * headPose * cameraWorldPoseInUnits;

            // Override the MRC camera's stage pose
            OVRPlugin.OverrideExternalCameraStaticPose(0, true, cameraStagePoseFix.ToPosef());
        }
Example #13
0
        protected virtual void Update()
        {
            if (useProfileData)
            {
                if (InitialPose == null)
                {
                    // Save the initial pose so it can be recovered if useProfileData
                    // is turned off later.
                    InitialPose = new OVRPose()
                    {
                        position    = CameraRig.transform.localPosition,
                        orientation = CameraRig.transform.localRotation
                    };
                }

                var p = CameraRig.transform.localPosition;
                p.y = OVRManager.profile.eyeHeight - 0.5f * Controller.height
                      + Controller.center.y;
                CameraRig.transform.localPosition = p;
            }
            else if (InitialPose != null)
            {
                // Return to the initial pose if useProfileData was turned off at runtime
                CameraRig.transform.localPosition = InitialPose.Value.position;
                CameraRig.transform.localRotation = InitialPose.Value.orientation;
                InitialPose = null;
            }

            //print(CameraRig.centerEyeAnchor.localEulerAngles.x);
            //if (CameraRig.centerEyeAnchor.localEulerAngles.x > 30 && CameraRig.centerEyeAnchor.localEulerAngles.x < 80)
            //{
            //    GameObject.Find("pallette").GetComponentInChildren<Renderer>().enabled = true;
            //   foreach (Renderer colorBalls in GameObject.Find("pallette").GetComponentsInChildren<Renderer>())
            //    {
            //        colorBalls.enabled = true;
            //   }
            //GameObject.Find("crosshair").transform.localScale = new Vector3(1, 1, 1);

            RaycastHit pallettehit;

            if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out pallettehit))
            {
                if (pallettehit.transform.tag == "pallette" || pallettehit.transform.tag == "ColorSelect" || pallettehit.transform.tag == "ColorMix")
                {
                    pallettehit.transform.GetComponentInChildren <Renderer>().enabled = true;
                    foreach (Renderer colorBalls in pallettehit.transform.GetComponentsInChildren <Renderer>())
                    {
                        colorBalls.enabled = true;
                    }
                    GameObject.Find("crosshair").transform.localScale = new Vector3(1, 1, 1);
                }
                else
                {
                    GameObject.Find("pallette").transform.GetComponentInChildren <Renderer>().enabled = false;
                    foreach (Renderer colorBalls in GameObject.Find("pallette").transform.GetComponentsInChildren <Renderer>())
                    {
                        colorBalls.enabled = false;
                    }
                    GameObject.Find("crosshair").transform.localScale = new Vector3(0, 0, 0);
                }
            }

            // } else {
            //GameObject.Find("pallette").GetComponentInChildren<Renderer>().enabled = false;
            //foreach (Renderer colorBalls in GameObject.Find("pallette").GetComponentsInChildren<Renderer>())
            //{
            //    colorBalls.enabled = false;
            //}
            //GameObject.Find("crosshair").transform.localScale = new Vector3(0,0,0);
            // }
            UpdateMovement();

            Vector3 moveDirection = Vector3.zero;

            inputHandle.InputHandle();

            float motorDamp = (1.0f + (Damping * SimulationRate * Time.deltaTime));

            MoveThrottle.x /= motorDamp;
            MoveThrottle.y  = (MoveThrottle.y > 0.0f) ? (MoveThrottle.y / motorDamp) : MoveThrottle.y;
            MoveThrottle.z /= motorDamp;

            moveDirection += MoveThrottle * SimulationRate * Time.deltaTime;

            // Gravity

            /*if (Controller.isGrounded && FallSpeed <= 0)
             *  FallSpeed = ((Physics.gravity.y * (GravityModifier * 0.002f)));
             * else
             *  FallSpeed += ((Physics.gravity.y * (GravityModifier * 0.002f)) * SimulationRate * Time.deltaTime);
             *
             * moveDirection.y += FallSpeed * SimulationRate * Time.deltaTime;*/

            // Offset correction for uneven ground
            float bumpUpOffset = 0.0f;

            if (Controller.isGrounded && MoveThrottle.y <= transform.lossyScale.y * 0.001f)
            {
                bumpUpOffset   = Mathf.Max(Controller.stepOffset, new Vector3(moveDirection.x, 0, moveDirection.z).magnitude);
                moveDirection -= bumpUpOffset * Vector3.up;
            }

            Vector3 predictedXZ = Vector3.Scale((Controller.transform.localPosition + moveDirection), new Vector3(1, 0, 1));

            // Move contoller
            //Controller.Move(moveDirection);

            Vector3 actualXZ = Vector3.Scale(Controller.transform.localPosition, new Vector3(1, 0, 1));

            if (predictedXZ != actualXZ)
            {
                MoveThrottle += (actualXZ - predictedXZ) / (SimulationRate * Time.deltaTime);
            }
        }
    protected virtual void Update()
    {
        if (useProfileData)
        {
            if (InitialPose == null)
            {
                // Save the initial pose so it can be recovered if useProfileData
                // is turned off later.
                InitialPose = new OVRPose()
                {
                    position = CameraRig.transform.localPosition,
                    orientation = CameraRig.transform.localRotation
                };
            }

            var p = CameraRig.transform.localPosition;
            p.y = OVRManager.profile.eyeHeight - 0.5f * Controller.height
                + Controller.center.y;
            CameraRig.transform.localPosition = p;
        }
        else if (InitialPose != null)
        {
            // Return to the initial pose if useProfileData was turned off at runtime
            CameraRig.transform.localPosition = InitialPose.Value.position;
            CameraRig.transform.localRotation = InitialPose.Value.orientation;
            InitialPose = null;
        }

        UpdateMovement();

        Vector3 moveDirection = Vector3.zero;

        float motorDamp = (1.0f + (Damping * SimulationRate * Time.deltaTime));

        MoveThrottle.x /= motorDamp;
        MoveThrottle.y = (MoveThrottle.y > 0.0f) ? (MoveThrottle.y / motorDamp) : MoveThrottle.y;
        MoveThrottle.z /= motorDamp;

        moveDirection += MoveThrottle * SimulationRate * Time.deltaTime;

        // Gravity
        if (Controller.isGrounded && FallSpeed <= 0)
            FallSpeed = ((Physics.gravity.y * (GravityModifier * 0.002f)));
        else
            FallSpeed += ((Physics.gravity.y * (GravityModifier * 0.002f)) * SimulationRate * Time.deltaTime);

        moveDirection.y += FallSpeed * SimulationRate * Time.deltaTime;

        // Offset correction for uneven ground
        float bumpUpOffset = 0.0f;

        if (Controller.isGrounded && MoveThrottle.y <= transform.lossyScale.y * 0.001f)
        {
            bumpUpOffset = Mathf.Max(Controller.stepOffset, new Vector3(moveDirection.x, 0, moveDirection.z).magnitude);
            moveDirection -= bumpUpOffset * Vector3.up;
        }

        Vector3 predictedXZ = Vector3.Scale((Controller.transform.localPosition + moveDirection), new Vector3(1, 0, 1));

        // Move contoller
        Controller.Move(moveDirection);

        Vector3 actualXZ = Vector3.Scale(Controller.transform.localPosition, new Vector3(1, 0, 1));

        if (predictedXZ != actualXZ)
            MoveThrottle += (actualXZ - predictedXZ) / (SimulationRate * Time.deltaTime);

        if (Input.GetKeyDown ("joystick button 16")) {
            jump ();
        }

        if (Input.GetKeyDown ("joystick button 18")) {
            fireLaser ();
        }

        if (Input.GetKeyDown ("joystick button 17")) {
            launchGrenade ();
        }

        if (transform.rotation.eulerAngles.x != 0) {
            transform.Rotate (-transform.rotation.eulerAngles.x, 0, 0);
        }

        if (transform.rotation.eulerAngles.z != 0) {
            transform.Rotate (0, 0, -transform.rotation.eulerAngles.z);
        }

        if (framesCooldownJump > 0) {
            framesCooldownJump --;
        }
        if (framesCooldownLaser > 0) {
            framesCooldownLaser --;
        }
        if (starTimer > 0)
            starTimer--;

        if (starTimer <= 0) {
            godMode = false;
            if(rick.isPlaying)
            {
                rick.Pause();
                game.Play();
            }
        }
    }
Example #15
0
	protected virtual void Update()
	{
		if (useProfileData)
		{
			if (InitialPose == null)
			{
				// Save the initial pose so it can be recovered if useProfileData
				// is turned off later.
				InitialPose = new OVRPose()
				{
					position = CameraRig.transform.localPosition,
					orientation = CameraRig.transform.localRotation
				};
			}

			var p = CameraRig.transform.localPosition;
			p.y = OVRManager.profile.eyeHeight - 0.5f * Controller.height
				+ Controller.center.y;
			CameraRig.transform.localPosition = p;
		}
		else if (InitialPose != null)
		{
			// Return to the initial pose if useProfileData was turned off at runtime
			CameraRig.transform.localPosition = InitialPose.Value.position;
			CameraRig.transform.localRotation = InitialPose.Value.orientation;
			InitialPose = null;
		}

		// MY CODE !!!!!!!!!!!!!!!!!!
		if (Input.GetButton("Fire1")) {
			transform.position = new Vector3 (0.0f,0.0f,0.0f);
		}

		// !!!!!!!!!!!

		UpdateMovement();

		Vector3 moveDirection = Vector3.zero;

		float motorDamp = (1.0f + (Damping * SimulationRate * Time.deltaTime));

		MoveThrottle.x /= motorDamp;
		MoveThrottle.y = (MoveThrottle.y > 0.0f) ? (MoveThrottle.y / motorDamp) : MoveThrottle.y;
		MoveThrottle.z /= motorDamp;

		moveDirection += MoveThrottle * SimulationRate * Time.deltaTime;

		// Gravity
		if (Controller.isGrounded && FallSpeed <= 0)
			FallSpeed = ((Physics.gravity.y * (GravityModifier * 0.002f)));
		else
			FallSpeed += ((Physics.gravity.y * (GravityModifier * 0.002f)) * SimulationRate * Time.deltaTime);

		moveDirection.y += FallSpeed * SimulationRate * Time.deltaTime;

		// Offset correction for uneven ground
		float bumpUpOffset = 0.0f;

        if (Controller.isGrounded && MoveThrottle.y <= transform.lossyScale.y * 0.001f)
		{
			bumpUpOffset = Mathf.Max(Controller.stepOffset, new Vector3(moveDirection.x, 0, moveDirection.z).magnitude);
			moveDirection -= bumpUpOffset * Vector3.up;
		}

		Vector3 predictedXZ = Vector3.Scale((Controller.transform.localPosition + moveDirection), new Vector3(1, 0, 1));

		// Move contoller
		Controller.Move(moveDirection);

		Vector3 actualXZ = Vector3.Scale(Controller.transform.localPosition, new Vector3(1, 0, 1));

		if (predictedXZ != actualXZ)
			MoveThrottle += (actualXZ - predictedXZ) / (SimulationRate * Time.deltaTime);
	}
Example #16
0
    protected virtual void Update()
    {
        Vector3 TmpMovement = GetOculusRotation() - OculusPrevRot;

        TmpMovement.x = RepairAxis(TmpMovement.x);
        TmpMovement.y = RepairAxis(TmpMovement.y);
        TmpMovement.z = RepairAxis(TmpMovement.z);

        OculusMovements.Add(TmpMovement);
        OculusTime.Add(Time.deltaTime);
        OculusPrevRot = GetOculusRotation();
        if (OculusMovements.Count > 150)
        {
            OculusMovements.RemoveAt(0);
            OculusTime.RemoveAt(0);
        }

        //if (ShakingHeadChecker(1, 60.0f, 300.0f, 0.0f, 1.0f, 1.0f, 2))
        //   Debug.Log("WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE");

        if (useProfileData)
        {
            if (InitialPose == null)
            {
                // Save the initial pose so it can be recovered if useProfileData
                // is turned off later.
                InitialPose = new OVRPose()
                {
                    position    = CameraRig.transform.localPosition,
                    orientation = CameraRig.transform.localRotation
                };
            }

            var p = CameraRig.transform.localPosition;
            p.y = OVRManager.profile.eyeHeight - 0.5f * Controller.height
                  + Controller.center.y;
            CameraRig.transform.localPosition = p;
        }
        else if (InitialPose != null)
        {
            // Return to the initial pose if useProfileData was turned off at runtime
            CameraRig.transform.localPosition = InitialPose.Value.position;
            CameraRig.transform.localRotation = InitialPose.Value.orientation;
            InitialPose = null;
        }

        UpdateMovement();

        Vector3 moveDirection = Vector3.zero;

        float motorDamp = (1.0f + (Damping * SimulationRate * Time.deltaTime));

        MoveThrottle.x /= motorDamp;
        MoveThrottle.y  = (MoveThrottle.y > 0.0f) ? (MoveThrottle.y / motorDamp) : MoveThrottle.y;
        MoveThrottle.z /= motorDamp;

        moveDirection += MoveThrottle * SimulationRate * Time.deltaTime;

        // Gravity
        if (Controller.isGrounded && FallSpeed <= 0)
        {
            FallSpeed = ((Physics.gravity.y * (GravityModifier * 0.002f)));
        }
        else
        {
            FallSpeed += ((Physics.gravity.y * (GravityModifier * 0.002f)) * SimulationRate * Time.deltaTime);
        }

        moveDirection.y += FallSpeed * SimulationRate * Time.deltaTime;

        // Offset correction for uneven ground
        float bumpUpOffset = 0.0f;

        if (Controller.isGrounded && MoveThrottle.y <= transform.lossyScale.y * 0.001f)
        {
            bumpUpOffset   = Mathf.Max(Controller.stepOffset, new Vector3(moveDirection.x, 0, moveDirection.z).magnitude);
            moveDirection -= bumpUpOffset * Vector3.up;
        }

        Vector3 predictedXZ = Vector3.Scale((Controller.transform.localPosition + moveDirection), new Vector3(1, 0, 1));

        // Move contoller
        Controller.Move(moveDirection);

        Vector3 actualXZ = Vector3.Scale(Controller.transform.localPosition, new Vector3(1, 0, 1));

        if (predictedXZ != actualXZ)
        {
            MoveThrottle += (actualXZ - predictedXZ) / (SimulationRate * Time.deltaTime);
        }
    }
Example #17
0
    protected void Update()
    {
        if (useProfileData)
        {
            if (InitialPose_ == null)
            {
                InitialPose_ = new OVRPose()
                {
                    position    = CameraRig.transform.localPosition,
                    orientation = CameraRig.transform.localRotation
                };
            }
            Debug.Log(OVRManager.profile.eyeHeight);
            var p = CameraRig.transform.localPosition;
            p.y = OVRManager.profile.eyeHeight - 0.5f * Controller.height;
            p.z = OVRManager.profile.eyeDepth;
            CameraRig.transform.localPosition = p;
        }
        else if (InitialPose_ != null)
        {
            CameraRig.transform.localPosition = InitialPose_.Value.position;
            CameraRig.transform.localRotation = InitialPose_.Value.orientation;
            InitialPose_ = null;
        }


        //We are making the user Jump when they pull the trigger while they were pressing the One (Touchpad) button on the Oculus Go controller
        if ((OVRInput.Get(OVRInput.Button.One) && OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger)) || Input.GetKey(KeyCode.Space))
        {
            MoveThrottle_ += new Vector3(0, transform.lossyScale.y * JumpForce, 0);
        }


        UpdateMovement();

        Vector3 moveDirection = Vector3.zero;

        float motorDamp = (1.0f + (Damping * SimulationRate_ * Time.deltaTime));

        MoveThrottle_.x /= motorDamp;
        MoveThrottle_.y  = (MoveThrottle_.y > 0.0f) ? (MoveThrottle_.y / motorDamp) : MoveThrottle_.y;
        MoveThrottle_.z /= motorDamp;

        moveDirection += MoveThrottle_ * SimulationRate_ * Time.deltaTime;

        // Gravity
        if (Controller.isGrounded && FallSpeed_ <= 0)
        {
            FallSpeed_ = ((Physics.gravity.y * (GravityModifier * 0.002f)));
        }
        else
        {
            FallSpeed_ += ((Physics.gravity.y * (GravityModifier * 0.002f)) * SimulationRate_ * Time.deltaTime);
        }

        moveDirection.y += FallSpeed_ * SimulationRate_ * Time.deltaTime;

        // Offset correction for uneven ground
        float bumpUpOffset = 0.0f;

        if (Controller.isGrounded && MoveThrottle_.y <= 0.001f)
        {
            bumpUpOffset   = Mathf.Max(Controller.stepOffset, new Vector3(moveDirection.x, 0, moveDirection.z).magnitude);
            moveDirection -= bumpUpOffset * Vector3.up;
        }

        Vector3 predictedXZ = Vector3.Scale((Controller.transform.localPosition + moveDirection), new Vector3(1, 0, 1));

        // Move contoller
        Controller.Move(moveDirection);

        Vector3 actualXZ = Vector3.Scale(Controller.transform.localPosition, new Vector3(1, 0, 1));

        if (predictedXZ != actualXZ)
        {
            MoveThrottle_ += (actualXZ - predictedXZ) / (SimulationRate_ * Time.deltaTime);
        }
    }
    protected virtual void UpdateController()
    {
        if (useProfileData)
        {
            if (InitialPose == null)
            {
                // Save the initial pose so it can be recovered if useProfileData
                // is turned off later.
                InitialPose = new OVRPose()
                {
                    position    = CameraRig.transform.localPosition,
                    orientation = CameraRig.transform.localRotation
                };
            }

            var p = CameraRig.transform.localPosition;
            if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.EyeLevel)
            {
                p.y = OVRManager.profile.eyeHeight - (0.5f * Controller.height) + Controller.center.y;
            }
            else if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.FloorLevel)
            {
                p.y = -(0.5f * Controller.height) + Controller.center.y;
            }
            CameraRig.transform.localPosition = p;
        }
        else if (InitialPose != null)
        {
            // Return to the initial pose if useProfileData was turned off at runtime
            CameraRig.transform.localPosition = InitialPose.Value.position;
            CameraRig.transform.localRotation = InitialPose.Value.orientation;
            InitialPose = null;
        }

        UpdateMovement();

        Vector3 moveDirection = Vector3.zero;

        float motorDamp = (1.0f + (Damping * SimulationRate * Time.deltaTime));

        MoveThrottle.x /= motorDamp;
        MoveThrottle.y  = (MoveThrottle.y > 0.0f) ? (MoveThrottle.y / motorDamp) : MoveThrottle.y;
        MoveThrottle.z /= motorDamp;

        moveDirection += MoveThrottle * SimulationRate * Time.deltaTime;

        // Gravity
        if (Controller.isGrounded && FallSpeed <= 0)
        {
            FallSpeed = ((Physics.gravity.y * (GravityModifier * 0.002f)));
        }
        else
        {
            FallSpeed += ((Physics.gravity.y * (GravityModifier * 0.002f)) * SimulationRate * Time.deltaTime);
        }

        moveDirection.y += FallSpeed * SimulationRate * Time.deltaTime;

        // Offset correction for uneven ground
        float bumpUpOffset = 0.0f;

        if (Controller.isGrounded && MoveThrottle.y <= transform.lossyScale.y * 0.001f)
        {
            bumpUpOffset   = Mathf.Max(Controller.stepOffset, new Vector3(moveDirection.x, 0, moveDirection.z).magnitude);
            moveDirection -= bumpUpOffset * Vector3.up;
        }

        Vector3 predictedXZ = Vector3.Scale((Controller.transform.localPosition + moveDirection), new Vector3(1, 0, 1));

        // Move contoller
        Controller.Move(moveDirection);

        Vector3 actualXZ = Vector3.Scale(Controller.transform.localPosition, new Vector3(1, 0, 1));

        if (predictedXZ != actualXZ)
        {
            MoveThrottle += (actualXZ - predictedXZ) / (SimulationRate * Time.deltaTime);
        }
    }
    protected virtual void UpdateController()
    {
        if (useProfileData)
        {
            if (InitialPose == null)
            {
                // Save the initial pose so it can be recovered if useProfileData
                // is turned off later.
                InitialPose = new OVRPose()
                {
                    position    = CameraRig.transform.localPosition,
                    orientation = CameraRig.transform.localRotation
                };
            }

            var p = CameraRig.transform.localPosition;
            if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.EyeLevel)
            {
                p.y = OVRManager.profile.eyeHeight - (0.5f * Controller.height) + Controller.center.y;
            }
            else if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.FloorLevel)
            {
                p.y = -(0.5f * Controller.height) + Controller.center.y;
            }
            CameraRig.transform.localPosition = p;
        }
        else if (InitialPose != null)
        {
            // Return to the initial pose if useProfileData was turned off at runtime
            CameraRig.transform.localPosition = InitialPose.Value.position;
            CameraRig.transform.localRotation = InitialPose.Value.orientation;
            InitialPose = null;
        }

        CameraHeight = CameraRig.centerEyeAnchor.localPosition.y;

        if (CameraUpdated != null)
        {
            CameraUpdated();
        }

        UpdateMovement();

        Vector3 moveDirection = Vector3.zero;

        float motorDamp = (1.0f + (Damping * SimulationRate * Time.deltaTime));

        MoveThrottle.x /= motorDamp;
        MoveThrottle.y  = (MoveThrottle.y > 0.0f) ? (MoveThrottle.y / motorDamp) : MoveThrottle.y;
        MoveThrottle.z /= motorDamp;

        moveDirection += MoveThrottle * SimulationRate * Time.deltaTime;

        // Gravity
        if (/*Controller.isGrounded && */ FallSpeed <= 0)
        {
            // FallSpeed = ((Physics.gravity.y * (GravityModifier * 0.002f)));
            FallSpeed = 0f;
        }
        else
        {
            // FallSpeed += ((Physics.gravity.y * (GravityModifier * 0.002f)) * SimulationRate * Time.deltaTime);
            FallSpeed = 0f;
        }

        // moveDirection.y += FallSpeed * SimulationRate * Time.deltaTime;
        moveDirection.y = 0f;


        // if (Controller.isGrounded && MoveThrottle.y <= transform.lossyScale.y * 0.001f)
        // {
        //  // Offset correction for uneven ground
        //  float bumpUpOffset = Mathf.Max(Controller.stepOffset, new Vector3(moveDirection.x, 0, moveDirection.z).magnitude);
        //  moveDirection -= bumpUpOffset * Vector3.up;
        // }

        if (PreCharacterMove != null)
        {
            PreCharacterMove();
            Teleported = false;
        }

        Vector3 predictedXZ = Vector3.Scale((Controller.transform.localPosition + moveDirection), new Vector3(1, 0, 1));

        // Move contoller
        // NOTE:X,Yで上下移動の可能にする.重力による落下はなしにしている
        if (OVRInput.Get(OVRInput.RawButton.B))
        {
            moveDirection.y += 0.1f;
            // Debug.Log("UP position");
        }
        else if (OVRInput.Get(OVRInput.RawButton.A))
        {
            moveDirection.y -= 0.1f;
            // Debug.Log("DOWN position");
        }
        Controller.Move(moveDirection);
        Vector3 actualXZ = Vector3.Scale(Controller.transform.localPosition, new Vector3(1, 0, 1));

        if (predictedXZ != actualXZ)
        {
            MoveThrottle += (actualXZ - predictedXZ) / (SimulationRate * Time.deltaTime);
        }
    }