void Update() { #if UNITY_ANDROID || UNITY_IOS if (SettingsManager.MobileControl == MobileControlMode.Tilt) { holdFly = Input.GetMouseButton(0); accelerationX = Input.acceleration.x; } else { if (accelerationX != 0) { accelerationX = 0; } holdFly = MobileInputManager.GetAxis("Vertical") == 1; axisHorizontal = MobileInputManager.GetAxis("Horizontal"); } #else holdFly = Input.GetButton("Fly") || Input.GetAxisRaw("Vertical") == 1; axisHorizontal = Input.GetAxis("Horizontal"); #endif TurnJetpack(holdFly); Vector3 scale = transform.localScale; if (rb2d.velocity.normalized.x > 0) { scale.x = 1; } else if (rb2d.velocity.normalized.x < 0) { scale.x = -1; } transform.localScale = scale; transform.rotation = Quaternion.Euler(0, 0, -(rb2d.velocity.x * 3)); audioSource.mute = !holdFly || !enabled; if (Input.GetButtonDown("Cancel")) { if (StageManager.Instance.IsPaused) { StageManager.Instance.Resume(); } else { StageManager.Instance.Pause(); } } Vector2 center = new Vector2(transform.position.x, coll.bounds.min.y); RaycastHit2D grounded = Physics2D.BoxCast(center, groundCheckSize, 0, Vector2.down, 0, groundLayer); Anim.SetBool("flying", !grounded); }
// ================================ // Game Completion // ================================ /// <summary> /// Called to disable input control in the event of game events or game completion /// </summary> public void RemoveInputSystems() { Debug.LogWarning("Lockout Triggered"); DesktopInputManager desktopinput = this.GetComponent <DesktopInputManager>(); Destroy(desktopinput); MobileInputManager mobileInput = this.GetComponent <MobileInputManager>(); Destroy(mobileInput); }
/// <summary> /// Initiates the desktop input system for this player /// </summary> private void BeginDesktopInputSystem() { playerInput.SwitchCurrentActionMap("Desktop"); MobileInputManager mobileInput = this.GetComponent <MobileInputManager>(); mobileInput.enabled = false; IDesktopInput deskTopInput = this.GetComponent <IDesktopInput>(); deskTopInput.InitialiseDesktop(); }
private void Update() { axisText.text = string.Format("Axis: {0}", MobileInputManager.GetAxis("Horizontal")); }
protected override void Start() { base.Start(); inputManager = GetComponent <MobileInputManager>(); }
public void OnPointerExit(PointerEventData eventData) { MobileInputManager.SetAxis(axis, 0); image.color = disabledColor; image.sprite = pressedSprite; }
public void OnPointerEnter(PointerEventData eventData) { MobileInputManager.SetAxis(axis, axisValue); image.color = enabledColor; image.sprite = normalSprite; }
private void Awake() { instance = this; }