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

[C# / Touch input / Mobile] Question regarding touch input

Discussion in 'Scripting' started by lkarus, May 27, 2015.

  1. lkarus

    lkarus

    Joined:
    Feb 25, 2015
    Posts:
    51
    So currently I'm implementing a virtual joystick that will appear at the location where the user touches. So if the user touches the near the lower left side of the screen or the uppper right side of the screen, a virtual joystick will appear and while holding down, the user can move their character around.

    Now comes the problem. I am thinking of having skill buttons or any other interactive UI's. How will I be able to figure out whether I planned to touch this UI or want to move my character. The way I am thinking is, I have to do a distance check from the position of my input to the UI button that I want to interact in screen space, and if they are super near (lets say 0.01f), I will ignore the joystick part and do whatever the interactive UI should do.

    Is this a good approach? Or is there a better / efficient way to do so?
    Thank you in advance!

    P.S. The title of the thread sucks, but it was the best I can do to describe the situation without having a long title.
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    are you using the new ui from 4.6 or higher?
     
  3. lkarus

    lkarus

    Joined:
    Feb 25, 2015
    Posts:
    51
    I haven't started doing the interactive UI stuff, but yeah since I'm using Unity 4.6, I think that is what I will be using.

    Edit : For the virtual joysticks, I'm not using UI stuff that are provided from Unity. I'm creating my own script that will get the information from Touch / TouchPhases and I will be rendering my Texture2D at that position. Wasnt sure which one you were asking so just decided to write both.
     
  4. lkarus

    lkarus

    Joined:
    Feb 25, 2015
    Posts:
    51
    Bump anyone?