Boolean Logic

Hi I am trying to figure this out. What I would like is for when ever you press F the boolean would change from true to false if it is true, and then from false to true if it is false. It is constantly bringing up False.

Just use the “FlipFlop” node :slight_smile: Atm you are just going through the entire sequence -> so it will go to true and some seconds after that to false - when you press again it will do the same thing

flip.jpg

The reason this is happening is because sequence executes everything in the chain one after another. You’re first ensuring the boolean is true, then ensuring the boolean is false. You’ll want to make them come off the same branch. True will make the boolean false, false routes to true. You can just drop the sequence and everything executed by Then 1.

Flip flop is a great way to do this, but you can also use the NOT boolean node which will simply toggle your boolean to be whatever it wasn’t when you set it.

Thanks guys!

Now what if I wanted to say switch between ABC or any other amount of options after that?

Could you probably give an example of what exactly you mean? :slight_smile:

After that you could use another “FlipFlop” node to change some other bool variables. Or a switch, sequence, branch…

You can store whatever desired selection you want in an integer instead of a bool.

a7f7a5cc4b.png
Works similarly to switching on an enum.
To cycle through 3 options, you’d have something like this (obviously with actual code being executed before setting the variable).

Hello,

Two years late, but an easy way to switch between 3rd, over the shoulder, and 1st person cameras, is to just move the Follow Camera and use two FlipFlops. Attach “Over the shoulder location” to A of the first FlipFlop, then attach a second FlipFlop to B, then attach “1st person location” to A of the second FlipFlop, and “3rd person Location” to B of the second FlipFlop. This will cycle between 3rd, to over the shoulder, to 1st, then back to over the shoulder, then back to 3rd, and repeat. This works for as many camera positions as you want. You don’t need to use multiple cameras, or make this complicated. You can also smooth out the transitions, but not really needed. Most solutions use the mouse wheel, but this works good enough for a gamepad.

68177b1e2405d54d96bb50f387df4b80.png

This is an old thread, but I wanted to post what I think is the most convenient way to toggle a boolean back and forth. This is especially useful for me because the blueprint this is used in will be instanced many times throughout my levels and the boolean could be either true or false when the game starts depending on the instance, so i needed generic code to just flip it no matter what it started on. Hope this helps someone!