Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Multiple things happening when space is pressed


Asweez
 Share

Recommended Posts

I want my vehicle to "jump" when the player presses space. Would I do it with Keyboard#isKeyDown() or make a new key bind for the space key?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

I'd say make a KeyHandler and add a vehicle jump key (So the player can change it if they so choose) and then, handle the jumping. I'm pretty sure the horse does kind of what you're wanting to do so maybe check out that. :P

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to comment
Share on other sites

Well I did that, but then Minecraft won't jump because the vehicle jump key is registered for space instead of player jump. Is there a way around this?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

Check if the player is riding an entity and, if it is your vehicle. Then: disable space for jump and enable it for the vehicle the player is riding. When the player is riding a horse, the space bar contributes to the horse the player is riding, otherwise, the spacebar is for the player's jumping.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to comment
Share on other sites

Why not just use the regular vanilla jump key? You can handle that in a KeyInputEvent just like you would a custom key binding, with the advantage of being very intuitive for players (jump key jumps for everything) and still customizable.

 

Another alternative you may consider is that you could simply let the player jump as normal while riding your vehicle, and then have the vehicle y motion match the player's, then you wouldn't need any key handling at all. I doubt that's how horses / minecarts work, but depending on what your vehicle is (e.g. a pogo-stick :P ), it could be an option.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.