Search Unity

Question OnScreenStick with button functionality

Discussion in 'Input System' started by skiwee, Feb 18, 2021.

  1. skiwee

    skiwee

    Joined:
    May 30, 2020
    Posts:
    32
    Recently I started looking at onscreen mobile controls in the new input system. The behavior I was looking for was a mix between joystick and button. Basically the goal is when the user clicks it, it acts as a button, then if the user holds it down and drags, it acts as a joystick. The joystick part was smooth and clean with the OnScreenStick component, which I set the control path to gamepad right stick. Then when I tried to use right stick press as an input in the inputactions editor the OnScreenStick does not seem to have button functionality. I think I might have to write a class outside of the inputactions framework that implements IPointerDownHandler and IPointerUpHandler but I have no idea how to do so, and if there is a way to connect such a class with the rest of the input system, that would be even better.
     
  2. skiwee

    skiwee

    Joined:
    May 30, 2020
    Posts:
    32
    Another idea that I had was make a button on top of the joystick to act as the button portion, and when held down the button disappears and the joystick takes over. But the problem is when the button disappears how do I transfer the OnPointerDown to the joystick. Currently when I hold the button and it disappears, the joystick appears but I need to release and then put my finger back down to use the joystick. If I could make the transition seemless between button and joystick that could be another solution.