Calculating Acceleration

Hi, what would be the best way to calculate the acceleration of a part?
Currently I check the velocity of that part every HeartBeat, calculate the velocity difference and the time difference, then devide the velocity over the time.
This, however, seems to not be 100% consistent all the time. Is there any other way of calculation the acceleration? (And I might worry that if the FPS of the user is really low, it might introduce inaccuracies.)

image

Thanks in advance!

2 Likes

You can’t assume that, this will only calculate a velocity difference. You still have to devide it by a certain amount of time to get acceleration.

And if you’d continue to work with the velocity difference and actually do calculate the acceleration with it (like I originally did), you would have recreated exactly what I already posted. And I am trying to ask here how to obtain the acceleration in a different way.

Oops totally forgot about time existing

ignore everything I said

However, have you tried using the step returned from the run service?

seems to be accurate for me when compared to using tick()

The step from a method of RunService would actually work pretty well in this scenario because it’s the delta time beteween two frames. That solves the time equation itself without any math and tick.

4 Likes

Also keep in mind this is the instantaneous acceleration between two frames, it won’t necessarily tell you much

Unless you’re the one providing the force, there’s not many ways to calculate the acceleration other than differentiating the velocity. Calculating from the previous frame will tell you what the average was over the past few milliseconds.

If you need it even more instantaneous than that, then you should provide the use case and maybe there’s a better way via prediction or via existing controls instead of trying to measure it.

  • If you control the force, acceleration is easy to calculate with mass.

  • If you don’t control the force, then the measurement method you described is as close to instantaneous as it gets. There isn’t a “current forces applied” property of baseparts sadly.

1 Like

what about gravity where the acceleration is constant?

If that were the only force acting upon the part then you would indeed have the acceleration, but you would need to know that it was in freefall and completely undisturbed by anything else.

I don’t think that’s what the post was after, but it’s a good point to raise.