Computing Local Acceleration/G forces

I’d like to compute/derive the local acceleration vector (including centripedal force) inside a flying vehicle. This is mostly for determining the optimal roll/pitch for any given turn - i.e. the one that would keep the perceived local g vector pointing straight into the floor.

I’ve tried hanging a little rigidbody from hinges inside the vessel and then checking its transform. Works kind of ok but it flops around a lot because of its own inertia. Also tried storing the Velocity from one Update to the next and using the difference between them. Easier to work with than the hinge system. But its very erratic I guess because of asyncrity between Update and FixedUpdate (??)

If anybody has any suggestions, I’d be much obliged.

Is there any particular reason why you need to do some things in Update and others in FixedUpdate (instead of doing everything in FixedUpdate)? Are you using Time.deltaTime to get the time since the last frame?

I’m computing this in Update because its primarily for support of graphical operations. But if operating in FixedUpdate makes this work, then I’ll move it to FixedUpdate.

The acceleration term will get used in a lot of places, most (all?) of them at Update pulserate. So, it kind of made sense to maintain it in Update. Besides the rotation stuff on the vessel itself, this vector is going to be used to push on CharacterControllers. If the force is strong enough, it will kick them into ragdoll mode. That kind of thing.

And yes on deltaTime. Here’s the code copy-pasted straight in. This isn’t really working code - I put it in update to test feasibility. I’m not all that hot with physics so I’m not really sure i’m computing it right. But this does work well enough to show violent fluttering on the Acceleration value.

Vector3 currentVelocity = rigidbody.velocity;
Vector3 acceleration = currentVelocity - m_previousVelocity;
m_previousVelocity = rigidbody.velocity;

Acceleration = acceleration.magnitude / Time.deltaTime;

I moved it to FixedUpdate and its nice and smooth now. And the magnitudes look about right. So, I guess problem solved.