playMaker

Author Topic: Control Setup: Swipe and rotate  (Read 14254 times)

ar2511

  • Playmaker Newbie
  • *
  • Posts: 14
Control Setup: Swipe and rotate
« on: May 22, 2012, 04:54:26 AM »
Hi All

I am working on an andriod game, this time is about rotate a object.

I would like to such a thing: When I swipe the phone, the game object will rotate 45 each time

so When I rotate 8times of it , it will return to the same point.

What Action should I use?

Itween Rotate to or? Itween Rotate ADD?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Control Setup: Swipe and rotate
« Reply #1 on: May 22, 2012, 05:57:31 AM »
Hi,

 it depends one thing: do you expect the user to swipe while the object is rotating or does the swiping is only taken in account when the object has finished or is not rotating.

 this implies slightly more work if the user can swipe anytime, because then you have to create some kind of buffer to record how many times the user swiped, nothing dramatic, but is important before I could give you some  useful help,

 bye,

 Jean

ar2511

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Control Setup: Swipe and rotate
« Reply #2 on: May 22, 2012, 08:22:22 AM »
Hi,

 it depends one thing: do you expect the user to swipe while the object is rotating or does the swiping is only taken in account when the object has finished or is not rotating.

 this implies slightly more work if the user can swipe anytime, because then you have to create some kind of buffer to record how many times the user swiped, nothing dramatic, but is important before I could give you some  useful help,

 bye,

 Jean

THX!!Jean!the user can swipe anytime is more suitable for me.

Best Wishes

ar2511

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Control Setup: Swipe and rotate
« Reply #3 on: May 22, 2012, 08:22:54 AM »
Hi,

 it depends one thing: do you expect the user to swipe while the object is rotating or does the swiping is only taken in account when the object has finished or is not rotating.

 this implies slightly more work if the user can swipe anytime, because then you have to create some kind of buffer to record how many times the user swiped, nothing dramatic, but is important before I could give you some  useful help,

 bye,

 Jean

THX!!Jean!the user can swipe anytime is more suitable for me.

Best Wishes

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Control Setup: Swipe and rotate
« Reply #4 on: May 22, 2012, 03:14:54 PM »
Hi,

 ok, I made a quick working example of the turn table management. It doesn't feature the swiping action tho, because for this we would need to discuss further the possibilities ( at the end of this post)

 So, in this package, you have a complete system to turn an object by a certain amount in a given time, and it will queue all the calls even when the table is turning.

!!!!!!!!!DO NOT FORGET TO IMPORT THE GLOBALS ASSETS!!!!!!!!!
There is a PlaymakerGlobals_EXPORTED file, select it and go in the playmaker menu -> tools -> import globals

 To queue the calls, you need to send the event "TURN TABLE" to the "MANAGER" FSM.

 It's very basic, but this is simply to demonstrate one way to go about this. By making two Fsm, we can separate the tasks: One Fsm is responsible for actually turning the object, not caring much about the context, and another fsm acts as the "manager" and queue calls, and proceed with them as the turn table finish turning.

If you have problem understanding these Fsms, do not hesitate to ask for more details.


Now, I know, no swiping yet... :) bugger... The thing is, there is a great library available on the asset store ( finger gesture) and there are playmaker actions made that works with it, so I would strongly suggest you work with that, it will give you so much more than if you start building swiping patterns yourself. you'll get your money back on the first day of use!

 If however you are a die hard playmaker fan, you can do the swiping pattern detection in playmaker of course, but that would be quite advanced, so if this package makes total sense to you, I can add the swiping all in playmaker if you so wish, tho personally, I would just use this "finger gesture" framework.


 Bye,

 Jean

ar2511

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Control Setup: Swipe and rotate
« Reply #5 on: May 23, 2012, 02:29:46 AM »
Hi,

 ok, I made a quick working example of the turn table management. It doesn't feature the swiping action tho, because for this we would need to discuss further the possibilities ( at the end of this post)

 So, in this package, you have a complete system to turn an object by a certain amount in a given time, and it will queue all the calls even when the table is turning.

