playMaker

Author Topic: How can I do an 'AND / OR' statement for 2 floats?  (Read 2119 times)

Shinugami

  • Playmaker Newbie
  • *
  • Posts: 2
How can I do an 'AND / OR' statement for 2 floats?
« on: January 11, 2013, 12:18:12 PM »
Hi, I'm converting a 3d game into a 2d game and I've encountered a problem due to my lack of experience with playmaker.
I'm doing an isometric game and so the 3dmodels have been rendered into sprite animations. I've simplified it for iOS so small objects have only 8 directions like a typical isometric game.
The problem I have is that I want to check if the direction of the AI is between 2 Euler Angles.
I notice a flaw in my layout because the 'Float Compare' actions are not connected so for example:

if the AI's direction is:
greater than 337.5 OR less than 22.5
Then change the animation to be facing up.

If the AI's direction is equal to or greater than 22.5 AND less than 67.5
Then the animation is facing Up_Right.

So I have all the actions there but they are not connected which will produce unwanted results.
I thought about doing a lot of complicated booleans BUT it shouldn't be that complex, it's simple.
In code I'd just do && or ||
can I do this in Playmaker?

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: How can I do an 'AND / OR' statement for 2 floats?
« Reply #1 on: January 11, 2013, 01:31:10 PM »
Hey there!

andOr is:
float compare with an event only if true.
Then right behind it put another float compare with both the true and the false event. That way if both return false, the false event is sent, if any of the 2 is true, it'll send true.

Or
2 float compare with bools assigned to them. I call the bools private/tempBool1 and private/tempBool2 . I use the same bools in any or statement in any FSM. They can be global if you don't want to create them anew each time you need them in a new FSM.
Then you send an event based on the bool test of the result of a bool operator action (the result can be any of your 2 bools above.)

And
Create 2 float compares. The first has only a failure event, the second has both true and false event. If the first statement is false it returns false. Else it goes on to the second action and checks that. If both are true it will then return the true event.

The Or statement is really not nice at all, I hope there's a better way which I just don't know of.
Best,
Sven

parnell

  • Playmaker Newbie
  • *
  • Posts: 8
Re: How can I do an 'AND / OR' statement for 2 floats?
« Reply #2 on: January 11, 2013, 03:30:08 PM »
Shinugami-

Would/Could I use this for On Button Down?  Right now I'm trying to find a solution so that the character reacts only when Button 1 AND Button 2 are pressed down. 
Would I make Bools for that?
Thanks for the post really helps me consider this logic for the future.
B