Slow down and stop when joystick is pulled back

Hey everyone, im at a loss with this one. I dound a chunk of code that allows me to use mas and force to move an object. I am using a gamepad and using input.getaxis to control forward momentum. But my issue is when i pull back to slow down and stop my object slows then then starts moving in reverse. Any ideas how to stop this from throwing me in reverse.

Here is my chunk of code that im using for movement

  // F = m*a = m*dv/dt  therefore  dv = F*dt/m
 Vector3 deltaVelocity = transform.forward * forwardInput * (engineForce * Time.deltaTime / mass);
 velocity += deltaVelocity;

 // v = ds/dt  therefore  ds = v*dt
 Vector3 deltaDisplacement = velocity * Time.deltaTime;
 transform.position += deltaDisplacement;


Use real physics instead - it’s much simpler

If you add a RigidBody (or Rigidbody2D if you’re building a 2D game) to the object you can use real physics to move it.

Then use methods like AddForce (or its 2D counterpart) to speed up or slow down the object without all the complicated and (as you see for youself) error-prone calculations.