Announcement

Collapse
No announcement yet.

Slowly blend gamepad axis input to 0 when player releases joystick?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Slowly blend gamepad axis input to 0 when player releases joystick?

    Oh, wise blueprint guru master shaman warriors... I require your help!

    I'm attempting to modify the values coming from the gamepad axis input values so that when a player is hard left (position -1) or hard right (position +1) and just releases the stick (position 0) the input values slowly interpolate back to the origin. I'm using this for some menu and ui cursor control effects. An easy way to explain what I'm after might be to imagine sliding a heavy object across a table. Right now, as soon as you were to remove your hand from the object (ie release the joystick), it immediately stops on a dime. Instead, I would like it to come to a full stop (position 0) gradually.

    The tricky part of this seems to not to be choosing the interp method (timeline, finterp, etc) but setting up the logic around when and how to call that interpolation function, since it's firing every tick.

    Any ideas?
    Last edited by SVR33; 08-06-2015, 07:13 AM.

    #2
    Something like this?
    The X-AxisValue variable interpolates to the target value over time, lower interp speed makes it take longer to reach the target. You then use this value instead of the actual value on the input event.

    Click image for larger version

Name:	g1aEmm5.png
Views:	1
Size:	71.6 KB
ID:	1083307

    Comment


      #3
      Hey Mosel3y, thanks for the reply.

      Two questions. For my situation, I would want to use a constant of 0 for the target, right? (I'm away from my computer this morning so I can't test it myself).

      Secondly, how would I limit this to only modify the input when going from -1 or +1 to 0? I don't want any sort of interpolation except when that happens.

      Comment


        #4
        The target should be the actual axis value, as above. I think it will make more sense to you when you get a chance to try it out; if the target was 0, it would just be interpolating 0 to 0. Since X-AxisValue is 0.

        You could set it to only use the interpolated value when the axis value==0. That would be equivalent to a user releasing the joystick - the actual axis value is 0 - so it uses the interpolated value. At all other times, i.e when the joystick is being titled - and the value is not equal to 0 - the actual axis value is used (no interpolation).

        Click image for larger version

Name:	5j0YEZm.png
Views:	1
Size:	113.7 KB
ID:	1083308

        Comment


          #5
          Just got home and took a minute to test it out... this works beautifully! I can't say the I really understand how this function works yet but I'm just thrilled that it does.

          Thank you so much!

          /bows to the great wise blueprint guru master shaman warrior Mosel3y

          Comment

          Working...
          X