[Seeking Help]Coding with a Joystick/Buttons

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Forum Statistics

    • Total Topics
      628686
    • Total Posts
      2984237
  • Similar Content

    • By Apollo Cabrera
      Yasss!!! My first Unity3d game is on the App Store and Google Play.
      Download please! About 30 minutes to get through 5 missions.
      Let me know what you guys think.
      Thanks a bunch
      Bleeping Bots MacOsx Demo Cut.mp4
    • By dabontv
      Stick City, a GTA style 2d game made for all devices (HTML5)
      Collect cash as you avoid the police and the traffic. Try to survive for as long as possible. The user with the most collected money goes to the top of the leaderboard.


      Play the game on lagged
    • By katastrophic88
       
      Hello, Everyone!
      My name is Kat, I'm the Community Manager for Bouncy Smash -- an energetic iOS roguelike-ish action platformer developed by IV Studio. I'm a lifelong gamer (courtesy of my parents) and am fortunate to work in an industry that speaks to my heart. I also have an interest in developing my own indie title (one day, when I stop being scared - lol). I look forward to exploring all of your wonderful work and learning from you!
      In the meantime, I have some awesome news I’d like to share.
      Bouncy Smash is a love letter to the likes of Super Smash Bros., Monument Valley, Donkey Kong, and Alto's Adventure. I'm excited to announce that Bouncy Smash was nominated by Playcrafting for The 2017 Bit Awards for Best Mobile Game of the Year. This category recognizes games that deliver the best experience across all mobile platforms.
      For those who aren’t familiar, The Bit Awards celebrates games and the people who make them over the course of a year. Categories include: PC/Console Game of the Year, Mobile Game of the Year, Tabletop Game of the Year, Best Style (audio and/or visuals), Best XR Game (augmented, virtual, or mixed reality), Best Student Game, and the Player’s Choice Award. To be eligible, all games must have shown at a Playcrafting event in New York, Boston, and/or San Francisco.
      Words cant express how grateful we are to the community who supported us along our journey of developing Bouncy Smash. We’d love to see you at The Bit Awards Ceremony on December 15th  in New York. Final winners will be announced at this event after a team of developers, industry professionals and press outside of the Playcrafting community have reviewed all the nominees. Here’s hoping we win!
      Bouncy Smash will be available on iOS devices in Q1 2018. Feel free to check us out at www.bouncysmash.com. Thanks for your support!

    • By Atwo Studios
      Hey Everyone!
      I am happy to announce our first official game from Atwo Studios!
      Our game ROY features a unique an awesome game play! The objective of ROY is to match different color combinations at appear on your screen, but watch out for hazards along the way!
      Give it a try and let us know how you feel about it!
      Download ROY now!

    • By mlamanna_music
      We would like to give out promo codes for our children's app Abigail's Tales: First Day Butterflies, tailored towards kids ages 6 thru 8. If you have children and want a code please message us at info@dabsterent.com the app looks best on iPad.
       

  • Popular Now