# playMaker

### Author Topic: Bool Float Modifier  (Read 517 times)

#### Thore

• Sr. Member
• Posts: 362
##### Bool Float Modifier
« on: June 05, 2019, 03:31:06 PM »
What it does
This action takes a float and multiplies it with one or the other factor depending on a bool variable.

Use Case
In 2D games, you often need to apply a positive force for one direction, and a negative force for the other direction, for example for moving projectiles or setting the velocity of the player. Right now, you'd have to use different states to check for direction, modify values to then apply the correct one. This action can do it in one simple action: you simply multiply e.g. your force or velocity float by 1 for the right direction and -1 for the left direction. The action might have other purposes, too.

Parameters
• Bool Variable: determines which factor is used for multiplication.
• Float Variable: the float variable to change based on the bool.
• Multiply If True: factor used when bool is true.
• Multiply If False: factor used when bool is false.
• Reset Float: change the float back when leaving the state (when coming here next time, the outcome is always the same, else value is continually changed further each time).
• Result:  the resulting value. You can use the same as in Float Variable or (of course) write to a new one.

I guess nobody will find this action when needed, since it's a somewhat abstract solution, and it might already exist. Anyhow, in case someone wants it

[edit: added parameter, clarified a bit]
« Last Edit: June 12, 2019, 03:06:33 AM by Thore »

#### jeanfabre

• Administrator
• Hero Member
• Posts: 14970
• Official Playmaker Support
##### Re: Bool Float Modifier
« Reply #1 on: June 06, 2019, 05:44:27 AM »
Hi,

it's actually a nice action, I have put it on the ecosystem.

I made few adjustments:

- result is saved in a distinct variable, which means you can still override the float by pointing both the float and result to the same variable, but you are also now free to not do that, which helps in many cases
- fixed reset, if you had selected everyframe, it would not reset to the original value, but to the last set.
- fixed a typo

Usually, if you are a developer in need of something, there is a very high chance that you are not alone so it's always very healthy to spread your work, share  what you find useful. It's good karma at the very least

Bye,

Jean

#### Thore

• Sr. Member
• Posts: 362
##### Re: Bool Float Multiplier
« Reply #2 on: June 06, 2019, 08:16:01 AM »
Thanks, and good changes!