Jump to content

Using the player's control keys


Firestarme

Recommended Posts

Ive been trying to make a vehicle mod, but the only way i can find of allowing the player to control motion is by using the mounted entity's motion values. What i want to achieve is for the ws keys to control forward/backward motion and for the ad keys to steer it. Is there any way of tapping in to the player's key handler so it can be used to control the car ?

Link to comment
Share on other sites

u can check the motion, the position, create a key handler, there are a lot of methods...

 

My current system uses motion, but that only gets what direction the player is trying to move, not what keys are being pressed ( i may try to separate the motion in to two vectors representing ad & ws but i recon there is an easier way to do this). Position is much the same as motion, and would be very hard to resolve back to the original keys. Finally, a key handler was my first idea for controlling motion, unfortunately, it overrides vanilla key bindings so when the player exits the car, they can no longer move.

Link to comment
Share on other sites

If you want to know when the key binding assigned to move forward/backward/etc. is pressed, you should check (client side) when FMLClientHandler.instance().getClient().gameSettings.keyBindForward.pressed is true. GameSettings holds all the vanilla keybinds, and that way you'll always know when the right key is pressed, even if the player ever changes it.

Then you need to relay the info to the server, but it seems to me you already know how to do that.

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.