private void Update() { Vector2 buttonPosition = TBInput.GetAxis2D(_button, _controller); Vector3 newPosition = new Vector3(buttonPosition.x * 8f, buttonPosition.y * 8f, 0f); transform.localPosition = newPosition; }
private void AnimateControllerModel() { if (TBInput.GetAxis1D(TBInput.Button.PrimaryTrigger, controller) > triggerThreshold) { triggerRepresentation.transform.localRotation = Quaternion.Euler(-10.0f, -180.0f, 0.0f); } else { triggerRepresentation.transform.localRotation = Quaternion.Euler(10.0f, -180.0f, 0.0f); } Vector2 joyPos = TBInput.GetAxis2D(TBInput.Button.Joystick, controller); analogRepresentation.transform.localRotation = Quaternion.Euler(-joyPos.y * 30.0f, 180.0f, joyPos.x * 30.0f); }
private void DetectTouchpadInputs(out bool actionTeleportation, out bool shiftLeft, out bool shiftRight) { actionTeleportation = false; shiftLeft = false; shiftRight = false; /* on touch start, note current touch position and prepare for shift */ Vector2 touchpadPosition = TBInput.GetAxis2D(TBInput.Button.Touchpad, controller); if (TBInput.GetTouchDown(TBInput.Button.Action1, controller)) { touchpadPrepareForShift = true; touchpadPositionOnTouchStart = touchpadPosition; } /* on touchpad release, check whether shift flag is still up and whether minimum threshold is met */ else if (TBInput.GetTouchUp(TBInput.Button.Action1, controller) && touchpadPrepareForShift) { touchpadPrepareForShift = false; if (Mathf.Abs(touchpadPosition.x - touchpadPositionOnTouchStart.x) > touchpadSwipeThreshold) { if (touchpadPosition.x < touchpadPositionOnTouchStart.x) { shiftLeft = true; } else { shiftRight = true; } } } /* when button is clicked, initiate teleport and cancel shift */ if (TBInput.GetButton(TBInput.Button.Action1, controller)) { touchpadPrepareForShift = false; actionTeleportation = true; } }
private void DetectJoystickInputs(out bool actionTeleportation, out bool shiftLeft, out bool shiftRight) { actionTeleportation = false; shiftLeft = false; shiftRight = false; /* joystick is pulled toward or away from player -> teleport */ Vector2 joystickPosition = TBInput.GetAxis2D(TBInput.Button.Joystick, controller); if (Mathf.Abs(joystickPosition.y) > joystickThreshold) { actionTeleportation = true; } /* joystick is pulled to the right -> blink shift to right */ else if (joystickPosition.x > joystickThreshold) { if (!shiftInitiated) { shiftRight = true; shiftInitiated = true; } } /* joystick is pulled to the left -> blink shift to left */ else if (joystickPosition.x < -joystickThreshold) { if (!shiftInitiated) { shiftLeft = true; shiftInitiated = true; } } else { shiftInitiated = false; } }