playMaker

Author Topic: Generating a series of getKeys based on Boolean states  (Read 1911 times)

scottstephan

  • Playmaker Newbie
  • *
  • Posts: 6
Generating a series of getKeys based on Boolean states
« on: May 31, 2013, 02:42:55 AM »
I have a turn-based game I'm working on and it has some simple logic- The character is surrounded by 4 probes in the NWSE directions. If any one of those probes is touching an impassable object, the player should not be able to move there. Simple!

However, here's where I run into an issue. I have a bool for each direction (NWSE). If a bool is false, I don't want to listen for key input because the player can't move there.

The only way I can see to do this is with an zany FSM that has a lot of bool checks (i.e., is 1 is true, then state 1, is 2 is true, state 2, is 1 and 2, state 3, if 123....). I figure there has to be a cleaner way I just haven't been exposed to yet.

Thoughts?

scottstephan

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Generating a series of getKeys based on Boolean states
« Reply #1 on: May 31, 2013, 03:06:48 AM »
Or: Is there a way to have multiple states active without having multiple FSMs?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Generating a series of getKeys based on Boolean states
« Reply #2 on: May 31, 2013, 05:23:52 AM »
Hi,

 nop, only one active state per Fsm.

bye,

 Jean

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Generating a series of getKeys based on Boolean states
« Reply #3 on: May 31, 2013, 08:44:51 AM »
Its not that you need to stop listening for that key input, you just need to run a check on the square before you go to the actual move. If it is blocked you simply return to the input reader state, if its clear then you proceed with the FSM. All the player cares about is if his character moves or not rather than what is literally happening in the FSM.

Attached is an example scene. This uses raycasts but you could just as easily have the probes switch a bool if they are in a collision and check that bool in the scan states after the player presses the input button to move but it would require a few more FSMs and I think the attached way is cheaper if you can integrate it that way.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D