I am trying to constrain physics. In blueprint it works fine but I can’t get it to work in C++.
I have a USphereComponent that I’m creating:
UPROPERTY()
TSubobjectPtr<USphereComponent> CollisionComp;
And initializing:
CollisionComp = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT("SphereComp"));
RootComponent = CollisionComp;
And configuring the physics state:
CollisionComp->SetSimulatePhysics(true);
CollisionComp->InitSphereRadius(0.01f);
CollisionComp->BodyInstance.bUseCCD = true;
CollisionComp->BodyInstance.LockedAxisMode = ELockedAxis::Y;
CollisionComp->SetEnableGravity(false);
The only thing that isn’t working is the locked axis. Am I missing a step somewhere?