Started by
Rugbeat90999
on
Topic category: Help with MCreator software
I want to make a flying procedure, but I don't want to enable creative flying.
I have the flying procedure change there y velocity, so they travel up, the problem is it only applies the velocity once per key press, so you have to spam the key bind to go up.
I want it to be that you just hold the key and it constantly adds the vy to the player.
How can I do this.
(variable page)Create global player lifetime logic variable, default false.
(global trigger)On player tick update, if variable = true, run the procedure you want.
(key binding)On key pressed, set variable to true
(key binding)On key released, set variable to false
that should work
Thanks a ton
yo catnip can you like explain that again in a kinda simpler way
Okay, basically, the first step is to create a new global variable with the scope of PlayerPersistant, the type of Boolean, and the starting value of false, call it whatever you like, I will call it keyPressed. This step is needed to give a framework that you can use to tell the game when you are holding the keybinding down.
The second step is to take whatever procedure you want to have run while the key is pressed and change the global trigger for it (the dropdown menu on the green starting block) to be On Player Tick Update. You also need to put the procedure's content inside an if block with the condition keyPressed = true. (the actual procedure block to get a global variable is a long one, but you won't need to do anything other than to change the variable to keyPressed.) This step sets the procedure up to run when the keybinding is held, and only when the keybinding is held, although you also need to define when keyPressed is true, which is done in the next steps.
The third step is to make a procedure, and all this procedure needs to do is set keyPressed to true with no global trigger. You can call this procedure KeyPressedOn. This will be used later.
The fourth step is to make another procedure, this one is basically the same as KeyPressedOn, except that you need to change true to false. You can call this one KeyPressedOff. This will also be used later.
The fifth and final step is to create your keybinding. Call it whatever you want and set it to whatever key you want, the important parts are the procedure triggers. Set it to run the KeyPressedOn procedure on the On Key Pressed trigger, and to run the KeyPressedOff procedure on the On Key Released trigger.
If you did all of those steps correctly, you should be good to go.