Download

inertia tensor goes crazy when attaching another physics object

I have 2 physics objects. 1 big one (a vehicle about 60kg) and one little one (3kg). The big vehicle on its own behaves fine, but when I attach a little box to it using:


FAttachmentTransformRules rules(EAttachmentRule::KeepWorld, true);
smallerActor->AttachToActor(parentActor, rules);

The inertia tensor goes sky-high making it almost incapable of rotating. Stood on one end it takes about a minute just to fall over.
Before attach:

After attach:

Note that the mass has remained the same, maybe its just not including the child object.

I assumed there would be some kind of actor->recalculateInertiaTensor() function I could call, but there doesn’t seem to be. No SetInertiaTensor() functions either.
Anyone have any idea what is wrong?

Nevermind, problem solved.
I was increasing the inertia tensor multiplier of the vehicle, but it wasn’t getting applied until the attach function was called.
The function to recalculate is rootComponent->BodyInstance.UpdateMassProperties();