i use bolt visual scripting. I add ‘input.getAxis’ in Bolt and set the axis name to ‘Vertical’ so to get response when i press ‘w’ and ‘s’. When running the game and press the ‘w’ key, the output data (acceleration) will increase from 0 to 1. The problem is the increasing time is too fast or too short. How to make it slower/longer? Let say i want it to take 3 seconds to reach 1.

Edit :

This is what i want to achieve (at time 6:10 to 6:25) : https://youtu.be/m8rGyoStfgQ?t=370 And the code is at the same video at time 6:00 . That codes works perfectly fine. And this is all i want to achieve but i want to do it in Bolt (visual scripting) rather than manual scripting.

So that line of code at 6:00 on that video : Velocity = time.Deltatime * acceleration

That code is controlling how fast or slow the acceleration can go from 0 to 1 when pressing ‘w’ key. But in Bolt, i use ‘getAxis’ and by using default sensitivity setting, if i press “w” it will take less than half a second for the acceleration to go from 0 to 1. I want to make it slower so i can go from 0 to 1 in 3 seconds or 5 seconds.

In fact , this the same as setting up the sensitivity in input manager to low value, but i want to keep this setting as default and want to control it inside bolt.

Pls check my video here : getAxis


You could use Input.GetAxisRaw instead of Input.GetAxis to get the unfiltered values. So with binary inputs like keyboard keys, you are always going to get -1, 0 or +1. You can then add your own smoothing logic on top of that for a maximum of control. Like in this example, where the input gets multiplied by deltaTime and the factor 0.1 and then added to a variable of an animation controller, which also gets clamped to between -1 and +1: Bolt Spaghetti By the way, the same thing in C# would be this:

void Update()
    var animator = GetComponent<Animator>();
    var velocity = animator.GetFloat("velocity");
    velocity += Input.GetAxisRaw("Horizontal") * Time.deltaTime * 0.1f;
    velocity = Mathf.Clamp(velocity, -1f, 1f);
    animator.SetFloat("velocity", velocity);

Or you could go to Edit -> Project Settings -> Input Manager and configure the smoothing of your axis. "Sensitivity" determines the speed with which the axis value goes from 0 to 1 when the player presses the key and "Gravity" the speed with which the axis goes back from 1 to 0 when the player releases the key. The Enabling the checkbox "Snap" means the axis will immediately go from 1 to 0 when the player presses the key for the opposite direction.

But considering that you are talking about a build-up time of 3 whole seconds, it seems like what you actually want is physically correct acceleration on the player game-object. In that case you might want to consider using rigidbody physics instead. Instead of pluging the inputs directly into the transform, make them apply a constant force to the rigidbody of the player game-object.

  • \$\begingroup\$ Thanks, yeah the effect is the same as when i edit in project setting->input manager and set sensitivity to low value. So when i do press and hold 'w' it will start to accelerate slowly from 0 to 1. The lower the sensitivity setting , the slower the acceleration. But if possible i don't want to do it in project setting because it will apply globally to current project. This can be easily done in scripting and i need to find the similar workflow in bolt to achieve the same effect. \$\endgroup\$ – andio Apr 21 at 16:12
  • \$\begingroup\$ the effect is like in this video : youtu.be/m8rGyoStfgQ?t=370 , the script works fine, it just i need the the similar workflow in bolt. \$\endgroup\$ – andio Apr 21 at 16:38
  • \$\begingroup\$ @andio All you need to do is multiply the axis with deltaTime (and optionally multiply it with a factor to control the amount of acceleration) and then add the result to the velocity. Would be a one-liner in C# but a bunch of spaghetti in Bolt. \$\endgroup\$ – Philipp Apr 21 at 22:38
  • \$\begingroup\$ thanks, but the problem is (using default sensitivity setting) when i press ‘w’ it will take only less than half a sec for acceleration to go from 0 to 1. Or in other word, under half a sec it will already reach 1, so it will be useless to multiply by delta time. If you multiply beyond half of second, the output will be constant, since we multiply by 1. Pls correct me if i’m wrong. So now, let say i want 3sec or 5sec to reach 1. \$\endgroup\$ – andio Apr 22 at 11:02
  • \$\begingroup\$ "Pls correct me if I'm wrong." You are wrong. Multiplying by 1 here just means you are applying the full acceleration-per-unit-time allowed by your chosen coefficient (the factor Philipp mentioned), which can still be as small as you desire. Want the acceleration to take twice as long? Divide your acceleration coefficient by 2. Now the stick input has to stay saturated at 1 twice as long to achieve the same effect. \$\endgroup\$ – DMGregory Apr 22 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.