Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Question Questions about Input System with touch.

Discussion in 'Input System' started by TeacherMax, Feb 4, 2023.

  1. TeacherMax


    Jan 27, 2019
    I am developing a game in Unity primarily for Phone/Tablet.

    For my control system the screen is in landscape mode, and split into four quarters.

    Pressing bottom right will jump. Not a tap – as soon as it is touched the player should jump.

    Pressing bottom left will accelerate. Acceleration will be maintained until release.

    Pressing top right will fire a weapon. Holding will auto-fire.

    Pressing top left will perform ‘other functions’ depending on circumstances.

    Swiping left to right will turn the player to face right.

    Swiping right to left will turn the player to face left.

    I would like to use the ‘new’ input system, as I feel it will be able to achieve what I want flexibly and with minimal coding (although I am a code, so not afraid of getting in there)

    But I really can’t find any info regarding using multi touch – or at least how best to use multi touch.

    Here are some of the things I feel the input system probably allows me to do – but I don’t know how…

    1. When touching the screen, apply some filter so that my code is executed (via binding/processors ?) depending on the ‘quadrant’ touched/released.

    2. For (for example) the jump quadrant, my code is NOT called until the touch has been stationary for a short time (or this could be the start of a swipe)

    3. There is some way of handling multi-touch. As an example, the user presses accelerate then presses Fire then releases accelerate but keeps fire pressed– I might have touch 0 and touch 1 handing accelerate and fire respectively. But it could happen the other way – press and hold fire, then press accelerate, then release fire. How is that handled in code – as far as I can see, I’d have touch0 and touch1 each handing one thing, but handing a different thing depending on circumstances – so how does one handle that? Is it a case of looing through all the active touches and ‘following up’ on what they were doing (bearing in mind any of them could be handing the start of a swipe?)

    4. How can I handle the following: The user presses accelerate, keeps it pressed so the player is accelerating. Now the user swipes from left to right but doe not raise their finger.
    Desired behaviour: acceleration stops when the bottom left quadrant is exited, ‘turn to the right’ behaviour is triggered. Jump is not triggered

    I appreciate this is a lot of specific questions – and I’d appreciate answers to any portion, or all of them, or even generic methods of handling multi touch that I can look at – but at the moment I’m really stalled on this – I just feel there is a ‘sensible’ way of achieving what I’m after – but I don’t know what it is!
  2. MatanYamin


    Feb 2, 2022
    I was facing something similar to that. I needed a multi-touch system for my game and when I tried using the Input system with actions and bindings, I came across some issues on specific situations.

    After some research I found out that my best solution was to use "EnhancedTouchSupport" by the new Input system.
    You can reference a finger according to where it started and you can handle multiple situations on what to do with that. I recommend diving into that and look if it can be useful for your own use-cases.
    This video helped me a lot to understand the basics.
    Good luck
  3. TeacherMax


    Jan 27, 2019
    Thanks - I'm glad at least I'm not alone!
    I haven't seen that video before either so I will take a look.