FPS Character controller jump acceleration

I am trying to get my character controller to accelerate by getkeydown(jump) “smoothly” to a maxspeed point.
First what i thought of is getting it to accelerate jst by something like this:


but this doesnt work cause i will keep accelerating all the time! how can i stop acceleration, and slow it down when i stop clicking jump keys?

What I am trying to get is a “car” acceleration by pressing jump key+movement key on my FPS character.

Any answer is more then welcome!

Hey there, you could accelerate till some point and stop. For that you should create:

defSpeed = 100
maxSpeed = 160
currSpeed = defSpeed
accelerateSpeed = 5


if(currSpeed < maxSpeed) currSpeed+=accelerateSpeed*time.deltatime;
   if(currSpeed > maxSpeed) currSpeed = maxSpeed;

if(unaccelerate or just un-hold the button "jump"){

if(currSpeed > defSpeed) currSpeed-=accelerateSpeed*time.deltatime;
   if(currSpeed < defSpeed) currSpeed = defSpeed;

Ok, that kinda help in some ways to think about it more, but not quite.
I still need to accelerate, to max speed, with that max speed i must be able to move around.
If i stop clicking jump my acceleration speed needs to slow down smootly.

Its like jump+direction key, add acceleration, jump+direction key, add acceleration etc. till max acceleration point.

i am still pressing jump+direction key now, i want to be able to move with maxspeed now.

I stopped clicking jump+direction key, acceleration goes down to normal movement speed.

I am jumping in place not clicking directional keys, i am not accelerating.

I am using C# by the way.

edit: i’ve been working on it, and this is what i got so far, pls help.

Been working on it abit, now i can accelerate to maxSpeed i want. But can’t return the speed to normal movement when i stop jumping.

	if(hasJumped && movementSpeed<maxSpeed){