!!!!!!!!!DO NOT FORGET TO IMPORT THE GLOBALS ASSETS!!!!!!!!!
There is a PlaymakerGlobals_EXPORTED file, select it and go in the playmaker menu -> tools -> import globals

 To queue the calls, you need to send the event "TURN TABLE" to the "MANAGER" FSM.

 It's very basic, but this is simply to demonstrate one way to go about this. By making two Fsm, we can separate the tasks: One Fsm is responsible for actually turning the object, not caring much about the context, and another fsm acts as the "manager" and queue calls, and proceed with them as the turn table finish turning.

If you have problem understanding these Fsms, do not hesitate to ask for more details.


Now, I know, no swiping yet... :) bugger... The thing is, there is a great library available on the asset store ( finger gesture) and there are playmaker actions made that works with it, so I would strongly suggest you work with that, it will give you so much more than if you start building swiping patterns yourself. you'll get your money back on the first day of use!

 If however you are a die hard playmaker fan, you can do the swiping pattern detection in playmaker of course, but that would be quite advanced, so if this package makes total sense to you, I can add the swiping all in playmaker if you so wish, tho personally, I would just use this "finger gesture" framework.


 Bye,

 Jean


1.   How to import it? I can’t find it at playmaker menu->tools. There are only custom action wizard and load al playmaker prefabs in the menu. Is it only at latest version playmaker?
2.    I know fingergesture is a good tools, but I can’t buy it at this month = =“” coz I need to pay credit debt. I am sorry about that.
3.   May I ask you a few question about hat, the <Add a pending turn>:Int add means the number of you swipe?
4.   If I would like to add swipe up /down/left, just correct/ add action to <Turn table>?It is because Manager is for processing the control and determine will it pending or not? Turn table is for animation only?


PS: Your task is really inspirational,make use of send event to connect difference FSM!!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Control Setup: Swipe and rotate
« Reply #6 on: May 23, 2012, 03:20:19 AM »
Hi,

 Thanks :) Communication between Fsm is key to achieve complex behaviors without headaches.

Have you updated to the latest playmaker on the asset store? if so, you will have in the playmaker menu this tool menu.

"Add a pending turn", yes, it's for recording the number of time you will ask this object turn.

As you will gain experience, you will realize that most of the time, it is essential to split the user input and the action it's supposed to trigger. the first very obvious reason is that if you want to execute this action automatically, then you have a problem, so by making a  clear distinction between the user input and the actions, you are able to better control your system. Second very important reason: you can test without the user inputs, it seems trivial, but as your system gets larger, you will want to just execute one particular action, without having to go trhough ALL the things the user must do before reaching that particular feature, example: this turn table is right at the end of the level, and it takes 5 mn to get there, avoiding all the ennemies... not good during testing yes? so simply trigger that via playmaker as an event, and done, you can work on a very specific aspect of your game without the need to necessarly play it, else you will loose A LOT of time. Third reason is that sometimes you want several input to do the same, and it woul dbecome messy to do it all in one place, there again, since you simply have to call "TURN TABLE", you can call that from where ever you want, one from a keyboard input, one from a touch input, one from a swipe input, etc etc, It becomes extremely flexible and easy to extend.

So for swiping, I would do it on a third Fsm. I don't have much time currently, I should have more next week, can you get back to me this week end, so that I don't forget? and I'll do a swiping system all in playmaker.

As a quick explanation ( if you want to try yourself meanwhile), you need to record the touch Id when the touch begins, you also record the screen position of the touch, then you keep watching that touch Id until it's ended canceled, you then record the last position, find out the travel, and if the distance is long enough  and it is horizontal enough ( by finding the angle between the release position and the start position). For proper swiping, you would also need to account for speed, and weird movement in between ( if the user do randomness as he drags the finger on screen, that would void the swipe command).

 Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Control Setup: Swipe and rotate
« Reply #7 on: May 23, 2012, 04:21:56 PM »
Hi,

 Ok, I discovered thanks to the new asset store Madness session that a more afforrable touch gesture recognizer exists:

http://u3d.as/content/song-game-dev/input-touches/2Tf

so, I am going to cover that framework for Unity ( currently cooking Vectrosity as well :) ), and I'll start with this swiping case :) I'll of course put it on the wiki, but it was just the rush of finding a new toy to play with before going to bed :)

