void Update() { float speed = ve.estimatedVelocity.magnitude; float angularSpeed = ve.estimatedAngularVelocity.magnitude; maxSpeed = Mathf.Max(maxSpeed, speed); maxAngularSpeed = Mathf.Max(maxAngularSpeed, angularSpeed); VRDebug.Log(string.Format("{0}\tspeed: {1:0.0}\tangspeed: {2:0.0}", name, maxSpeed, maxAngularSpeed)); }
void FixedUpdate() { string handName = trackpadHand == VRHand.WhichHand.Left ? "Left" : "Right"; /* * if (Input.GetButton(handName+"TrackpadTouch") && !Input.GetButton(handName+"TrackpadPress")){ * float h=Input.GetAxis(handName+"TrackpadHorizontal"); * float v=Input.GetAxis(handName+"TrackpadVertical"); * VRDebug.Log(h+" "+v+"\n"); * Transform t=Left.transform; * Vector3 movement=h*t.right+v*t.forward; * movement=Quaternion.FromToRotation(t.up,moveTarget.up)*movement; * float armSwingerAmount=getArmSwingerAmount(); * if(useArmSwinger) * movement*=armSwingerAmount*armSwingerMultiplier; * else * movement*=speed*Time.fixedDeltaTime; * moveTarget.Translate(movement,Space.World); * }else */ if (!Input.GetButton(handName + "TrackpadPress")) { float h = Input.GetAxis(handName + "ThumbstickHorizontal"); float v = Input.GetAxis(handName + "ThumbstickVertical"); if ((new Vector2(v, h)).magnitude > 0.1f) { VRDebug.Log(h + " " + v + "\n"); Transform t = Left.transform; Vector3 movement = h * t.right + v * t.forward; movement = Quaternion.FromToRotation(t.up, moveTarget.up) * movement; float armSwingerAmount = getArmSwingerAmount(); if (useArmSwinger) { movement *= armSwingerAmount * armSwingerMultiplier; } else { movement *= speed * Time.fixedDeltaTime; } moveTarget.Translate(movement, Space.World); } } }
void Start() { instance = this; str1 = str2 = ""; }
void Update() { { float Y = HMD.localPosition.y; float vy = (Y - lastY) / Time.deltaTime; lastY = Y; evY = Mathf.Lerp(evY, vy, lerpFactor); float g = (evY - lastvY) / Time.deltaTime; lastvY = evY; eG = Mathf.Lerp(eG, g, lerpFactor); } { switch (m_jumpStage) { case 0: if (hmdHeightTS > hmdInitHeightTS * .9f && eG > 0.5f && evY > 0.5f) { m_jumpStage = 1; } break; case 1: if (hmdHeightTS > hmdInitHeightTS * 1.1f && eG < 0) { m_jumpStage = 2; } break; case 2: if (evY < 0 && eG < 0) { m_jumpStage = 3; } break; case 3: if (eG > 0 && hmdHeightTS < hmdInitHeightTS * 1.1f) { m_jumpStage = 0; } break; } } if (HMD.localPosition.y < stanceCriteria * hmdInitHeightTS) { enterStanceCount += Time.deltaTime; if (enterStanceCount > .1f && !m_stance) { m_stance = true; } } else { enterStanceCount = 0; m_stance = false; } if (HMD.localPosition.y < crouchCriteria * hmdInitHeightTS) { enterCrouchCount += Time.deltaTime; if (enterCrouchCount > .1f && !m_crouching) { m_crouching = true; } } else { enterCrouchCount = 0; m_crouching = false; } VRDebug.Log(string.Format("height: {0:0.00}\tvy: {1:0.0}\tg:{2:0.0}", hmdHeightTS, verticalSpeedTS, verticalAcceleratorTS)); VRDebug.Log("crouch: " + isCrouching + "\tstance: " + isStance + "\tjump: " + m_jumpStage + ">1"); }