Analog stick and 8 directions?

0 favourites
  • 6 posts
From the Asset Store
Everything you need to incorporate old school hip hop bangers.
  • I wanted to make the player walk in all direction based on analog stick position, not only "8 directions" I know that I can do so using custom movement, but I need acceleration and deceleration that only 8 directions has, I'm without ideias T-T

  • The stick already provides acceleration, and deceleration based on input.

    You can simply set position:

    Sprite.X+(Gamepad.Axis(0, 0)*yourspeed)*dt

    Sprite.Y+(Gamepad.Axis(0, 1)*yourspeed)*dt

    You can tweak the speed part if you need to adjust acc/dec. Lerp works nice.

  • The stick already provides acceleration, and deceleration based on input.

    You can simply set position:

    Sprite.X+(Gamepad.Axis(0, 0)*yourspeed)*dt

    Sprite.Y+(Gamepad.Axis(0, 1)*yourspeed)*dt

    You can tweak the speed part if you need to adjust acc/dec. Lerp works nice.

    wow it seems to work better than custom movement, but actually I want to use acc/dec to simulate slipping, like walk on ice, can you do that? (sorry I wasn't very specific)

  • That's a little more complicated: dropbox.com/s/aedegy6p8zaxi07/slipperystick.c3p

    Play with the pad variables for the slipping. Same for acceleration.

    Speaking of... I'm a little iffy on using gamepad axis=0 for a Bool. It might be an issue if you have a stick with unwanted drift.

    Ashley any way we could get something added to to account for when the stick is not in use?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That's a little more complicated: dropbox.com/s/aedegy6p8zaxi07/slipperystick.c3p

    Play with the pad variables for the slipping. Same for acceleration.

    Speaking of... I'm a little iffy on using gamepad axis=0 for a Bool. It might be an issue if you have a stick with unwanted drift.

    Ashley any way we could get something added to to account for when the stick is not in use?

    well, it works a bit strange here, the object speeds up a bit when I release the stick, but I think it's gonna work for now, thanks a bunch!

  • well, it works a bit strange here, the object speeds up a bit when I release the stick, but I think it's gonna work for now, thanks a bunch!

    Yeah that's the acceleration on the raycasting.

    You can lower the acceleration rate, or the length of the ray.

    You could just set the pad variable to:

    Sprite.X+(Gamepad.Axis(0, 0)*yourspeed)*dt

    Sprite.Y+(Gamepad.Axis(0, 1)*yourspeed)*dt

    Instead of the ray cast as the angle() between the joystick, and the object can get a bit iffy when they are close.

    Or possibly check their distances.

    Edit:

    Its probably a good idea to create a dummy object to act as the proxy for the joystick.

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