how to use y and x velocity?

Started by edgardeivis on

Topic category: Help with MCreator software

Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
how to use y and x velocity?
Wed, 06/03/2020 - 16:09 (edited)

how to do i use y and x velocity to detect movement or jumps?
it doens't work for me, i want it to be activated at all times

Edited by edgardeivis on Wed, 06/03/2020 - 16:09
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You could use velocity to…
Thu, 06/04/2020 - 01:47

You could use velocity to detect movement, but I would suggest just checking if the keybind is down. 

Here is the method,

Minecraft.getInstance().gameSettings.keyBindJump.isPressed()

There are some other methods, i.e isKeyDown(). So configure accordingly.

 

To directly answer your question;

how to do i use y and x velocity to detect movement or jumps?

Use something like this,

if (player.getMotion().y >= 0.2)

And for this;

 i want it to be activated at all times

This is why I would rather use my first method. To keep checking you are going to need to put this in a tick method. But if you are to check for velocity, you are going to "run" your procedure many times (if that is what you want go ahead). 

Although, if you check for the keybinding being pressed, then you (theoretically) should run the procedure once.