PlayerAction lastAction; // Tracks the actively held down button/axi, to assist with the cooloff timer. // Use this for initialization. Occurs before Start(), will execute even if script is disabled (but not if gameObject is disabled). void Awake() { filteredDirection = new TwoAxisInputControl(); filteredDirection.StateThreshold = 0.5f; uiActions = UIActions.CreateWithDefaultBindings(); }
public void OnTriggerStay(Collider other) { // TODO: Vacuum if (m_tb) { if (other.gameObject.GetComponent <Vacuum>()) { Clean(); } else if (other.attachedRigidbody.GetComponent <Player>()) { Player player = other.attachedRigidbody.GetComponent <Player>(); TwoAxisInputControl movement = player.MovementControl; if (movement != null) { Dirty(movement.Vector.magnitude * 5.0f); } } else if (other.gameObject.GetComponent <Baby>()) { Dirty(other.GetComponent <NavMeshAgent>().velocity.magnitude + 1); } } }
public void UpdatePlayerInput() { rightStickInput = InputManager.ActiveDevice.RightStick; if (OnMovementEvent != null) { OnMovementEvent(InputManager.ActiveDevice.LeftStick); } if (OnLookEvent != null) { OnLookEvent(InputManager.ActiveDevice.RightStick); } if (InputManager.ActiveDevice.LeftBumper.IsPressed) { if (OnLeftBumperPressedEvent != null) { OnLeftBumperPressedEvent(); } } if (InputManager.ActiveDevice.RightBumper.IsPressed) { if (OnRightBumperPressedEvent != null) { OnRightBumperPressedEvent(); } } if (InputManager.ActiveDevice.Action1.WasReleased) { if (OnActionKeyPressedEvent != null) { OnActionKeyPressedEvent(); } } }
void AddAliasControls() { RemoveAliasControls(); if (IsKnown) { LeftStick = new TwoAxisInputControl(); RightStick = new TwoAxisInputControl(); DPad = new TwoAxisInputControl(); AddControl(InputControlType.LeftStickX, "Left Stick X"); AddControl(InputControlType.LeftStickY, "Left Stick Y"); AddControl(InputControlType.RightStickX, "Right Stick X"); AddControl(InputControlType.RightStickY, "Right Stick Y"); AddControl(InputControlType.DPadX, "DPad X"); AddControl(InputControlType.DPadY, "DPad Y"); #if UNITY_PS4 AddControl(InputControlType.Command, "OPTIONS button"); #else AddControl(InputControlType.Command, "Command"); #endif ExpireControlCache(); } }
public void DisableControls() { this.movementControl = null; this.rotateControl = null; this.characterSelectControl = null; this.characterSelectLeft = null; this.characterSelectRight = null; this.attackButton = null; this.interactButton = null; }
public PlayerControls(TwoAxisInputControl movementControl, TwoAxisInputControl rotateControl, TwoAxisInputControl characterSelectControl, InputControl characterSelectLeft, InputControl characterSelectRight, InputControl attackButton, InputControl interactButton) { this.movementControl = movementControl; this.rotateControl = rotateControl; this.characterSelectControl = characterSelectControl; this.characterSelectLeft = characterSelectLeft; this.characterSelectRight = characterSelectRight; this.attackButton = attackButton; this.interactButton = interactButton; }
// Use this for initialization public CursorActions() { Activate = CreatePlayerAction("Activate"); Left = CreatePlayerAction("Left"); Right = CreatePlayerAction("Right"); Up = CreatePlayerAction("Up"); Down = CreatePlayerAction("Down"); Move = CreateTwoAxisPlayerAction(Left, Right, Down, Up); Slow = CreatePlayerAction("Slow"); }
//Initialize PlayerControls stuct with default controls public PlayerControls(InputDevice device) { this.movementControl = device.LeftStick; this.rotateControl = device.LeftStick; this.characterSelectControl = device.RightStick; this.characterSelectLeft = device.LeftBumper; this.characterSelectRight = device.RightBumper; this.attackButton = device.Action1; this.interactButton = device.Action3; }
private static void Prefix(TwoAxisInputControl __instance, ref float x, ref float y) { try { var source = TwoAxis.GetValues(__instance).LastOrDefault(_ => _.Value != Vector2.zero); if (source != null) { x = source.Value.x; y = source.Value.y; } } catch (Exception exception) { Main.Logger.Exception(exception); } }
private static void Prefix(InControlInputModule __instance, ref TwoAxisInputControl ___direction) { try { if (!(Instance.Target is NavigateWithKeyboard navigate)) { return; } // avoid overwriting controller movement/presses __instance.MoveAction = ___direction.Vector == Vector2.zero ? navigate.Move : null; __instance.SubmitAction = !__instance.SubmitButton().IsPressed ? navigate.Submit : null; __instance.CancelAction = !__instance.CancelButton().IsPressed ? navigate.Cancel : null; } catch (Exception exception) { Main.Logger.Exception(exception); } }
void RemoveAliasControls() { LeftStick = null; RightStick = null; DPad = null; RemoveControl(InputControlType.LeftStickX); RemoveControl(InputControlType.LeftStickY); RemoveControl(InputControlType.RightStickX); RemoveControl(InputControlType.RightStickY); RemoveControl(InputControlType.DPadX); RemoveControl(InputControlType.DPadY); RemoveControl(InputControlType.Command); ExpireControlCache(); }
private void FixedUpdate() { TwoAxisInputControl movement = MovementControl; if (movement != null) { // TODO: Handle movement if (movement.Vector != Vector2.zero) { float angle = movement.Angle; m_rigidbody.MoveRotation(Quaternion.Euler(0, 180 + angle, 0)); Vector2 dir = movement.Vector; m_rigidbody.MovePosition(m_rigidbody.position + new Vector3(dir.x, 0, dir.y) * m_moveSpeed * Time.fixedDeltaTime); } } }
//UseConnectedCanvas void UseConnectedCanvas() { //Se deplacer dans un Canvas connecte if (controller.Action1.WasPressed && button1Ready) { connectedCanvas.button1 = true; StartCoroutine("Button1Wait"); } if (controller.Action2.WasPressed && button2Ready) { connectedCanvas.button2 = true; StartCoroutine("Button2Wait"); } if (controller.Direction.WasPressed && directionReady) { TwoAxisInputControl zzz = controller.Direction; //Conversion de l'angle du stick en direction Haut Droite Bas Gauche int angle = Mathf.RoundToInt(zzz.Angle); if (angle > 315 || angle <= 45) { //Debug.Log("1"); connectedCanvas.up = true; } else if (angle > 45 && angle <= 135) { //Debug.Log("2"); connectedCanvas.left = true; } else if (angle > 135 && angle <= 215) { //Debug.Log("3"); connectedCanvas.down = true; } else if (angle > 215 && angle <= 315) { //Debug.Log("4"); connectedCanvas.right = true; } StartCoroutine("DirectionWait"); } }
void Awake() { filteredDirection = new TwoAxisInputControl(); filteredDirection.StateThreshold = 0.5f; }
void Awake() { filteredDirection = new TwoAxisInputControl(); filteredDirection.StateThreshold = 0.5f; state = EBtnPageState.eStandby; }
public static void Link(TwoAxisInputControl source, TwoAxisInputControl target) => TwoAxis.Add(target, source);
private void CheckController(InputControl trigger, InputControl bumper, InputControl stickButton, TwoAxisInputControl stick, int selectedNum, Ray controller) { if (trigger.IsPressed) { if (SelectedObject[selectedNum] == null) { Collider[] hits = Physics.OverlapSphere(controller.origin, 0.1f, 1 << BuiltLayer);; if (hits.Length > 0) { Collider closest = hits.OrderBy(hit => Vector3.Distance(hit.transform.position, controller.origin)).First(); SelectedObject[selectedNum] = closest.transform; } else { SelectedObject[selectedNum] = GameObject.CreatePrimitive(PrimitiveType.Cube).transform; SelectedObject[selectedNum].GetComponent <Renderer>().material.color = CurrentColors[selectedNum]; SelectedObject[selectedNum].gameObject.layer = BuiltLayer; StartCoroutine(PopIn(SelectedObject[selectedNum])); } } SelectedObject[selectedNum].position = controller.origin; } else { SelectedObject[selectedNum] = null; } if (stickButton.IsPressed) { if (ColorWheels[selectedNum] == null) { ColorWheels[selectedNum] = GameObject.Instantiate(ColorWheelPrefab).GetComponent <ColorWheel>(); } CurrentColors[selectedNum] = ColorWheels[selectedNum].Select(stick.Vector); if (SelectedObject[selectedNum] != null) { SelectedObject[selectedNum].GetComponent <Renderer>().material.color = CurrentColors[selectedNum]; } ColorWheels[selectedNum].transform.position = controller.origin; ColorWheels[selectedNum].transform.LookAt(KinectManager.Instance.CurrentAvatar.Head); } else { if (ColorWheels[selectedNum] != null) { Destroy(ColorWheels[selectedNum].gameObject); } } if (bumper.IsPressed) { if (GunAim[selectedNum] == null) { GunAim[selectedNum] = GameObject.Instantiate(AimPrefab).GetComponent <Aim>(); } GunAim[selectedNum].DoUpdate(controller.origin, controller.direction); } else { if (GunAim[selectedNum] != null) { Destroy(GunAim[selectedNum].gameObject); GameObject bullet = GameObject.Instantiate <GameObject>(BulletPrefab); bullet.GetComponent <Bullet>().Launch(controller); } } }
protected ShallowGamesInputModule() { direction = new TwoAxisInputControl(); direction.StateThreshold = analogMoveThreshold; instance = this; }
public void UpdateTouchButtonPad() { #if JamToolsUseInControl var device = TouchManager.Device; if (device != null) { InputControl button = device.GetControl(this.button); TwoAxisInputControl stick = device.RightStick; if (this.stick == TouchControl.AnalogTarget.LeftStick) { stick = device.LeftStick; } Vector2 stickValue = stick.Value; if (button.Target == this.button) { if (button.WasPressed) { //Debug.Log("press"); tapReleasedTimer = tapReleaseWindow; fired = false; } else if (button.WasReleased) { if (tapReleasedTimer > 0 && !fired) { //Debug.Log("release jump"); if (touchButtonPadActions[(int)TouchButtonPadAction.Tap] != null) { touchButtonPadActions[(int)TouchButtonPadAction.Tap].Invoke(); fired = true; } } } else if (button.IsPressed) { if (tapReleasedTimer > 0) { if (!fired && touchButtonPadActions[(int)TouchButtonPadAction.SwipeUp] != null && stickValue.y > dragDistance) { touchButtonPadActions[(int)TouchButtonPadAction.SwipeUp].Invoke(); fired = true; } if (!fired && touchButtonPadActions[(int)TouchButtonPadAction.SwipeDown] != null && stickValue.y < -dragDistance) { touchButtonPadActions[(int)TouchButtonPadAction.SwipeDown].Invoke(); fired = true; } if (!fired && touchButtonPadActions[(int)TouchButtonPadAction.SwipeLeft] != null && stickValue.x < -dragDistance) { touchButtonPadActions[(int)TouchButtonPadAction.SwipeLeft].Invoke(); fired = true; } if (!fired && touchButtonPadActions[(int)TouchButtonPadAction.SwipeRight] != null && stickValue.x > dragDistance) { touchButtonPadActions[(int)TouchButtonPadAction.SwipeRight].Invoke(); fired = true; } tapReleasedTimer -= Time.deltaTime; if (tapReleasedTimer <= 0 && !fired) { //Debug.Log("timeout jump"); if (touchButtonPadActions[(int)TouchButtonPadAction.Tap] != null) { touchButtonPadActions[(int)TouchButtonPadAction.Tap].Invoke(); fired = true; } } } } } } #endif }