Playmaker Updates & Downloads > Share New Actions

Bool Multi Test[SOLVED]

(1/2) > >>

The following action can take several bools with different values and compare them all at once. It's the equivalent to this:

If (bool1 == true && bool2 == false && bool3 == false & bool4 == true)
   do this

To use it, do this:
(a) enter the number of bools to include in the statement in the Bool Variables field.
(b) enter the exact same number in the Bool States field.
(c) in Bool Variable (0) field, enter the variable with the bool.
(d) in Bool State (0) field, enter the state that the bool variable must be for this action to return True.
(e) repeat c & d for each additional variable that you add.

To get TRUE:
All bools variables must match the bool states that you selected.

To get FALSE:
If any bool variable does not match it's bool state.

The code:

--- Code: ---// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved.

namespace HutongGames.PlayMaker.Actions
[Tooltip("Tests if all the given Bool Variables are are equal to thier Bool States.")]
public class BoolTestMulti : FsmStateAction
[Tooltip("This must be the same number used for Bool States.")]
public FsmBool[] boolVariables;

[Tooltip("This must be the same number used for Bool Variables.")]
public FsmBool[] boolStates;

public FsmEvent trueEvent;
public FsmEvent falseEvent;

public FsmBool storeResult;

public bool everyFrame;

public override void Reset()
boolVariables = null;
boolStates = null;
trueEvent = null;
falseEvent = null;
storeResult = null;
everyFrame = false;

public override void OnEnter()

if (!everyFrame)

public override void OnUpdate()

void DoAllTrue()
if (boolVariables.Length == 0 || boolStates.Length == 0) return;
if (boolVariables.Length != boolStates.Length) return;

bool allTrue = true;

for (int i = 0; i < boolVariables.Length; i++)
if (boolVariables[i].Value != boolStates[i].Value)
allTrue = false;

storeResult.Value = allTrue;

if (allTrue)
Fsm.Event (falseEvent);

--- End code ---

In the image below, if B: Flag Right Wall is TRUE, and B: Flag Bottom Wall is FALSE, the stored result will be TRUE and the True Event is called.

Quite useful in a multi-player game.
Thank you.

Thanks this really helped me

There is a similar action on the ecosystem called : Bool Multi Condition

Hello @djaydino,

This is probably the wrong place to post this but I did a quick search on Bool Multi test and it lead me to this post.
The Bool Multi Condition from the ecosystem works the same way as this script but the fail condition is not working along with the Everyframe function. It only check the condition once and then the action becomes disabled.

Tri Nguyen


[0] Message Index

[#] Next page

Go to full version