Download

Constraint Angular Velocity Drive

If I set Angular Velocity Drive for a PhysicsConstraintActor from the Editor all fine and dandy. I start playing and the Constraint Actor swings for a few seconds then stops.

However, if I do the same from C++ code, the actor does not stop swinging. What am I missing?

I also tried from Blueprints with “Set Angular Velocity Drive”, “Set Angular Velocity Target” and “Set Angular Drive Params”. Same thing, the actor does not stop swinging.

Editor settings:

Angular Velocity Drive - checked
Angular Velocity Target - 0,0,0
Angular Drive Force Limit - 1000.0
Angular Position Strength - 50.0 (editing disabled)
Angular Velocity Strength - 1.0
Angular Drive Mode - Twist and Swing

C++ code:


for (TActorIterator<APhysicsConstraintActor> AItr(this->GetWorld()); AItr; ++AItr)
{
    AItr->ConstraintComp->SetAngularVelocityDrive(true, true);
    AItr->ConstraintComp->SetAngularVelocityTarget(FVector(0.f, 0.f, 0.f));
    AItr->ConstraintComp->SetAngularDriveParams(50.0f, 1.0f, 1000.0f);
    AItr->ConstraintComp->ConstraintInstance.AngularDriveMode = EAngularDriveMode::TwistAndSwing;

    GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, "Params set for " + AItr->GetName());
}

Resolved by Gleb Bulgakov here