How to move the player farward at a constant speed on Z-axis

I am making a cube Runner game as a beginner.
I want my Cube to move forward at a constant speed using the Addforce property …
Along with that I am using “ontrigger.enter” to pickup a specific type of cube.
Now the problem is that as my main cube move forward it’s speed starts increasing gradually which I don’t want at all. How to solve thos problem. I want costant speed

,
I am making a cube Runner game as a beginner.
I want my Cube to move forward at a constant speed using the Addforce property …
Along with that I am using “ontrigger.enter” to pickup a specific type of cube.
Now the problem is that as my main cube move forward it’s speed starts increasing gradually which I don’t want at all. How to solve thos problem. I want costant speed.

FixedUpdate() is called every frame- so every frame, you’re adding the force. This is why the cube is speeding up gradually over time, you’re repeatedly adding more and more force. Instead, try altering the rigidbody’s velocity directly.

rigidbody.velocity = new Vector3(0, 0, 1000 * Time.deltaTime);

this will keep it at a constant speed.

I am not sure about using AddForce for this specific request, however there is a very easy way to do this:

transform.Translate(Vector3.forward * speed * Time.deltaTime);

This will move it forward instantly, without slowly increasing the speed.

Speed should be a public float variable, that way you can adjust it based on your needs.