playMaker

Author Topic: Door opening FSM  (Read 3834 times)

unearthly

  • Junior Playmaker
  • **
  • Posts: 62
Door opening FSM
« on: May 03, 2016, 05:31:09 AM »
I'm a PlayMaker newbie and I need some help. I have a door opening FSM activated by a trigger zone. At the Start state I have a trigger event connecting to one with a Get Key Down action, then an I Tween Rotate To, followed by another Get Key Down action and another I Tween with reversed parameters. All works great except that the initial trigger doesn't stop - the player can continue use the key press and open and close doors where ever they go in the level. Have tried inserting exit trigger events to no effect. Any suggestions will be welcome.

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Door opening FSM
« Reply #1 on: May 03, 2016, 12:01:16 PM »
It sounds like you are doing the right thing with the Trigger Exit- when you watch the first door FSM what is it doing? getting stuck in a state that waits for Get Key down?

Posting screencaps of your fsm/states/actions will make it easier for someone to help  :)
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

ransomink

  • Playmaker Newbie
  • *
  • Posts: 44
Re: Door opening FSM
« Reply #2 on: May 04, 2016, 02:34:59 AM »
Hmm, this could be a few things. After you open the doors, the FINISHED event should link back to the Start state (so it can check the trigger again), not another Get Key Down action.

I'm guessing you link between the states using the Get Key Down actions. So once the door opens it waits for input to close, then it waits for input to open again. It never returns to the Start state to check if the player enters the trigger again.

Hopefully this is the issue as it's hard to tell without pictures of the FSM/states/actions...

unearthly

  • Junior Playmaker
  • **
  • Posts: 62
Re: Door opening FSM
« Reply #3 on: May 04, 2016, 08:09:52 AM »
Thanks for your response, gentlemen. The attached images show what I have at this point. Tried a bunch of things but no success. The truth is I don't really understand how to put an FSM together, how the parts work and how the options (actions, variables etc, effect them. What I have made so far I have copied from others via videos.

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Door opening FSM
« Reply #4 on: May 04, 2016, 01:49:17 PM »
Try having your closing state transition back into the idle state- right now its staying in the one waiting for a key press- it will continue to react to the key press-
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

ransomink

  • Playmaker Newbie
  • *
  • Posts: 44
Re: Door opening FSM
« Reply #5 on: May 04, 2016, 03:58:19 PM »
Aha, I figured that was the issue. ..

Your Idle state should link to your Use Action state. The Use Action state should link to a new state that has a Bool Test action to check whether the door is already open or closed (you will have to create a bool variable, e.g., is_door_closed?. If the door is closed by default, set this to true)...

If the door is closed, send an event to your Opening state. This state should have a Set Bool Value action to set is_door_closed? to false. If the door is open, send an event to your Closing state. This state should also set is_door_closed?, but to true...

Both door_done events should link back to the Idle state. This will allow the player to open/close the door only when inside the trigger...

I think this should work fine, but you must take a look at the PlayMaker youtube videos. They teach you the basics of everything and a lot more. I definitely benefited from them...

Game Design with Playmaker and Unity
https://www.youtube.com/playlist?list=PLC759306A1E692A10

unearthly

  • Junior Playmaker
  • **
  • Posts: 62
Re: Door opening FSM
« Reply #6 on: May 04, 2016, 09:05:49 PM »
Thanks ransomink, the attachments show where I am up to, it looks like the right wiring but I guess there's several things wrong. I have tried a lot of permutations.

ransomink

  • Playmaker Newbie
  • *
  • Posts: 44
Re: Door opening FSM
« Reply #7 on: May 04, 2016, 10:24:00 PM »
You have to fix your Door Check state. For the Bool Test: Is True event should send door_open, Is False event (this is missing) should send door_closed...

NOTE: You should get into the habit or writing a description for each state so you know what's happening inside of them. It's easy to forget when coming back to an FSM after a while...
« Last Edit: May 04, 2016, 10:30:27 PM by ransomink »

unearthly

  • Junior Playmaker
  • **
  • Posts: 62
Re: Door opening FSM
« Reply #8 on: May 06, 2016, 10:36:00 PM »
Thanks again ransomink.

I will write descriptions with my FSM's in future.

Still wasn't able to get it working properly. I have found another way following Red Hawk Studios YouTube & I will stick to that method for now, but I should learn how to put together FSM's better with more practice.
« Last Edit: May 07, 2016, 12:37:58 AM by unearthly »