Increase speed after pressing 'Horizontal' keys for N second

HI I’m a beginner and just started learning unity visual scripting . Am now my character is able to move and jump in 2d mode. And I want to ask that how to increase the speed after pressing A and D for n second . like after pressing A or D for 1 second the speed change from 20 to 45 and also change the animation from walking to running . My scripts are pretty simple just contain Get axis Horizontal and Set velocity 2D

OK, a pretty long answer… We’re going to use several variables:

  1. Change Time - the time it takes to change from low speed to high speed
  2. Low Speed - at your suggestion 20
  3. High Speed - at your suggestion 45
  4. Elapsed Time - the total time since A or D was pressed
  5. Speed - the current speed (either 20 or 45)

When you start up, you need to set Speed to Low Speed.

When either A or D is first pressed, we set Elapsed Time to zero so we can start our count up.

When either A or D is released, we set Speed to Low Speed.

While A or D are held down, we add up the time so far. Delta Time is the amount of time that has passed between each call to the Key Down node. We then check to see if we have gone past Change Time and, if we have, we set Speed to High Speed

You can now use the Speed variable in your move graph. Note that none of these new graphs used Update so your Update code can stay as it is. Let me know if you have any problems.