GMS 2 Full analog movement with variable speed?

Discussion in 'Programming' started by Undead Hero, Jan 16, 2020.

  1. Undead Hero

    Undead Hero Member

    Joined:
    Jul 20, 2016
    Posts:
    73
    Hey. I’ve looked everywhere, but couldn’t find an answer to this.

    Is there a function in GM2 that that would allow you to change the speed a player moves at based on how far you’re moving an analog stick? ie, nudge the stick a little bit to move slowly, push it all the way to the edge to move quickly.

    Thanks!
     
  2. chamaeleon

    chamaeleon Member

    Joined:
    Jun 21, 2016
    Posts:
    1,078
    Presumably gamepad_axis_value will be what you're looking for. The example code is more or less doing what you are asking for.
     
  3. Undead Hero

    Undead Hero Member

    Joined:
    Jul 20, 2016
    Posts:
    73
    I thought this was saying it would simply return -1 or 1, based on a left or right input. Does it get more granular than that with the analog sticks?
     
  4. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    2,192
    Yes.
     
  5. Undead Hero

    Undead Hero Member

    Joined:
    Jul 20, 2016
    Posts:
    73
    Sweet, thanks.
     
  6. Sabnock

    Sabnock Member

    Joined:
    Jul 21, 2016
    Posts:
    358
    this is actually quite simple you just use the result of gamepad_axis_value as a multiplier.
     
  7. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,372
    Make sure you lower the threshold.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice