# 6. Mobile Input Pitfalls Part of [[Mobile Input and Touch]]. Prev: [[5. Worked Example On-Screen Stick Player]]. ## Stick snaps back to center while the thumb is down Classic `PlayerInput` auto-switch vs simulated Gamepad events. Official fix: `OnScreenStick.useIsolatedInputActions = true`. If you left isolated mode off "to keep it simple," you built the bug the 1.20.1 manual exists to describe. ## Two readers, double movement Polling `Touch.activeTouches` *and* reading the Move action the stick already writes. Or a second generated action class beside `PlayerInput`. One authority for Move. ## No EventSystem / no raycast target / full-screen blocker `OnScreenStick` is EventSystem-driven. A missing EventSystem, a Graphic with Raycast Target off, or a full-screen invisible Image on top of the stick will look like "the Input System is broken." ## Polling `Touchscreen` in `Update` instead of Enhanced Touch Official touch-polling warning: you can miss contacts that start and end inside one update. Call `EnhancedTouchSupport.Enable()` before `Touch.activeTouches`. Forgetting `Enable` throws `InvalidOperationException`. Forgetting to `Disable` in a matching `OnDisable` leaves the extra work running (and `Enable`/`Disable` are reference-counted). ## `UnityEngine.Touch` vs `EnhancedTouch.Touch` Name clash. Use the official alias `using Touch = UnityEngine.InputSystem.EnhancedTouch.Touch`. ## Believing the Device Simulator on multitouch, performance, or `UNITY_IOS` Official 6000.5 limits: **one finger**, Play Mode only, no performance or rendering simulation, no platform defines, no gyroscope. A two-finger gesture that "fails" in the Simulator has not been tested. `#if UNITY_IOS` will not become true because you picked an iPhone in the dropdown. ## Clicking the Game view and "the Simulator died" Official active-view rules: focusing a Game view disables simulators. Click back on the Simulator view. ## Safe area ignored Sticks under a notch or home indicator. Use `Screen.safeArea` and re-apply on rotation. ## Rebinding the virtual stick [[3. Runtime Rebinding]] is for physical controls the player can swap. An on-screen stick is layout, not a bind you offer in the rebind UI. Rebind keyboard / gamepad as before; leave the overlay on `<Gamepad>/leftStick`. ## OnScreenButton and isolated input Do not copy `useIsolatedInputActions` onto `OnScreenButton` in 1.20.1 unless IntelliSense shows it. The official button page is pointer-down = 1, pointer-up = 0, path must be a Button control. ## Invented Simulator or Input System versions This series cites Input System **1.20.1** manuals and the 6000.5 Device Simulator page. A search snippet that mentions a different Input System major version is not a source for flags in this course. Confirm simulate-touch-from-mouse options in the **installed** 1.20.x Input Debugger if you need them. ## "It works in the Editor Game view at 1920×1080" The assignment includes a Simulator notch device and, if you have one, a player build on a phone. Desktop Game view is necessary but not sufficient. ## Sources - https://docs.unity3d.com/Packages/[email protected]/manual/create-on-screen-stick-control.html - https://docs.unity3d.com/Packages/[email protected]/manual/touch-polling.html - https://docs.unity3d.com/6000.5/Documentation/Manual/device-simulator-introduction.html