Acceleration in a vacuum?

Hi, I’m working on a project about acceleration on a vacuum, it entails hitting an object with a certain force and have it move faster and faster, as it would happen in real life.

As is I’m doing something like this.

empuje = 4 + Random.Range(-empuje / 20, empuje / 20);
rb.AddRelativeForce((-transform.forward * empuje));

Where empuje is the initial force+ a margin of error. However what I’ve noticed is that when doing this the object very much loses acceleration, it does the oposite of what it should.

rb is a rigidbody with gravity turned off, all rotation frozen and all translation, except on the z axis (I want it to move on a straight line) frozen as well.

What I’ve done so far is just add more forces on update.

rb.AddRelativeForce((-transform.forward * (empuje / 7)));

But I want to know if there’s a better, more precise way of doing this.

The first force is added when the user presses the space bar, the rest are added every frame afterwards.

well firstly negative transform.forward is backward.

and your code is -transform.forward

your range seems to between a negative and positive value, if you get a positive value the negative times positive will reverse you, if you get a negative the double negative will apply a positive accel.

There are many things strange or wrong in your description. First of all you said:

hitting an object with a certain force
and have it move faster and faster, as
it would happen in real life

This is not what would happen in real life. In real life there’s somethnig we call conservation of energy. So if you just hit an object you apply an impulse force once. In vacuum the object would always move with the same velocity unless there’s an external force applied to the object.

In your case you do apply a force every frame so the object should accelerate. With a constant force the object would get a constant acceleration which will cause a steady increase of the velocity as long as no counter forces are applied.

So you should make sure that you do not have set any drag or angular drag on your rigidbody.

You should add more context to the code you posted. It’s not clear where and when your two snippets are actually executed. Continuous forces should be applied in FixedUpdate while one-time forces / impulses can be applied anywhere.