How do I do ball mechanics

I’m trying to make a move where the player rolls into a ball and basically can gain momentum loose momentum etc etc

Normally when you press let’s say D key
You set player movement speed on X axis to 100
When you release D key you set player speed to 0
And that is how you make it move like you see in most games

Now instead of setting speed to 0 when key is released
You go with
INVERTED D key is pressed
Player speed is above 0

Subtract 3 from player speed

And you are smoothly loosing speed but that is linear
You may want to go with

Subtract (Player.Speed()/90+2)
So more speed player have
Faster he will lose it so at beginning when you release D key it will start loosing speed fast but when he have little speed left he will lose speed slower
Kinda like actual ball would behave

Now imagine reversing that process for when D key is pressed

uh… what? I’m sorry but that confuzzles me

Are you using the platformer behavior on the player? Does the ball have physics?

If yes, then you can’t mix the platformer behavior with physics since both behaviors work in completely different ways and use different calculation methods.

You’ll have to recreate the character movements using physics forces to make this work. This will allow the ball to interact with the player realistically using physics and affect the speed of the player according to the forces, mass etc…

If no, then you’ll need to add more context so we can understand better what you’re trying to do.

Momentum is like only HOW you are decreasing increasing speed

IF yo want your player to roll at max speed of for example 120
Then you could add to player speed 1
And with each frame it would gain +1 speed unit
Imagine is as regenerating HP
You see HP bar fill with constant speed this method
BUT if you gonna fill HP bar with 1+(CurrentHP / 80)
Then more HP you have Faster HP bar will fill
So like car accelerating
You want to reach max speed of 200
But when you start your car you won’t start with 200 speed it will start from 0 and gradually will be moving faster and faster
Now question is
Do you want car to accelerate in constant rate
So like each sec it increase accelerating speed? or constantly gain same amount of speed?
For example
At sec 1 acceleration (NOT CURRENT SPEED) adds 10 to speed
But in 2 second acceleration adds 30 to speed
Where in 3 second it adds 50 or 70
And so go on
Where linear acceleration would be increase acceleration for 10 each second
So in 1st sec it would be 10 in 2nd it would be 20 in 3rd 30 and so go on
That is what i meant
You have 2 choices of how acceleration deceleration goes as i described above

SO aside from that
It is just constantly adding some value to other value
That is how you control speed i mean either you add to accelerate or subtract to decelerate