I am creating a constraint on a sphere with the following code:
AplayerCode::AplayerCode(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
UPhysicsConstraintComponent* cc = NewObject<UPhysicsConstraintComponent>(this);
cc->ConstraintActor1 = this;
cc->ConstraintActor2 = NULL;
cc->ConstraintInstance.LinearXMotion = ELinearConstraintMotion::LCM_Free;
cc->ConstraintInstance.LinearYMotion = ELinearConstraintMotion::LCM_Free;
cc->ConstraintInstance.LinearZMotion = ELinearConstraintMotion::LCM_Free;
cc->ConstraintInstance.AngularSwing1Motion = EAngularConstraintMotion::ACM_Free;
cc->ConstraintInstance.AngularSwing2Motion = EAngularConstraintMotion::ACM_Locked;
cc->ConstraintInstance.AngularTwistMotion = EAngularConstraintMotion::ACM_Locked;
cc->ConstraintInstance.bAngularBreakable = false;
}
This seems to work as intended… I have a sphere that does not roll, but can turn left and right. However, sometimes after a collision the angular constraints seem to break and I start rolling even though I set bAngularBreakable to false. Any idea what could be causing this?
Also, I am assuming that creating a constraint tied to “this” will attach to the root component. In this example, my root component is a Sphere shape that is simulating physics.