Search Unity

How do I make input.touch not work when button is clicked?

Discussion in 'Scripting' started by HowWeLife, Aug 1, 2015.

  1. HowWeLife

    HowWeLife

    Joined:
    Jul 4, 2015
    Posts:
    51
    I am using Input.Touches to have my character move, however at the same time I am using UIbuttons for things like jumping. But whenever I click on a Button the touch from Input.touhes also registers and moves the character. What can I do to prevent Input.Touches from making the character move (register the touch) whenever I tap on a button ? In other words is there away to make it so that when the UIButtons are clicked no Touch is registered?

    I tried setting the Button's to a z position of -100. I hoped it would put the buttons "on top" of whatever registers Input.touch, but I guess Input.touch doesn't have a position- it just registers very touch. Any Ideas?
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Got a couple. The video is written for mouse, but it's the same basic ideas.

     
    HowWeLife likes this.
  3. HowWeLife

    HowWeLife

    Joined:
    Jul 4, 2015
    Posts:
    51
    Perfect! Thank You!

    ps if anyone else is having trouble, to make this work on a touch screen do the first method the video shows and then add a 0 inside !EventSystem.current.IsPointerOverGameObject () so !EventSystem.current.IsPointerOverGameObject (0)
     
    Kiwasi likes this.