For the tempted people:
1: get InputTouches framework if you don't have it already
2: import the InputTouches package in the turntable scene or else of course...
4: import the package attached to this post
5: select the playmakerGlobals_EXPORTED asset in the project browser, and select the menu "Playmaker->tools>import globals", you can delete it once imported.
6: Drag to the scene the "gesture" prefab from the folder "InputTouches/InputPrefab"
7: Drag to the scene the "PlayMakerInputTouchesProxy" prefab from the folder "PlayMaker InputTouches"
6: in the turn table "MANAGER" Fsm add the global event "INPUT TOUCHES / SWIPE LEFT" to the state "Add a pending turn"

Done!, everytime you will swipe left ( with the mouse or with the device) you will make the cube rotate. You have a great level of control over the swiping detection in the gesture prefab, so be sure to read the doc, even if you are not going to script it, it's important to grasp the possibilities and flexibilities offered.

currently, the following global events are available:
"INPUT TOUCHES / SWIPE LEFT"
"INPUT TOUCHES / SWIPE RIGHT"
"INPUT TOUCHES / SWIPE UP"
"INPUT TOUCHES / SWIPE DOWN"

you'll notice the "/" this is so that when you select a global event, it's all organized nicely in the various drop-down menus, so as you want to add that global event, look for "CUSTOM EVENTS" then "INPUT TOUCHES" then "SWIPE LEFT"

More to come :) this is just the beginning.

If you have any questions, do not hesitate!

 Bye,

 Jean

ps: That doesn't count as my future attempt for an *all* playmaker swiping system, so don't worry, that will come as well within the next few days.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Control Setup: Swipe and rotate
« Reply #8 on: May 23, 2012, 06:44:42 PM »
Just in case people missed it, there's also a Swipe Gesture action:
https://hutonggames.fogbugz.com/default.asp?W583

(maybe it was covered earlier - just catching up with this thread)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Control Setup: Swipe and rotate
« Reply #9 on: May 24, 2012, 02:08:38 AM »
d'uh...

 No you are right Alex, it wasn't covered I think, completely missed out on that action!



 Bye,

 Jean

ar2511

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Control Setup: Swipe and rotate
« Reply #10 on: May 24, 2012, 10:19:54 AM »
d'uh...

 No you are right Alex, it wasn't covered I think, completely missed out on that action!



 Bye,

 Jean

Ha !You are really thankful! You are really nice!

Best wishes

ar2511

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Control Setup: Swipe and rotate
« Reply #11 on: May 24, 2012, 11:30:05 AM »
Should I Reset the START STATE?

It is because there are something wrong..... I just can rotate it once

« Last Edit: May 24, 2012, 11:42:43 AM by ar2511 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Control Setup: Swipe and rotate
« Reply #12 on: May 24, 2012, 03:09:53 PM »
Hi,

 If you are using "INPUT TOUCHES / SWIPE LEFT" as a transition of the state "Add pending turn", then the action that actually add a pending turn, will never be called, hence the bug you are seeing.

 So, remove that transition you created, and select the state "Add pending turn" and right click -> "Add Global Transition" and then select "INPUT TOUCHES / SWIPE LEFT"

this way it will work.

 Bye,

 Jean

ar2511

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Control Setup: Swipe and rotate
« Reply #13 on: May 25, 2012, 07:39:16 AM »
Hi,

 Ok, I discovered thanks to the new asset store Madness session that a more afforrable touch gesture recognizer exists:

http://u3d.as/content/song-game-dev/input-touches/2Tf

so, I am going to cover that framework for Unity ( currently cooking Vectrosity as well :) ), and I'll start with this swiping case :) I'll of course put it on the wiki, but it was just the rush of finding a new toy to play with before going to bed :)

For the tempted people:
1: get InputTouches framework if you don't have it already
2: import the InputTouches package in the turntable scene or else of course...
4: import the package attached to this post
5: select the playmakerGlobals_EXPORTED asset in the project browser, and select the menu "Playmaker->tools>import globals", you can delete it once imported.
6: Drag to the scene the "gesture" prefab from the folder "InputTouches/InputPrefab"
7: Drag to the scene the "PlayMakerInputTouchesProxy" prefab from the folder "PlayMaker InputTouches"
6: in the turn table "MANAGER" Fsm add the global event "INPUT TOUCHES / SWIPE LEFT" to the state "Add a pending turn"

Done!, everytime you will swipe left ( with the mouse or with the device) you will make the cube rotate. You have a great level of control over the swiping detection in the gesture prefab, so be sure to read the doc, even if you are not going to script it, it's important to grasp the possibilities and flexibilities offered.

