How to disable all player inputs

I am trying to create a combat game, and initially I was watching these videotutorials of this youtube user: Unreal Engine 4 2D Fighting Game Lesson 01 : Setting the Scene - YouTube

While I was creating scenes and cutscene’s … I noticed that during the shooting of the initial scene of the game, I could control the fighters (which I do not want).

I Tried to disable them for the first 5 seconds, but to my surprise, only player 1 is disabled … player 2 is not. I know I need the player character and player controller to use the node “Disable Input”, but this one asks for an index. I suppose that player one always stays with index 0 … I do not know what index has the player 2 … :frowning:

Maybe it’s something very basic, but excuse me, I only have 2 weeks testing UE4

I don’t recommend using Disable Input because it stops ALL inputs including pressing Esc to quit the game or bring up your menu. What I recommend is creating a boolean called “InputEnabled” and I just use this with a branch in front of all of my input nodes and if I turn it off, then it stops the inputs from working. Gives you more control over which inputs you want to disable or not by simply not implementing the boolean check for the ones you want to always work. Don’t forget to set the default value of the boolean to true. Then for multiplayer, you would get a reference to player 0 or player 1 and you can enable or diable their input separately.

2 Likes

I second this.

It can be tedious though to attach to all input logic individually, but I haven’t found a solid work around for the controls to be disabled reliably without going through every unput and adding a branch to check… But this does work reliably.

Hi there,
It’s a very old thread, but in case someone needs the info, once you’ve created the Level Sequence and placed it in the level, go to Details Panel and check the options Disable Movement Input and Disable Look at Input.

Sure, it’s tedious, but that’s a lot of game design :stuck_out_tongue: The nice thing is you only need to do it once per game. You could do it once for all projects as well, by setting up a custom Player Controller and putting all of your input nodes in there, then migrating it to any future projects as well.

Again, this disables all input and is not advisable. It means your player won’t be able to quit your game.

1 Like

Hello, I liked the idea but I didn’t understand it very well, wouldn’t you have a photo showing the nodes and variables and how you use them?

Sure, yeah. It’s the most basic kind of setup you can create:

It’s literally as simple as creating three boolean variables “LookEnabled?”, “Movement Enabled”, and “AttackEnabled” and then plugging them into a branch before you call your movement or attacking nodes. If the boolean is false, then it doesn’t do anything, but if it’s true, then it can proceed.

Then you can create a few custom events “InputDisabled”, “InputEnabled”, “LookDisabled”, “LookEnabled”, “MoveDisabled”, “MoveEnabled” and “AttackDisabled” and “AttackEnabled”. Then you just turn the bools on or off for each of the custom events by setting the bool value.

You also have to make sure all of the booleans are enabled by default (compile your BP and then select the bool variable and set the default state to checked). Otherwise you won’t be able to move when you play.

Anytime you want to disable looking, or movement, or attacking, you just use the node “Get player character” then cast to your specific character, then call “DisableMove or DisableAttack”. Same thing when you want to enable it again. For example, maybe you don’t want them to be able to attack when opening a door until the open animation completes so from your door blueprint, you could AttackDisable when you interact with the door, and then “AttackEnable” when it finishes opening.

thanks!!

1 Like