Download

Is there a way to wait until a boolean changes to trigger a branch?

Hi, in my game, I want you to not be able to sprint while falling/jumping, but if you press the key while in mid-air it will remember you’ve pressed it and automatically go into a sprint when you land, is this possible? Here’s what I’ve got so far, I want the ‘True’ in the branch to wait until and re-trigger when ‘Is Falling’ equals false, and then connect back to the ‘Set ‘Sprinting?’ true’ node.

Create a Custom event called “Sprint Queue”. Pipe this event to the Branch (leave the input as is).

Event “On Landed” → “Is input key down” (sprint key) → Branch … If true → Sprint Queue

@Mikester4411

Here’s a BP setup.

Awesome! It works perfectly, thank you so much!

@Mikester4411

Glad it helped you out.

The absolute best bits of advice I can give you would be to start implementing a player controller now. You’ll eventually need it anyway. Then create a function that determines and sets movement speed. A Function allows you to have all speed controls in one place versus spread all over the character class. Input action such as sprint should only be setting booleans etc.

So with that …

  • Create a PlayerController class.
  • Create custom events in your character class for each input and pipe them up. For inputs that will need press and release you should create an event for each.
  • In the Player Controller setup the Input action to pipe to the custom event.

​​​​​​​Here’s an example.

Player Controller …
Key input is first checked in the player controller by default. Here we simply execute an event for the input action. Said event and applicable logic resides in the character class.

Next create a function that handles setting movement speed. Use nested branches for logic flow to determine speed and set it.

Append this function to your forward/backward and left/right movement event. Character movement speed only applies when you input movement. So you only have to adjust/set speeds when movement is applied.

I forgot to note that eventually you’ll probably want to control the mouse pitch/yaw sensitivity as well.

e.g. when ADS your aiming sensitivity is reduced for accuracy.

You may want to have this sensitivity user customizable and per optic zoom level. Say at 1x zoom slightly reduced than normal, but at 4x (acog scope) you want it really reduced so you don’t over snap.

You do this by multiplying your mouse pitch/yaw by a rotation rate float… Pitch Rotation Rate, Yaw Rotation Rate.

e.g.

A better more dynamic approach is to create a Function similar to “Movement Speed” and execute it before “Add Controller Pitch/Yaw Input”. Pipe the Axis value into it … have the function calculate the output value. Pipe the output to the controller pitch input val.

How dynamic the function above is … is up to you. Personally I’d have a default pitch/Yaw float set for each optic attachment and pull that value for the multiplier.

Do the same for Yaw.