How to stop character movement until specific buttons are pressed?

Hello everyone.

I’m pretty new to scripting in Blueprint, and I’d like to achieve the following (in Paper 2D, if that makes any difference):
When the character’s health drops to 0, the player can’t move the character anymore, and is required to press one of two buttons in order for the character to move again. Each button gives a slightly different result, but will always restore the character’s health, and re-enable the character’s movement.

I know how to script the health itself, but it’s the disabling movement and getting the buttons input that gives me trouble. I tried using the “Set movement mode” node, but the character’s sprites still updated when attempting to move; and I’m also stuck on getting the actual button input.
I’d appreciate any help or tips!

You can stop the player controller working with

333372-screenshot-1.jpg

But I don’t think that’s what you want, because you wont be able to press anything then.

Why not just ignore the normal movement input keys when the health reaches zero, just use a bool.

Thanks, I’ll try with the bools.

UE4.27

  1. How can I disable Player movement keys, but allow Mouse rotate and Screenshot type keys (for a short time) - but allow [Simple Move to Node] to work?

  2. Is there a way to define a list of [exact keys and/or the wildcard key/gamepad that the player has assigned for specific InputActions] - and disable only those [keys] for a [duration/toggle]?

Ty :slight_smile: . PS asking a pro since I know you recommended the Set Ignore node.

Yes, there is. You have to do it in the player / NPC code. You can use bool flags that will allow turning / movement etc, and you turn them on or off depending on what effect you want to achieve.

Can you show me the Node to ‘define a list of [exact keys and/or the wildcard key/gamepad] to disable’?
I tried searching related words, did not find. Ty

  • Or do you mean I have to put a Bool lock (in Char BP) before every Input I potentially may want to disable? (which I want to avoid doing), if there is an easier Node to define a list of Inputs by name = any key the player binds to that Input, the key will auto be affected by the No list.

This is what I meant. You can have total control over the situation. If you try and do it with ‘disable movement’ nodes, it’s pretty much on or off…

1 Like