playMaker

Author Topic: Why doesn't Touch Object 2D Event have 'Not Touching' like Touch GUI event??  (Read 12428 times)

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Hi guys,
Why doesn't Touch Object 2D Event have 'Not Touching' like Touch GUI event?? It means you can press down on a 2d collider, slide your finger off and the collider is still down.

Surely it should be able to detect if the 2d Object is no longer being touched??

Is there a fix for this, while still using 2D colliders?

Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

 you can know this by listening to the enter and exit events ( you are using the unity 2d package from the wiki right?), and when it exits, it's not touching basically.

 If you have experimented with this and isn't what you expect, can ou detail what you want to achieve?


 Bye,

 Jean

4ppleseed

  • Full Member
  • ***
  • Posts: 226
You mean the 2D proxy? I don't think I have that in my scene, maybe that's the way to go?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

 2D is not supported by default, you will need to use the Package provided on the wiki to work with physics 2d and 2d colliders.

https://hutonggames.fogbugz.com/default.asp?W1150

 Bye,

 Jean

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Hi,

 you can know this by listening to the enter and exit events ( you are using the unity 2d package from the wiki right?), and when it exits, it's not touching basically.

 If you have experimented with this and isn't what you expect, can ou detail what you want to achieve?


 Bye,

 Jean

Hi Jean, I tried but I can't get it to work.

I want a button that you can press down and when you let go it pops back up. So far no problems. What happens next is you press the button down, slide your finger away from the button and it stays down.

I've added a 2Dproxy to the game object and have selected the Collision 2D Exit event and tried the Collision 2D Exit Global event but I can't make it go back to the Button UP state when I slide my finger away from the button and move out of the collision touch space.

Where am I going wrong?

Thanks.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

 that's a typical requirement from the User Experience logic, you won't get the up event if you have downed on a element then moved outside of it. it's the same with your OS, try to mouse down on a button, move away from the button and release, you won't fire any action.

 Bye,

 Jean

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Hi Jean,
And if I don't want the usual logic? Touch GUI event has a 'Not Touching' event, that would trigger when it wasn't being touched any more.

Surely most virtual controls/UI need to know the player has moved off the controls??

Touch Object 2D Event having a 'Not Touching' event seems so logical to me.

Other people have raised this issue in the past:
http://hutonggames.com/playmakerforum/index.php?topic=9335.msg44537#msg44537

Thanks.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

 unfortunatly, I am not sure there is a way unless you implement a raw set of scripts listening to raw inputs from Unity and make it up, raycasting the 3d world and firing the up event even if exited the element it was down on.

 even the new UI system and eventSystem engine doesn't fire the up event if you are not over the element you where down on.

Can you explain your use case? maybe there is a way ( I am sure there is actually), but I need more context as to what you want to achieve.

Also, you will find a lot of third party systems implementing their own input management, like ngui, input.touches, and I know for a fact that Input.touche do fire input events regardless of the context, it's completly agnostice to whats in the ui or 3d, it may be an option for you and it has support for PlayMaker on the wiki. However, I must warn you that it's raw, that is you'll have to raycast and find out manually what is underneath the mouse or touch.

https://hutonggames.fogbugz.com/default.asp?W961

 Bye,

 Jean

4ppleseed

  • Full Member
  • ***
  • Posts: 226
It's pretty simple. I have a Move Left button next to a Move Right button. It's a two player game so there is a pair of these buttons in each corner of the screen. It's a pretty frantic game so players will be holding down the Left Button, slide their finger over to the Right Button and the Left Button will remain down. It makes the gameplay confusing and not fun, as you never fully feel in control.



4ppleseed

  • Full Member
  • ***
  • Posts: 226
Maybe I could fire a cancel event to Left Button when Right Button is touched?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

 no react on down, not up, so implement everything on MOUSE DOWN system event.

4ppleseed

  • Full Member
  • ***
  • Posts: 226
I got this working last night but it's such a long winded way  :(

Touch Object 2D Event, Get Touch Info, Store X and Y to floats, compare to where the button is. If lesser/greater than tolerance, cancel touch event.

That for all four buttons! So each has it's own Finger ID etc... it's really messy and I fear won't work when the screen is scaled?

I can't believe there isn't a simpler way to detect if a 2d object that was pressed down, has been moved away from in Playmaker :o
« Last Edit: March 06, 2015, 06:29:02 AM by 4ppleseed »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

 Dealing with individual finger id is mandatory, else it's unreliable, this is the way unity works, and actually logical, since you can have many simultaneous touches, you need to keep track of the right touch for a particular button.

I don't think there is a simple way even in scripts. If you find script that does what you need, let me know, I'll see how it's been made and work out a solution in PlayMaker if it turns out simple.

Bye,

 Jean

allornothing

  • Playmaker Newbie
  • *
  • Posts: 20
not 100% sure how to set up in playmaker/unity, but I solved the same problem in another engine by spawning a small object at the touch position, and then monitoring the collision between the touch object and the button. Releasing touch destroys the object.

Should be simple enough to implement in playmaker, would that work here?

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Hi,

 Dealing with individual finger id is mandatory, else it's unreliable, this is the way unity works, and actually logical, since you can have many simultaneous touches, you need to keep track of the right touch for a particular button.

I don't think there is a simple way even in scripts. If you find script that does what you need, let me know, I'll see how it's been made and work out a solution in PlayMaker if it turns out simple.

Bye,

 Jean

Thanks Jean. Would what I'm trying to do work if we still used 'Touch GUI' with the 'Not Touching' event? I never used it but it seemed like it was for this purpose.