I’m writing a custom movement component and moving a custom skeletal mesh I made in blender using SafeMoveUpdatedComponent
. Here is the main part of the code:
const FVector PositionDelta = CalculatePositionDelta(DeltaTime);
const FRotator RotationDelta = CalculateRotationDelta(DeltaTime);
const FQuat NewRotation = UpdatedComponent->GetComponentQuat() * FQuat(RotationDelta);
FHitResult Hit(1.0f);
SafeMoveUpdatedComponent(PositionDelta, NewRotation, true, Hit);
if (Hit.IsValidBlockingHit())
{
HandleImpact(Hit, DeltaTime, PositionDelta);
SlideAlongSurface(PositionDelta, 1.0f - Hit.Time, Hit.Normal, Hit, true);
}
UpdateComponentVelocity();
The collision behaves as if the physics asset of the mesh was rotated by 90 degrees, even though the debug Collision view shows that it’s oriented correctly, the asset preview looks good as well. When I rotate it by additional 90 degrees then it works as it should, but clearly something is not ok.
You can see it going through a box here:
And here is how it collides when I rotate the main part of the physics asset by 90 degrees.
The same issue occurs when I use this mesh with Floating Pawn Movement component.
EDIT: I’ve managed to identify the source of the issue – the root bone of my skeletal mesh had 90 degree rotation applied on it. Leaving the question open, because the fundamental issue still isn’t solved – if the root bone rotation is applied to the skeletal mesh why isn’t it applied to the physics asset?
5
The animation (pose) is calculated first, then physics applies a separate transformation over it.
A bone is a model’s handle for the physics engine to use, but it doesn’t go both ways.
Physics can move models but models have no way to calculate physics or affect the engine.
It’s related to the bug where characters move around in T-pose, poking limbs through walls. The physics engine uses whatever it is given, even if there animation errors.
2