protected virtual void Update() { if (controllerEvents != null && controllerEvents.touchpadTouched && controllerEvents.GetTouchpadAxis() != Vector2.zero) { float touchpadAngle = controllerEvents.GetTouchpadAxisAngle(); float angle = ((touchpadAngle > 180) ? touchpadAngle -= 360 : touchpadAngle) + headset.eulerAngles.y; transform.localEulerAngles = new Vector3(0f, angle, 0f); } }
void CheckColor() { if (colorLerpTime >= 1f) { oldCol = crystalMaterial.material.color; colorLerpTime = 0f; } ColorLerpDEBUG(); //ONLY RUN THIS IF USING VRTK SIMULATOR. Num1, 2, 3 change colors; //SPELL TYPES: 0 = red, 1 = green, 2 = blue. if (myController.touchpadAxisChanged) { float myAngle = myController.GetTouchpadAxisAngle(); {/*if (myController.GetTouchpadAxisAngle() <= 90 && myController.GetTouchpadAxisAngle() > 45) { * //if in the center of the red and green tri * if (myController.GetTouchpadAxis().x > 0) { * redAm = 1f; * spellType = 0; * } * else { * greenAm = 1f; * spellType = 1; * } * } * else if (myController.GetTouchpadAxisAngle() > 90 && myController.GetTouchpadAxisAngle() < 120) { * if (myController.GetTouchpadAxis().x > 0) { * //if in the half of the red and green tri * redAm = 0.5f; * greenAm = 0.25f; * spellType = 0; * } * redAm = 0.25f; * greenAm = 0.5f; * spellType = 1; * } * if (myController.GetTouchpadAxisAngle() >= 120 && myController.GetTouchpadAxisAngle() < 150) { * blueAm = 0.5f; * spellType = 2; * //if in the first half of the blue tri * } * else if (myController.GetTouchpadAxisAngle() >= 150) { * blueAm = 1f; * //else if in the center of the blue tri * spellType = 2; * } * else { * blueAm = 0.25f; * //else if outside of blue * }*/ //detect if red //detect if green //detect if blue } if (myAngle >= 0 && myAngle < 120) { tarCol = Color.red; spellType = 0; } if (myAngle >= 120 && myAngle < 240) { tarCol = Color.green; spellType = 1; } if (myAngle >= 240) { tarCol = Color.blue; spellType = 2; } tarCol.a = ogValue; oldCol = crystalMaterial.material.color; } if (oldCol != tarCol) { realCol = Color.Lerp(oldCol, tarCol, colorLerpTime);// this doesn't work because it's setting it to a value between 0 and 1. colorLerpTime += 0.02f; } // I want to put this in update, and not use oldCol as a method of judgement. if (myController.touchpadPressed) { if (myController.GetTouchpadAxisAngle() <= 120) { if (myController.GetTouchpadAxis().x > 0) { realCol = new Color(1f, 0.25f, 0.25f, ogValue); } else { realCol = new Color(0.25f, 1f, 0.25f, ogValue); } } else { realCol = new Color(0.25f, 0.25f, 1f, ogValue); } } crystalMaterial.material.color = realCol; }