I would like for the body of a vehicle to stop spinning and stay upright for the rest of the game.
I do not want to have the body of the vehicle to spin along with the wheel, so I set the angular swing to ACM_Locked, as shown:
UPhysicsConstraintComponent* PhysicsConstraintComponent = ObjectInitializer.CreateDefaultSubobject<UPhysicsConstraintComponent>(this, ConstraintNames*);
PhysicsConstraintComponent->SetWorldLocation(this->GetActorLocation()); //Set world location.
PhysicsConstraintComponent->AttachTo(this->GetRootComponent(), NAME_None, EAttachLocation::KeepWorldPosition); //Attach to root.
PhysicsConstraintComponent->SetConstrainedComponents(this->FrameMeshComponent, NAME_None, MeshComponent, NAME_None);
PhysicsConstraintComponent->SetAngularSwing1Limit(EAngularConstraintMotion::ACM_Locked, 0.0f);
PhysicsConstraintComponent->SetAngularSwing2Limit(EAngularConstraintMotion::ACM_Free, 0.0f);
PhysicsConstraintComponent->SetAngularTwistLimit(EAngularConstraintMotion::ACM_Locked, 0.0f);
Since the spinning body of the vehicle is instantiated in C++ and not using blueprints, I wasn’t able to set the “Mass in KG” in the Physics detailed panel.
What can I do to stop the body frame from spinning when I start rolling the wheels?