playMaker

Author Topic: best practice for mouse event and touch event handling  (Read 7251 times)

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
best practice for mouse event and touch event handling
« on: April 01, 2014, 09:20:26 AM »
Hi,

I made an FSM that handles mouse events (for testing purposes) and ALSO touch events, but the mouse events will not be needed once the application is deployed to some touch enabled device. Right?

So the question is: Can those unnecessary mouse stuffs cause any problems? (I know: it depends, and sure they can.)
But would it be wiser to separate the mouse interaction from the touch interaction into separate FSM (maybe even separate empty objects) then disable them when building the project for a touch device?

Some documentation about frequently asked questions and best practices to do common things would be very much appreciated.

Thanks in advance,
Peter

sebaslive

  • Hero Member
  • *****
  • Posts: 572
    • Frame Tale Studios
Re: best practice for mouse event and touch event handling
« Reply #1 on: April 01, 2014, 02:22:16 PM »
This deals more with Unity's set up than Playmaker so the best practices would be in the mobile section of their best practices when it comes to this which is actually found here.

https://docs.unity3d.com/Documentation/Manual/iphone-PracticalGuide.html

But to answer your question, it would be wiser to separate the two and just disable it for when going to mobile. You can test all this with the stats but supposedly, mouse events slow down mobiles more than touch events.
All my VR games use Steam VR Playmaker Toolkit: http://u3d.as/u20
And Oculus Touch Playmaker Toolkit: http://u3d.as/QT5


Follow me @sebasRez

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Re: best practice for mouse event and touch event handling
« Reply #2 on: April 02, 2014, 01:00:52 AM »
Thanks Sebastian, I'll read that guide you linked to.
And I already started separating the mouse and touch things for easy disabling.

Br,
Peter

drswoboda

  • Playmaker Newbie
  • *
  • Posts: 24
Re: best practice for mouse event and touch event handling
« Reply #3 on: April 05, 2014, 02:38:48 PM »
I'd love to see an example of this as I will need to do the same thing shortly.

Would it be possible to document your setup to help us new comers to Playmaker.

Thank you,
-David

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Re: best practice for mouse event and touch event handling
« Reply #4 on: April 07, 2014, 02:46:53 AM »
Hi David,

I am just learning too as I go along.
First went through all the tutorial video series:
http://www.hutonggames.com/tutorials_game_design_with_playmaker.php

Then started figuring things out on my own. Of course making lots of mistakes and not so optimal stuff along the way and learning what's required (like some vector math) for the ideas I'd want to prototype.

What is that "same thing" exactly you'll need shortly? Is it the multi touch moving of things around?
I could show that in one image if that's the thing.

Br,
Peter

drswoboda

  • Playmaker Newbie
  • *
  • Posts: 24
Re: best practice for mouse event and touch event handling
« Reply #5 on: April 07, 2014, 06:40:46 PM »
Hi Peter,

A few screen shots of wiring would be great. I was referring to the splitting out into multiple FSMs for keyboard and touch.

One issue that I am still wrapping my head around is how to get a good view of the whole picture of a setup. With all these separate FSMs controlling the actions, it can be difficult to see the BIG picture of all the interconnections. That is one area that scripting has the advantage, it's easier, I think, to see how it all connects together.

That said, Playmaker is a fantastic system and well worth the cost.
-David


purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Re: best practice for mouse event and touch event handling
« Reply #6 on: April 08, 2014, 01:40:05 AM »
Hi David,

You could have several FSM running on one "empty" object doing the mouse and touch stuff, or you can have a separate empty object for each, like I have.
You would then have to either disable just an FSM or a complete object when building for touch devices. (the one with the mouse things)

On the attached 2 images you can see my wiring (I removed all the unnecessary stuff) for the mouse interaction and on the 2nd image you can see the wiring for the touch with ONE TOUCH COUNT.
All you need to do to have multiple touches is to duplicate that and modify that one value to 2,3, etc. that I indicated in the shot.

Br,
Peter

drswoboda

  • Playmaker Newbie
  • *
  • Posts: 24
Re: best practice for mouse event and touch event handling
« Reply #7 on: April 08, 2014, 02:48:55 PM »
Thank you for taking the time to document this. It's very helpful.
-David

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Re: best practice for mouse event and touch event handling
« Reply #8 on: April 09, 2014, 12:56:05 AM »
You are welcome! I'm glad you find it useful.

I hope others with more experience also take a look and maybe propose some improvements or even a way better solution to solve this.

Br,
Peter

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: best practice for mouse event and touch event handling
« Reply #9 on: April 09, 2014, 07:28:43 AM »
Hi,

 Thanks for this, indeed it's very well documented. I would mention something very important tho.

With tracking touch, it's important to record the finger Id you are tracking:

When using action like "touch event", always store the finger id in an fsm int when you watch for the "began" touch phase, so that when on other states you watch for the cancel AND ended events, you only what these phases for that finger ID ( by injecting in the property "finger id" that fsm int having the finger id you caught beginning, else you will have bugs if several fingers are on screen.

Bye,

 Jean

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Re: best practice for mouse event and touch event handling
« Reply #10 on: April 09, 2014, 08:56:56 AM »
:-) Now that's why an expert needs to check it. Thanks Jean, I forgot to mention that.
I was so focused on showing the touch began stuff (I DO save the fingerID there) that I did not pay attention to also show what is in the "do something" states.

As Jean explained you don't just do something there but also watch for the same fingerID ended and canceled states to stop doing your thing when that particular touch ends.

This is how it's set up for mouse and the touches:

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: best practice for mouse event and touch event handling
« Reply #11 on: April 09, 2014, 02:42:55 PM »
Hi,

 the top shot should show how to store the finger Id right? you are showing instead the mouse state :)

bye,

 Jean

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Re: best practice for mouse event and touch event handling
« Reply #12 on: April 10, 2014, 01:22:27 AM »
No, storing the finger ID is on the "touch1.png" these 2 are about how you return from the "do something" states  to waiting for click(mouse) OR touch(finger).

Br,
Peter