Disable rotation on Actor that otherwise obeys gravity

I’m trying to keep a cube from toppling over a ledge–requiring that it is always upright and has to clear the ledge entirely before falling (without rotations). Any ideas on how to do this? (This desired outcome is similar to a puzzle in Ocarina of Time where you push blocks until they fall into their hole in the ground.)

Someone suggested Physics Constraints but that seems to only work when you are locking two objects together–and something like

actorPhysicsConstraint->SetConstrainedComponents(actorStaticMesh, NAME_None, NULL, NAME_None);

does not seem to work.

I want to Actor to obey gravity, and to respond to forces, etc. but I just need it to stay oriented the entire time.


I’ve finally figured it out. This is the code needed in BeginPlay needed to achieve the effect…

 //physicsConstraint->SetConstrainedComponents(staticMesh, NAME_None, NULL, NAME_None);
//physicsConstraint->SetAngularTwistLimit(EAngularConstraintMotion::ACM_Locked, 0);
//physicsConstraint->SetLinearXLimit(ELinearConstraintMotion::LCM_Free, 1);
//physicsConstraint->SetLinearYLimit(ELinearConstraintMotion::LCM_Free, 1);
//physicsConstraint->SetLinearZLimit(ELinearConstraintMotion::LCM_Free, 1);

My main problem was that I was trying to set SetConstrainedComponents in the constructor, which resulted in a failure to create the constraint while only issuing a warning. SetConstrainedComponents needs to be in BeginPlay.