rigidbody acceleration

Hi, is there any way to obtain the acceleration vector of the rigidbody? In the same way that we can obtain the velocity ej: rigidbody.velocity.

The case is that I have rigidbody objects in my scene, to wich I apply some forces, and then I would like to compute the acceleration of the rigidbody at a certain moment.

Thanks!!

Instantaneous acceleration doesn't have a meaning in Unity, where rigidbodies are accelerated by forces acting repeatedly at discrete intervals, and stopped without static objects actually exerting forces. You could could do a delta over the smallest possible time step:

acceleration = (rigidbody.velocity - lastVelocity) / Time.fixedDeltaTime;
lastVelocity = rigidbody.velocity;

And if you're talking about acceleration in terms of forces you're applying, instead of measured velocity differences, then just add up whatever you think matters, i.e. stuff you're doing in FixedUpdate plus other forces that happen at irregular intervals.

It's useful for calculating G forces and things like that.

The problem with this method is that there is some numerical "noise" on it...

I have some gauges set up here to measure vertical speed and vertical acceleration and I get some huge jerking movements on the needles...

Vertical speed is more or less ok... it twitches a little when near 0, and some more approaching higher values... It's the derivative of the ship's altitude on the fixed time step (fixedDeltaTime)...

Now, vertical acceleration is the derivative of vertical speed... so it jerks around horribly...

The problem is that this is essentially verlet integration, which is an inherently unstable integration method...

Yeah, Unity really should expose a rigidbody's acceleration... so these things are more convenient.

Cheers

You can also use the LinearAcceleration() function here:

http://wiki.unity3d.com/index.php/3d_Math_functions

Ok, that's more or less what I thought, but I needed some kind of confirmation, and you gave me that!

I'll calculate the acceleration by derivating the velocity as you say. But I think the instantaneous acceleration of a rigidbody or physic object could be useful... I really don't know.

Thanks anyway!