Search Unity

Bug OnScreenStick locking when dragging two at the same time

Discussion in 'Input System' started by saskenergy, Dec 14, 2020.

  1. saskenergy

    saskenergy

    Joined:
    Nov 24, 2018
    Posts:
    30
    Hey, folks. Has anyone else encountered a bug where the OnScreenStick freezes when dragging two sticks at the same time? This is of course on the new input system. I tested a build on Android and it happens on both a Mono and IL2CPP build. Here's a video of a simple project I recorded showing the bug (this is recorded on a Samsung Galaxy S9 Plus with "Show Taps" on in Developer options so you can see where I'm actively tapping):



    And here's another one:



    I'm using a slightly modified OnScreenStick that allows me to tap anywhere on the RectTransform and move the handle. Nothing fancy.

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using UnityEngine.EventSystems;
    4. using UnityEngine.InputSystem.Layouts;
    5. using UnityEngine.InputSystem.OnScreen;
    6.  
    7. [AddComponentMenu("Input/On-Screen Stick Stationary")]
    8. public class OnScreenStickCustom : OnScreenControl, IPointerDownHandler, IPointerUpHandler, IDragHandler
    9. {
    10.     [InputControl(layout = "Vector2")] [SerializeField]
    11.     private string stickControlPath;
    12.  
    13.     [SerializeField] private RectTransform handle = null;
    14.     [SerializeField] private float movementRange = 100;
    15.  
    16.     private RectTransform _rectTransform;
    17.     private Vector3 _handleStartPos;
    18.  
    19.     protected override string controlPathInternal
    20.     {
    21.         get => stickControlPath;
    22.         set => stickControlPath = value;
    23.     }
    24.  
    25.     private void Start()
    26.     {
    27.         _rectTransform = (RectTransform) transform;
    28.         _handleStartPos = handle.anchoredPosition;
    29.     }
    30.  
    31.     public void OnPointerDown(PointerEventData eventData)
    32.     {
    33.         OnDrag(eventData);
    34.     }
    35.  
    36.     public void OnDrag(PointerEventData eventData)
    37.     {
    38.         if (eventData == null)
    39.         {
    40.             Reset();
    41.             return;
    42.         }
    43.  
    44.         RectTransformUtility.ScreenPointToLocalPointInRectangle(_rectTransform, eventData.position,
    45.             eventData.pressEventCamera, out var position);
    46.         var delta = (Vector3) position - _handleStartPos;
    47.         delta = Vector2.ClampMagnitude(delta, movementRange);
    48.         handle.anchoredPosition = _handleStartPos + delta;
    49.  
    50.         var controlValue = new Vector2(delta.x / movementRange, delta.y / movementRange);
    51.         SendValueToControl(controlValue);
    52.     }
    53.  
    54.     public void OnPointerUp(PointerEventData eventData)
    55.     {
    56.         Reset();
    57.     }
    58.  
    59.     public void Reset()
    60.     {
    61.         handle.anchoredPosition = _handleStartPos;
    62.         SendValueToControl(Vector2.zero);
    63.     }
    64. }
    65.  
    I can also confirm that the joysticks from Joystick Pack (https://assetstore.unity.com/packages/tools/input-management/joystick-pack-107631) have this bug when the using the new input system or setting it to both.

    I've tested this on Unity versions 2019.4.16f LTS and 2020.1.17f.
    For the Input System, I've tried it on 1.0.1 verified and 1.1.0 preview 2.
    I've also built APKs on Linux (Ubuntu 20.04 LTS) and the latest version of Windows 10.

    This bug is currently active on the following devices:
    - Samsung Galaxy S9
    - Samsung Galaxy S9 Plus
    - Samsung Galaxy Note 8

    I'm guessing the bug shows on other devices too, I haven't tested them.
     
    BGCH and neroznikovyury like this.
  2. saskenergy

    saskenergy

    Joined:
    Nov 24, 2018
    Posts:
    30
    nongbenzgames likes this.
  3. saskenergy

    saskenergy

    Joined:
    Nov 24, 2018
    Posts:
    30
    QA team has responded and this issue has already been tracked since August. Weird that it has no votes, are people not using the new input system for mobile devices?

    Issue Tracker: https://issuetracker.unity3d.com/is...en-there-are-at-least-2-touches-on-the-screen

    As a workaround, I've used the Enhanced Touch API but the issue still exists, just infrequent. It doesn't happen on drag now but on quick taps (multiple fingers).
     
  4. amamaenko

    amamaenko

    Joined:
    Jun 2, 2013
    Posts:
    8
    I got the same issue on Unity 2020.2.0f1
    Input System: 1.1.0 preview 2
    Building on MacOS and testing on iPhone XR with iOS 14.2
    Thanks to @mk0a1a, apparently that's not me doing something stupid after originally implementing and testing multiple inputs back with Unity 2020.1.13f
     
    saskenergy likes this.
  5. nongbenzgames

    nongbenzgames

    Joined:
    Oct 8, 2018
    Posts:
    19
    That's my ticket submission ages ago though I'm pretty sure this has been bugged forever.

    "Move slow and break things"

    There are workarounds by checking active touch cound and resetting your buttons manually, but these are kind of hacky and not 100%.

    Not sure what's going on at Unity but mobile was the one area they had the edge over UE4, but they're handing that over too.
     
    saskenergy likes this.
  6. BGCH

    BGCH

    Joined:
    Nov 23, 2017
    Posts:
    20
    I have the same problem.
    Input System: 1.0.1 verified.
    It seems that OnPointerUp does not work when quickly interacting with two or more buttons.
    Unity please fix this. It makes me revert to the old input system
     
  7. saskenergy

    saskenergy

    Joined:
    Nov 24, 2018
    Posts:
    30
    Looks like they finally fixed it in v1.1 preview 3 (Check the issue tracker).
     
    BGCH likes this.