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

Simple iPhone Game Controls?

Discussion in 'iOS and tvOS' started by Jaun7707, Oct 11, 2010.

  1. Jaun7707

    Jaun7707

    Joined:
    Oct 11, 2010
    Posts:
    11
    Hi, I am really new to unity iPhone and coding in general, and lately I have been having trouble making GUI controls. I want to make a character move by four arrow keys on the screen of the iPhone. I have tried some touch detectores on the iPhone screen before but the problem is, when you touch an arrow you can't touch the another at the same time (you have to touch one at a time or it cancels the action of the second touched one). Any help would be greatly appreciated. Thanks
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Hi, welcome to the forum!

    As you say, the GUI system can only handle a single touch at a time. However, you can define rectangles on screen using the Rect class and check if a touch is within the rectangle using Rect.Contains. The separate touches on the screen can be retrieved using the Input.touches array (the manual page has a code sample showing how to use the touch data).
     
  3. Jaun7707

    Jaun7707

    Joined:
    Oct 11, 2010
    Posts:
    11
    Thank you very much for responding! However, I dont really get how touch inputs work with unity, so could you write me a guideline of how it should look or something like that. Thanks again for the help!
     
  4. Jaun7707

    Jaun7707

    Joined:
    Oct 11, 2010
    Posts:
    11
    Okay actually I got the Rect.Contains method to work but I have been using through a Input.GetMouseButton. So Is there a way to have multiple mouse clicks?
     
  5. Jaun7707

    Jaun7707

    Joined:
    Oct 11, 2010
    Posts:
    11
    never mind i got it