On Screen Controls not working correctly.

I have used the On Screen controls, creating both a stick and a few buttons, but i cannot seem to get the sticks to work. The strange thing is that they move, but the input is not actually used, the object doesnt move. The object does move and work perfectly if i drag the sticks in the editor on my pc, anyone have any ideas what might be wrong?

Thanks!

(Let me know if further information is desired, or what information.)

So it works in the editor but does not work in the player? Which platform?

And the buttons work but the stick does not? Or none of the controls work?

It also doesn’t work, from debugging I can see that the component works, but the Player Input does not receive the event

I got it working in the end… cant remember what i changed tho hehe

I got the same problem! when i use player input, i hardly can drag the onscreen stick and the action hardly be triggered. if I don’t use player input, I can drag the controll smoothly, but still have no action be triggerd

2 Likes

Hmmm, any solution for this? I have the same problem that OnScreenControl (LeftStick [GamePad]) works until I add the PlayerInput script on the scene.

I found that PlayerInput Auto-Switch was causing jittering and to get it to work in the editor I needed to set manually input.SwitchCurrentControlScheme(“Keyboard&Mouse”); to remove all devices.

1 Like

Same problem. I drag the stick on my phone and it registers for about a second then stops. I have to wiggle my finger to get continuous movement

Same problem and sadly the official Input System tutorial’s source code doesn’t containt the On Screen controllers (and if you add it still doesn’t work :() but(!) I have found 2 solutions for this.

The main problem is with the PlayerInput script, because for some reason it sends “canceled” input event immediately after the "performed" event, so you can create a bunch of if statement, and predictions to check the cancel event is fake, or:

1.) Instantiate the input action from the action map by yourself and enable/disable it on the correct lifecycle event (OnEnable, OnDisable).
If it’s enabled you can read the value from it in the Update() like in the “old” input system.
You can check this video, and focus on the assets → c# script generation and usage.

2.) The second solution is to obtain the asset itself (e.g. create a serialized field and drag that into it) and get the action mappings and actions from it. After that, you can enable/disable the action and add/remove the correct listeners to it.

Here is a sample code:

[SerializedField]
InputActionAsset controls;

InputAction movement;
InputAction useAction;
InputAction attackAction;

...

void Awake()
{
  var actionMap = controls.FindActionMap("Player");

  movement = actionMap.FindAction("Move");
  useAction = actionMap.FindAction("Use");
  attackAction = actionMap.FindAction("Attack");
  specialAction = actionMap.FindAction("Special");
}

...

void OnEnable()
{
  movement.Enable();
  useAction.Enable();
  attackAction.Enable();
  specialAction.Enable();

  movement.performed += OnMove;
  useAction.performed += OnUse;
  attackAction.performed += OnAttack;
  specialAction.performed += OnSpecial;
}
2 Likes

I subscribe to the things mentioned above, PlayerInput 1.2.0 doesn’t work with On-screen Stick

yes, On-screen Stick seems to be broken in 1.1.1 and 1.2.0.

I wrote a possible fix/replacement for the PlayerInput class, for example if you want to use Move action’s event you’ll need to make OnMove like I did below

 [SerializeField] private InputActionAsset inputControls;
    private InputAction[] inputActions;
    private void Awake()
    {

        InputActionMap actionMap = inputControls.FindActionMap("Player");

        inputActions = actionMap.actions.ToArray();
    }
    private void OnEnable()
    {
        foreach (var action in inputActions)
        {
            action.Enable();
            action.performed += ProcessInput;
            action.canceled += ProcessInput;

        }

    }
    private void OnDisable()
    {
        foreach (var action in inputActions)
        {
            action.Disable();
            action.performed -= ProcessInput;
            action.canceled -= ProcessInput;

        }
    }
    private void ProcessInput(CallbackContext callbackContext)
    {
        SendMessage($"On{callbackContext.action.name}", callbackContext, SendMessageOptions.DontRequireReceiver);
    }
    private void OnMove(CallbackContext callbackContext)
    {
        Vector2 currentInput = callbackContext.ReadValue<Vector2>();

    }

The auto-switch on PlayerInput can cause jittering.To avoid this, there are 2 solutions (I use the second one) :

  • disable auto-switch and select manually ControlScheme playerInput.SwitchCurrentControlScheme(new InputDevice[ ]{ inputDevice })
  • enable auto-switch but edit ControlScheme (top left button in the InputActionAsset editor) and add Touchscreen device as optionnal
3 Likes

It is also broken on 1.3.0

2 Likes

yeah and i gave up the new input system for my game controll. Using “Touch Control Kit” now, which seems stable (at least so far). Its available in Asset Store at following link:-
https://assetstore.unity.com/packages/tools/input-management/touch-controls-kit-lite-41395#reviews

1 Like

the cancelled event is fired when the joystick moves, so it moves, and then it cancels outs.

1 Like

still waiting for a fix lol

5 Likes

After investing so much time in the new input system only to find out it needs some hacks to work on mobile. I will gladly revert back to the old input system or look some third party option.

Hi there !
I just figured out that I had no EventSystem in the scene. Therefore the On-Screen Stick cannot work. I also had to replace the StandaloneInputModule with the new input system version (Unity kindly offer a button to do that)

I hope it can help someone !

Still an issue in Input System 1.5.0

Not sure is its’s the same case, anyways might be related to the update type. Change InputSystem update type to manual and invoke InputSystem.current.Update() (don’t remember the exact syntax) within a MonoBehaviour Update()