Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Nekoyoubi on April 11, 2011, 02:03:43 PM
-
I was trying to work on getting some refire on a weapon that I've got in my (thus far) PlayMaker-only game-in-the-works.
Problem is (and I've tried this many different ways already) that I can't seem to detect or act on an appropriate mouse button state after the initial Down or Up, and the actual Down/Up actions do not seem to want to repeat if nothing's changed.
Basically, what I end up with is: Idle> *Click+Hold* > Fire > Idle > *Still holding* ... *Never going to click again*
I thought, "well, it's just the action of clicking, so of course it's not firing again". So I turned it into a Bool Test. The variable was set appropriately (so I see in debugging), but never fires the event it's wired up to.
Am I misusing the Bool Test? Is there an example already that can articulate weapon refire? Thanks much in advance.
-
You mean even when the flag is tested in BoolTest the state flow is *not* going to the desired state? That's really weird.. Anyways, description is a tad nebulous, a screenshot of your FSM would help (us to help you).
-
Do you want the weapon to fire repeatedly while the mouse button is pressed?
I would set up the Fire state to transition to itself after a delay (the repeat rate of the weapon).
The Fire state should transition back to Idle on mouse up (or ammo == 0 etc.)
-
@Alex : So [Idle + *Click+Hold* > Fire (still held) > Fire (still held) > Fire *Release* > Idle] ?
-
Exactly. You can then add more states as you develop the game. Once you get the hang of it, a visual FSM lets you quickly build quite complex behavior that is still easy to read and debug.
-
It was the "staying-in-the-fire" so to speak that got me. I've been coming along fairly well I guess, as that's really the first thing I was stumped on. Everything else I go to do (so far, anyway) proves to be delightfully simple where I was always getting irritated at how I would have to write little tiny scripts for everything before. Not that code is a problem for me, but some things (like randomly shining a light, responding to key presses, or rotating a projectile) shouldn't require constant rewrites of tiny scripts.
I greatly appreciate your response. You diagramming my exact scenario helped it to click for me very quickly. I literally just took what you said in the first response and applied it in less than 30 seconds to see it working exactly as I intended. Thanks again!
Oh, and by the way, are you a wizard?
-
You're welcome! Unfortunately not a wizard - just getting older with more grey hair every year :-\