Jump to content
  • Advertisement
SantaCode

[Seeking Help]Coding with a Joystick/Buttons

This topic is 467 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I am developing a game. 
mP4PVbK.png

That is what it looks like. I want to script the controls so that when the joystick is selected and one of the buttons is pressed, the game moves the character with that specific limb. Is there any guidance on how I'd get started on that? 

Share this post


Link to post
Share on other sites
Advertisement

Hello @SantaCode You would just map the joystick button to the function which handles the movement of the joint while the joystick is being rotated.

if (joystick) { if (buttonA) { // movement for limb } }

You would need to code the part of the arm to rotate at the point of the joint connection based on the joypad direction.

shoulderJoint.setRotateValue(var);

You need to feed the y and x for the joystick which will give you the radiant value, then you can convert it to degrees to feed into the function. I don't know what library you're using however, but SFML for example requires degrees.

http://en.cppreference.com/w/cpp/numeric/math/atan2

Share this post


Link to post
Share on other sites
1 hour ago, Rutin said:

Hello @SantaCode You would just map the joystick button to the function which handles the movement of the joint while the joystick is being rotated.

if (joystick) { if (buttonA) { // movement for limb } }

You would need to code the part of the arm to rotate at the point of the joint connection based on the joypad direction.

shoulderJoint.setRotateValue(var);

You need to feed the y and x for the joystick which will give you the radiant value, then you can convert it to degrees to feed into the function. I don't know what library you're using however, but SFML for example requires degrees.

http://en.cppreference.com/w/cpp/numeric/math/atan2

4

Thank you so much. I'll keep this thread updated if I figure it out! :D

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!