playMaker

Author Topic: Mouse Pick Event / infinite loop  (Read 3091 times)

atmuc

  • Playmaker Newbie
  • *
  • Posts: 26
    • View Profile
Mouse Pick Event / infinite loop
« on: July 01, 2012, 08:17:45 AM »
i use Mouse Pick Event Mouse down operation on my listener state. when mouse down i set a variable on another state and return to my listener state. it causes infinite loop. should not it apply mouse down once? what is the solution to stop infinite loop?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14337
  • Official Playmaker Support
    • View Profile
Re: Mouse Pick Event / infinite loop
« Reply #1 on: July 02, 2012, 04:31:05 AM »
Hi,

I think the solution for what you are describing is to only get back to your state on mouse up, so use the "get mouse button up" to come back to your pick state.


hopefully, this is what you are after.

Bye,

 Jean

RogueVapor

  • Playmaker Newbie
  • *
  • Posts: 2
    • View Profile
Re: Mouse Pick Event / infinite loop
« Reply #2 on: July 12, 2012, 02:16:49 AM »
Yeah, I'm not getting this. The infinite loop check seems overly aggressive.
I have a FSM...
State1: MousePick Action (Use Owner, MouseUp = touchme event)
Touchme leads to
State2: Set Visibility (Use Owner, Toggle) on Finished
Finished leads to
State1 again

This throws the infinite loop. How can I have 2 mouse ups, or as suggested by PM, an infinite amount of mouseups, without atleast a mouse down in between.

And what if I wanted it that way, where I wanted the user to click, click, click...

I was simply copying an example from the wellplayed game series. Has a bug/feature been introduced after the IOS series. Or can someone tell me what I am doing wrong or not getting?

I also then tried

State1 looking for MouseDOWN
State2 looking for MouseUP
State3 Set vis (toggle)  - which goes back to state1

No joy...

So then I tried the following, which even if it worked is not what I would want

State1 looking for mouseDown
State2 set vis (toggle)
State3 looking for mouse up - which goes back to state1

Still "Possible infinite loop" error...

Now I know I sound a little frustrated, but this is only 1 of about 10 roadblocks I am hitting with PM. And I am seriously doubting that this is ease of this product.

I'll write a few more posts in proper threads, but if anyone has answers to the following quick one offs I would love it...

How do I print out my FSM in a code view type of way? Some verbose way that I could print (or send in to the forums when I have questions and someone wants to see the specifics)?

Why I am adding ten gazillion events... I am having a hard time understanding why I am writing events. I don't understand the need for them. They seem to be just an extra step added in to transitioning between one action and the next.

Why couldn't I just tell an action... If XXX then goto action YYY. Right now I have to say if XXX then look for road BBB to get to Action YYY.

I am not getting the need or benifit to write out an event for a transition. I don't see the value add. Which makes me feel I am missing some important understanding of PM.

Thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14337
  • Official Playmaker Support
    • View Profile
Re: Mouse Pick Event / infinite loop
« Reply #3 on: July 12, 2012, 03:05:23 AM »
Hi,

 I think you are over thinking this. There is a much more mainstream way of achieving this.

1: create a cube
2: add a fsm to it
3: create a new state called "toggle visibilty"
4: add a global transition to thet state and select "MOUSE UP". this is a built in event, don't create it yourself
5: in that "toggle visibilty" state, add a "set visibility" action and check toggle, and uncheck "Reset on exit"

you are done, now you click on that cube, and it will turn toggle it's visibility.

tho, Is it really what you are after? I mean once the cube is invisible, yes the cube can still receives mouse up but the user obviously can't see it. Is that not a case where you can to toggle another gameObject?

as for the mousepick actions, yes they require a bit more work, but you don't need it in your case, AND the solution I gave above works on mobile anyway.

bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14337
  • Official Playmaker Support
    • View Profile
Re: Mouse Pick Event / infinite loop
« Reply #4 on: July 12, 2012, 03:14:26 AM »
Hi,

 to answer your set of questions:

Quote
How do I print out my FSM in a code view type of way? Some verbose way that I could print (or send in to the forums when I have questions and someone wants to see the specifics)?

You can't unfortunatly, the only way is to create a package of your fsm on a working scene, if you do so, make sure you remove the playmaker dll as you create the pacake, else you would breach the license.


Quote
Why I am adding ten gazillion events... I am having a hard time understanding why I am writing events. I don't understand the need for them. They seem to be just an extra step added in to transitioning between one action and the next.

Events are core to the Fsm behavior, even outside playmaker implementation of what an FSM is.
http://en.wikipedia.org/wiki/Finite-state_machine


Quote
Why couldn't I just tell an action... If XXX then goto action YYY. Right now I have to say if XXX then look for road BBB to get to Action YYY.

The mechanism to do so is to "transit" via an event. It's just the way FSM are working basically. Don't see this as a constraint, it's actually a very powerful way of describing your process. Also you seem to misunderstand what a State is and what an Action is.

a State is implement Actions, so you don't go to an Action, you go to a different state, that has one or more actions defined in it.


I tend to build very common events, like "YES", "NO", "DONE", so that for a given state, so for example, I would have a state "Is my player armed?" and I would add two transition to that state, "YES" and "NO", effectivly achieve an "if" statement.

  I suggest you watch all the videos provided in the documentation, they will definitly help you grasp all them concepts and start to understand the frame of mind to adopt when working with playmaker.

http://www.hutonggames.com/tutorials_game_design_with_playmaker.php

Bye,

Jean