Power, activated and deactivated by a key on the keyboard

Started by zorualeloupsolitaire on

Topic category: Help with Minecraft modding (Java Edition)

Active 1 month ago
Joined Nov 2024
Points:
98

User statistics:

  • Modifications: 0
  • Forum topics: 11
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 9
Power, activated and deactivated by a key on the keyboard

Hello,

I have searched on Mcreator and on the internet, without success, for a tutorial that explains how to check if a player has pressed a button.

I'd like to make a power boost, which activates when the player presses a button, for example K.
The player would receive enhanced strength, speed and jumping boosts. But I don't want him to have to hold down the K button constantly.

Does anyone know how to make it so that the player only needs to press once to activate the power boost and a second time to deactivate it?

Thank you!

Active 1 month ago
Joined Aug 2023
Points:
229

User statistics:

  • Modifications: 1
  • Forum topics: 4
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 32
You could have the power…
Thu, 01/02/2025 - 17:46

You could have the power boost be active when a player_lifetime logic variable is true for them?

Detect when K is pressed using a Key Binding element, then assign a procedure to the On key pressed trigger.
Inside the procedure, you would set your variable to true if it is currently false, and false if it is currently true.

Active 1 month ago
Joined Nov 2024
Points:
98

User statistics:

  • Modifications: 0
  • Forum topics: 11
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 9
Thank you for your help, I…
Thu, 01/02/2025 - 18:27

Thank you for your help, I simply have a problem. Now my launcher won't launch at all.

Do you have a solution? Here's what I did.

Variable

Procedure Tick update

 

Procedure Key pressed

Active 1 month ago
Joined Nov 2024
Points:
98

User statistics:

  • Modifications: 0
  • Forum topics: 11
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 9
Hey, so my game's going…
Thu, 01/02/2025 - 18:57

Hey, so my game's going really well now. It was PlayerAnimator, which made me crash.

Now I've got another problem: the command doesn't work.

Active 1 month ago
Joined Nov 2024
Points:
98

User statistics:

  • Modifications: 0
  • Forum topics: 11
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 9
So my fault, I've just…
Thu, 01/02/2025 - 19:02

So my fault, I've just realized that I'd set the wrong variable on one of the commands. Now it's working fine!

Thanks again!