currently, the following global events are available:
"INPUT TOUCHES / SWIPE LEFT"
"INPUT TOUCHES / SWIPE RIGHT"
"INPUT TOUCHES / SWIPE UP"
"INPUT TOUCHES / SWIPE DOWN"

you'll notice the "/" this is so that when you select a global event, it's all organized nicely in the various drop-down menus, so as you want to add that global event, look for "CUSTOM EVENTS" then "INPUT TOUCHES" then "SWIPE LEFT"

More to come :) this is just the beginning.

If you have any questions, do not hesitate!

 Bye,

 Jean

ps: That doesn't count as my future attempt for an *all* playmaker swiping system, so don't worry, that will come as well within the next few days.


SORRY TO  hesitate you again and again, I feel so sorry.

I am doing swipe up/right/down/left

swipe left is well done as your tough.

Now I am doing another 3 of that, however it goes not good.I have tried 2 kind of method.

The 1st method is ADDING 3 more state at manger and turn table, but it is failed.

The 2nd method is ADDING 3 more FSM  to be manger, named as manger up/down/ right and 3 more FSM be Animation.

I have changed the variable, 'do we have pending inputs' FSM name, and 'send event target'

In my point of view, all manager are separate.

When I swipe up,the manager up is activate,then animation will be activated. The other manager are cool down.

Am I wrong? Coz  I can't make that up

ar2511

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Control Setup: Swipe and rotate
« Reply #14 on: May 25, 2012, 08:53:08 AM »
Hi,

 Ok, I discovered thanks to the new asset store Madness session that a more afforrable touch gesture recognizer exists:

http://u3d.as/content/song-game-dev/input-touches/2Tf

so, I am going to cover that framework for Unity ( currently cooking Vectrosity as well :) ), and I'll start with this swiping case :) I'll of course put it on the wiki, but it was just the rush of finding a new toy to play with before going to bed :)

For the tempted people:
1: get InputTouches framework if you don't have it already
2: import the InputTouches package in the turntable scene or else of course...
4: import the package attached to this post
5: select the playmakerGlobals_EXPORTED asset in the project browser, and select the menu "Playmaker->tools>import globals", you can delete it once imported.
6: Drag to the scene the "gesture" prefab from the folder "InputTouches/InputPrefab"
7: Drag to the scene the "PlayMakerInputTouchesProxy" prefab from the folder "PlayMaker InputTouches"
6: in the turn table "MANAGER" Fsm add the global event "INPUT TOUCHES / SWIPE LEFT" to the state "Add a pending turn"

Done!, everytime you will swipe left ( with the mouse or with the device) you will make the cube rotate. You have a great level of control over the swiping detection in the gesture prefab, so be sure to read the doc, even if you are not going to script it, it's important to grasp the possibilities and flexibilities offered.

currently, the following global events are available:
"INPUT TOUCHES / SWIPE LEFT"
"INPUT TOUCHES / SWIPE RIGHT"
"INPUT TOUCHES / SWIPE UP"
"INPUT TOUCHES / SWIPE DOWN"

you'll notice the "/" this is so that when you select a global event, it's all organized nicely in the various drop-down menus, so as you want to add that global event, look for "CUSTOM EVENTS" then "INPUT TOUCHES" then "SWIPE LEFT"

More to come :) this is just the beginning.

If you have any questions, do not hesitate!

 Bye,

 Jean

ps: That doesn't count as my future attempt for an *all* playmaker swiping system, so don't worry, that will come as well within the next few days.


SORRY TO  hesitate you again and again, I feel so sorry.

I am doing swipe up/right/down/left

swipe left is well done as your tough.

Now I am doing another 3 of that, however it goes not good.I have tried 2 kind of method.

The 1st method is ADDING 3 more state at manger and turn table, but it is failed.

The 2nd method is ADDING 3 more FSM  to be manger, named as manger up/down/ right and 3 more FSM be Animation.

I have changed the variable, 'do we have pending inputs' FSM name, and 'send event target'

In my point of view, all manager are separate.

When I swipe up,the manager up is activate,then animation will be activated. The other manager are cool down.

Am I wrong? Coz  I can't make that up

I have a idea, should I set 3 more global events named as Turn Table down/up/right?