# How to set the inertia tensor for a component?

I’m trying to freeze rotation for a Pawn that is simulating physics. Freezing its position goes fine by putting the linear dampening to a high value, however putting the angular dampening to a high value does not prevent it from rotating during a collision.

In this thread https://answers.unrealengine.com/questions/8970/feature-request-freezes-rigidbody-positionrotation.html it was suggested that you can set the inverse inertia tensor to 0 along some axes, but which function should I call to do this?
I cannot find properties for the inertia tensor in the editor or documentation anywhere, except for vehicles.

We automatically calculate inertia tensor based on the density and the simple collision geometry, there isn’t a way to set it directly. Possibly adding a constraint would be another way to accomplish this? Or you could modify the source to let you do it!

1 Like

Physics constraints seem to be useful when there are two Actors involved. However, I’m trying to control the effects of a collision of a Pawn with any object in the world.

So far I am able to achieve reasonable results by overriding the ReceiveHit event and adjusting the physics angular and linear velocities. However the ReceiveHit event is always called AFTER the physics engine pushed through its changes. This results in glitchy behaviour as described by the following example:

Suppose there is a Pawn simulating physics that has a very high linear velocity and is moving directly towards a wall
Suppose the physics angular and linear dampening of the pawn is set to zero
Suppose the physics material of MyPawn and the wall is set such that restitution is 1.0
Suppose the ReceiveHit event resets the velocities to zero:

``````

void APawnClass::ReceiveHit(class UPrimitiveComponent* MyComp, class AActor* Other, class UPrimitiveComponent* OtherComp,
bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit) {
Super::ReceiveHit(MyComp, Other, OtherComp, bSelfMoved, HitLocation, HitNormal, NormalImpulse, Hit);

MyPawn->SetPhysicsLinearVelocity(FVector::ZeroVector);
MyPawn->SetPhysicsAngularVelocity(FVector::ZeroVector);
}

``````

When the pawn hits the wall it will stop moving, but it didn’t stop exactly at the wall. It bounced back a little and its rotation has changed. Now when I try to set the world rotation and location of MyPawn to my liking in the ReceiveHit event this results in glitchy behaviour, because I’m always one frame behind.

I hoped that there was an easier way to have complete control over the physics engine besides messing with the source code.

You can create a constraint between your pawn and the ‘world reference frame’, just by leaving the second object blank.

We’re having a discussion here about whether exposing an option for ‘zero inverse inertia’ would be an easy feature to add!