// Update is called once per frame void Update() { currRate += Time.deltaTime; if (currRate > rate) { currRate = 0.0f; int wandKeyNum = InputKey.WandTriggerStrong - InputKey.WandMenu + 1; for (int i = 0; i < 2; i++) { InputType type = (InputType)i; for (int j = 0; j < (int)wandKeyNum; j++) { InputKey key = (InputKey)j; bool keystatus = TGInput.GetKey(type, key); if (keystatus) { ThreeGlassesUtils.Log("type=" + (InputType)i + "key=" + key); } } // ThreeGlassesUtils.Log("type=" + (InputType)i // + " trigger process=" + TGInput.GetTriggerProcess(type) // + " stick=" + TGInput.GetStick(type)); ThreeGlassesUtils.Log("type=" + (InputType)i + " trigger position=" + TGInput.GetPosition(type) + " rotation" + TGInput.GetRotation(type)); } } //transform.position = TGInput.GetPosition(InputType.LeftWand); transform.rotation = TGInput.GetRotation(InputType.RightWand); }
// Update is called once per frame void Update() { ThreeGlassesUtils.Log("HMD's name is " + TGInput.GetHMDName()); ThreeGlassesUtils.Log("HMD's touchpad " + TGInput.GetHMDTouchPad()); if (TGInput.GetKey(InputType.HMD, InputKey.HmdMenu)) { ThreeGlassesUtils.Log("HMD's key menu is pressed "); } if (TGInput.GetKey(InputType.HMD, InputKey.HmdExit)) { ThreeGlassesUtils.Log("HMD's key exit is pressed "); } for (int i = (int)InputKey.WandMenu; i <= (int)InputKey.WandTriggerStrong; i++) { if (TGInput.GetKey(InputType.LeftWand, (InputKey)i)) { ThreeGlassesUtils.Log((InputKey)i + " is pressed"); } } // by get way if (useType == UseType.UseGet) { // set transform transform.localPosition = origin + TGInput.GetPosition(inputType) * moveScale; transform.localRotation = TGInput.GetRotation(inputType); float intensity = TGInput.GetTriggerProcess(inputType); mat.SetColor("_Color", new Color(intensity, intensity, intensity, 1)); // change bullet type if (TGInput.GetKey(inputType, InputKey.WandLeftSide)) { bulletType = (bulletType + 3) % 4; } if (TGInput.GetKey(inputType, InputKey.WandRightSide)) { bulletType = (++bulletType) % 4; } // create a bullet currRate += Time.deltaTime; if (currRate > fireRate) { currRate -= fireRate; if (TGInput.GetKey(inputType, InputKey.WandTriggerStrong)) { GameObject bullet = GameObject.CreatePrimitive((PrimitiveType)bulletType); bullet.transform.position = firePos.position; bullet.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); Rigidbody rb = bullet.AddComponent <Rigidbody>(); rb.AddForce(transform.forward * bulletSpeed, ForceMode.VelocityChange); Destroy(bullet, 10.0f); } } } // move control if (headDisplay != null) { Vector2 dir = TGInput.GetStick(inputType); if (inputType == InputType.LeftWand) { dir = dir * moveSpeed * Time.deltaTime; headDisplay.Translate(new Vector3(dir.x, 0, dir.y)); } else if (inputType == InputType.RightWand) { headDisplay.Rotate(headDisplay.up, dir.x * rotateSpeed * Time.deltaTime); headDisplay.Rotate(headDisplay.right, -dir.y * rotateSpeed * Time.deltaTime); } } }