Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Click problems on mobile.

Discussion in 'Editor & General Support' started by will_brett, Apr 18, 2014.

  1. will_brett

    will_brett

    Joined:
    Feb 16, 2013
    Posts:
    208
    Im building a game that uses a click to move a character around the screen, a drag to move a camera around a screen and a click for gui objects.

    The issue is these inputs all clash with each other for example, dragging the camera also moves the player. clicking a gui button also moves the player.

    There has to be a solution to this problem as touches are the main if not only way to interact with tablets and phones.

    I've spent ages trying different things and scouring the internet for answers but have not found one yet. Any help would be incredibly well received.

    Thanks you
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    The best way to fix this seems to be to build a "GUI Master" class that takes all input, figures out where it needs to go, and sends it there. Something along the lines of this (in the barest pseudocode):

    If a tap is on a GUI element, send it there.
    Else, start tracking the tap.
    If the tap moves before it is lifted, start using it to drag the camera.
    if the tap is lifted without moving, move the character there (or interact with whatever was tapped on).
     
  3. will_brett

    will_brett

    Joined:
    Feb 16, 2013
    Posts:
    208
    Thanks StarManta.

    I think this is the correct way to go about it but I think its a bit above my skill level. I will give it a shot but I'm not keeping my hopes up.