Author Topic: Help getting Joystick to ignore input from separate touches  (Read 3026 times)

JumpDog

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Hi guys,

I just implemented the joystick script found here into my project: http://www.tasharen.com/?topic=an-ngui-virtual-joystick-solution

I've got it fixed and sync'd with another script to move the player around, sitting on the bottom-left corner of the screen. I'm also adding 2-3 buttons on the right side of the screen. Unfortunately, while holding/dragging the joystick, any touches on the buttons on the other side of the screen influence it (I cannot move left while pressing a button that's on the right of the screen). If I hold the button and THEN activate the joystick, it doesn't seem to affect it anymore no matter how many times I press the button. Obviously this isn't a fix.

I'm not a pro at programming. I've tried adding a bool to check if the joystick is already pressed, and another to assign a touchID and only take inputs from that. If me posting here wasn't clear enough, my attempts failed. So if anyone can help me out with this it would be very much appreciated. Or perhaps someone else has used this joystick and already implemented a fix for this?

Thanks

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: Help getting Joystick to ignore input from separate touches
« Reply #1 on: June 10, 2012, 11:22:36 PM »
Sounds to me like you are just searching for the first input pressed when you should be scanning for all presses.

JumpDog

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: Help getting Joystick to ignore input from separate touches
« Reply #2 on: June 11, 2012, 12:05:20 AM »
No that's the opposite of what I want. I do only want the first press on the joystick, I don't want other presses that aren't near the joystick to influence it while it's being dragged.

yuewah

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 180
    • View Profile
Re: Help getting Joystick to ignore input from separate touches
« Reply #3 on: June 11, 2012, 03:17:12 AM »
If you are using only single joypad and some other buttons (i.e. two joypads is not work). I have a workaround.

add the following line to the beginning of OnDrag() in UIJoystick.cs
  1. if ( UICamera.currentTouchID != 0 ) return;