Why is a vector force's acceleration not constant?

Hey community, I have made a small system where I apply a constant force to a part and measure the acceleration that part obtains through time. The problem is that according to it, the acceleration caused by the force isn’t constant. It starts either greater or smaller than the expected acceleration. It adjusts through time forming a horizontal asymptote:


The expected acceleration is calculated using newton’s second law:

image

F stands for force, m stands for mass, and a stands for acceleration

image

The actual acceleration is measured using this equation:

s stands for space, a for acceleration, and t for time

image

NOTE: I made sure to remove friction by having the part in the air and using an anti gravity force to keep it still.

This is the uncopylocked place with all the stuff: acceleration and forces - Roblox

I may be wrong, but I believe that this is intentional.

Imagine a car, where the wheel is exerting a constant force on the ground. It starts to accelerate faster and faster but also tapers off after a certain speed is reached.

What do you mean? The acceleration stays constant once it reaches the predicted one.

I think it is intentional but for a different reason. I don’t think that forces are true forces within the physics engine, but calculations based on how the object will be rendered in the 3D space between frames.
Any object initially rendered in space must also have an initial point with speed nil, so any acceleration would also have to account for inertia.
And any massless object would therefore have a 0/infinity issue when forces are applied.
So as the force itself is arbitrary (being only applied as an abstract to an object), mathematically the physics engine just needs to say where things should appear each frame. Calculating acceleration curves can be worked out on initial parameters such as mass and force, but then this devolves into the second equation for any further calculations, until mass or force changes.

But then again I didn’t write the physics code, but this is my best guess :slight_smile:

2 Likes

I’m not sure if these are the reasons, but:

Most game physics engines that I have seen (e.g. PhysX, Box2D) use an optimisation called semi-implicit Euler integration to calculate the distance travelled in the the physics step; this effectively ignores the additional displacement that takes place during the time step due to acceleration during that time step (this gives some detail Euler integration discussion there is a link to a good paper on it about half way down).

So acceleration and displacement do not tie up perfectly like when you use the suvat equations. I don’t know what Roblox uses, so this is still just a guess by me. But if you are calculating acceleration from displacement and time this could be a factor.

I’ve only just started using Roblox, but I believe the default physics runs on a fixed timestep size, so it won’t necessarily be one physics step per frame render, I’m not sure how you can test how many physics steps have run, so be careful that the time between displacement measurements is what you think it is and you aren’t getting a frame rate dependency.

Another common approach to game physics is to have some rigidbody velocity damping, you can test this, if you stop applying the force, does velocity remain constant (excluding friction and gravity) for ever?

I hope some of that helps!

2 Likes

Just tested this, and it does stay constant.

1 Like

As @LostShedGames the cause may be due to physics engine inconsistencies and integration step errors. I remember this post which talks about this perhaps you can fix it and such:

Otherwise the values are actually already ok, it may just be the graphing/visualization that is misleading, The initial value 3.65 is very close to 3.57 with a difference of 0.08. That is a very small 2.2% error which improves over time.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.