Search Unity

gui buttons multitouch

Discussion in 'Immediate Mode GUI (IMGUI)' started by demozbox, Sep 10, 2015.

  1. demozbox

    demozbox

    Joined:
    Nov 26, 2014
    Posts:
    83
    hi . Is there simple way to start working gui buttons while multitouch?
    want to make my hero able to jump while walking.
    and also i have a inventory which i want to use while walking.
    THanks fow any help
     
  2. garza

    garza

    Joined:
    Dec 18, 2013
    Posts:
    30
    this is my TouchButton.cs class
    you'll need to reference it in your player control script, like so

    ...
    //theLeftandRightButtons
    private TouchButton LeftButton;
    private TouchButton RightButton;

    //theJumpButton
    private TouchButton JumpButton;
    ...
    voidStart ()
    {
    //settheLeftandRightButtons
    LeftButton = GameObject.Find ("LeftButton").GetComponent<TouchButton>();
    RightButton = GameObject.Find ("RightButton").GetComponent<TouchButton>();

    JumpButton = GameObject.Find ("JumpButton").GetComponent<TouchButton>();
    }
    ...

    voidFixedUpdate ()
    {
    //ifyourtouchisovertheLeftButton...rollleft
    if (LeftButton.isTrue)
    {
    //go left
    }

    //ifyourtouchisovertheRightButton...rollleft
    if (RightButton.isTrue)
    {
    //go right
    }

    if (JumpButton.isTrue)
    {
    //jump
    }

    ...

    i used this in my game
    https://www.assetstore.unity3d.com/en/#!/content/40229
     

    Attached Files: