Platform behavior control with gamepad

0 favourites
  • 7 posts
From the Asset Store
Easily create a GAMEPAD for your mobile games by simplifying the movement of your characters on mobile devices.
  • Hey all,

    I just bought a wired Xbox 360 controller to try out with the Gamepad object. It works very well however I've run into a very interesting issue.

    I'm trying to get it working together with the platform behavior. The platform behavior is designed for keyboard / binary input - completely stopped or running as fast as possible. This presents some natural difficulties when adding a gamepad controller - of course, it's trivial to just set a threshold and turn the analog stick's proportional input into a binary input - however one sacrifices the fine-grained control that analog sticks provide.

    My first thought was to simply set the platformer's max speed to some factor of the analog stick's x-axis. This works well for the most part, however it completely breaks deceleration - releasing the analog stick brings the player to a jarring halt in mid-air as the max speed resets to zero.

    Does anyone have any ideas about fixing this?

  • *bump*

  • you always told me to use variables :)

    Then you could do , if the analog stick X-axis is not egal to zero ;

    Set max speed to analog stick X-axis

    Does that resolve it ?

  • Whiteclaws that doesn't work as zero is just a 'special case' - plus, the game would register a reduced max speed if the stick happened to register a number while snapping back/being released slowly.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • hmmm

    var constant dec = 0.2 // fiddle to speed

    var constant pwr = 10

    var speed = gamepad.x * pwr

    if (speed < sprite.currentspeed)


    sprite.currentspeed = lerp(sprite.currentspeed, speed, dec)


    else if (speed > sprite.currentspeed)


    sprite.currentspeed = speed


    ummmm. will that work based on what your looking for; or at least maybe some inspiration to solve your problem. It's not fined tuned too work 100%. I'm just brainstorming.

  • jayderyu any specific reason you used lerp()? Why not just simple deceleration value every tick?

    I see the thought behind that, though, it may just work! hmm...

  • sqiddster, I thought it might create a more fluid deceleration that was dt based rather than tick based. If the deceleration was per tick then slower hardware would end up having a deceleration slower compared to the dt already implemented... however I forgot to add the dt modifier.

    i'm just trying brainstorm an idea. If it helps get you on the right path the suggestion successful :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)