playMaker

Author Topic: Logic around two Boolean variables being TRUE?  (Read 2772 times)

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Logic around two Boolean variables being TRUE?
« on: May 06, 2013, 04:29:30 PM »
Hi, just finding my way around and don't know how to set up a state that is looking for two boolean variables to be true. For example, press UP and Boolean Is UP pressed = TRUE. Press RIGHT and Boolean Is RIGHT pressed = TRUE.

But how do I check if both UP and RIGHT are true at the same time?

Many thanks

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Logic around two Boolean variables being TRUE?
« Reply #1 on: May 06, 2013, 04:49:50 PM »
Bool All True action.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Re: Logic around two Boolean variables being TRUE?
« Reply #2 on: May 06, 2013, 08:27:44 PM »
Ahh I see, when you add the number it lets you put in more than one Bool variable. It's still not helping me. I'm trying to make an 8-way top down firing system. I can get the up, down, left & right working but the diagonals have me foxed as you need two keys pressed at once. I read that you should separate each key press to individual FSM but even with Global Bool UP and Global Bool RIGHT I can't get them to register at the same time to make Bool All 2, up and right work & therefore send out a diagonal projectile.

Is Global Boolean the right way to go? Should I use Bool Flip on key press, Bool Flip on Key off?
« Last Edit: May 06, 2013, 08:31:16 PM by dlmrky »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Logic around two Boolean variables being TRUE?
« Reply #3 on: May 06, 2013, 09:12:18 PM »
Sure it works, all you have to do is separate all of the two direction combinations as bool groups. It would be 4 new actions of All True.

Set bools for bLeft, bRight, bUp, bDown.

Make an All True checking bRight and bUp, in which case it does the up-right state. You can then make separate All True's for the other combinations like bRight+bDown and the left side.

There are only 8 directions so 8 direction states + idle state. In each of the direction states you just check to see if any of those bools (for that direction) are false and if so then go back to the checker state that tests all of the bools in those 8 different actions. You will lose one(or two?) frame of movement to check them.

You do not need global's for this since you are doing it all in one FSM.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Re: Logic around two Boolean variables being TRUE?
« Reply #4 on: May 07, 2013, 08:29:47 AM »
Thanks Lane. I couldn't get it working properly without using Globals. I tried a few things but no luck. It's working as expected right now with Global Bools - if I get time I'll come back and give it another go, cheers.