Download

Prevent spamming of a certian key? (SLIDE/CROUCH)

I have a rootmotion sliding mechanic in my project, that uses the default crouch function in UE4 to make my hitbox small.
Sadly, the camera also snaps up and down whenever i press the key, so i implemented, in my event graph, a way to “compensate” for this using the “AddRelativeLocation” node with my Camera as a target.

So, how do i prevent spamming of this camera movement?

I already tried using a “DoOnce” node with the KeyPressed node and a delay, and it MOSTLY works, but it causes a glitch when i spam slide while i’m rotating, where the camera goes crazy for like
1 frame and moves up.

It’s very annoying. Does anyone have a solution that works 100% of the time or almost 100%?

use a CanSlide? boolean and check against it on input.

IF CanSlide? true -> do slide, set CanSlide? to false -> “set timer by event”
timer event -> set CanSlide? true

Here’s BP …