Sprinting when crouched

Hello there,

I am new to unreal engine and I am experimenting with blueprints.
I made a toggle crouch function. When I toggle crouch, so I am crouching now, and I press sprint when I am stilled crouched, I uncrouch and sprint. But when i try to toggle crouch again it doesn’t. I have to press it twice to get it to toggle crouch again.

What am I doing wrong here?

Seems like you have two crouches “Crouch_Toggle” and “Crouch” this may be causing a problem of some kind but that out of the way
You want to look at the InputMapping it should be in FirstPerson/Input Folder or ThirdPerson/Input

if your using 3rd you want to look at the Input action
Screenshot 2024-06-03 135625
That will look something like this when you open it up


what your looking for is the trigger you’ll want to add one and test out how it works

hint try dragging a line out from the Canceled execution pin as well

My ones a bit of a mess i have to clean it up still and forgot so thanks for the accidental reminder

My one at the moment just slows you down when aiming down sights ( ADS ) or when im out of stamina my stamina system sets Can Sprint

Screenshot 2024-06-03 140714
And so does my crouch… tho i plan to move this to its own variable so they never get mixed… say my stamina fills up while im still crouched and it says i can run again, i know need a check either on the stamina system or the crouch

Note the Cancel execution and lack of flip flop, you could use the flip flop but it’ll always cause weird behavior

Hey @xYuujii! Welcome to the forums!

It’s because your IA_Crouch_Toggle event is running on a Flip Flop. When you sprint, it sets IsCrouching? to False, which is great. However, the Flip Flop is not triggered, so it’s still going to take the B path before you can activate the A path again.

Take out the flip flop and replace it with a branch!
Use IsCrouching? as the input for the branch, on False use the Crouch path and on True use the UnCrouch path! :slight_smile:

Also, Nightwolf’s suggestions of the Input Actions is a good thing to note, as well. You don’t really need more than one here, you can probably get rid of IA_Crouch completely and use a single Input Action with multiple input styles as shown above!

Let us know if you need more assistance!