Help with stoping key press

Im trying to stop the player from moving left or right sometimes during my game. Is their a way to block/ pause/ stop the key press for a short period of time?

you can call ‘set ignore input’ on player controller

You should not fiddle with the input system, but rather stop processing the input, e.g. if there is an obstacle in the way.

So (pseudocode):

OnKeyPressed()

    if Player.IsAbleToMove
       Player.MoveLeft()
    else 
       DoSomethingElse()

I put this for blueprint

Hello @ddave104,
You can try doing something like this:
First of all, in your BP_Character create a Custom Event called BlockLeftRight and a boolean variable called BlockMoveLeftRight. In the event, set the variable to true to block lateral movement, then add a Delay with the duration you want, and after the Delay set the variable back to false to re-enable normal movement.

Then, in the Move function, which is in the Functions section on the left side of the Event Graph, add a Branch with the condition BlockMoveLeftRight. If the condition is true, allow only Forward/Backward movement, and if it is false, allow both Forward/Backward and Left/Right.

In my case I tested it with a Blueprint that has a Trigger Box: when the character enters the trigger, it calls the BlockLeftRight event, but you can call it from anywhere you need.


Hope it helps!