Physics upright constraint

Is there a way to set a physics upright constraint in blueprint? The Vehicle class in UDK had this built in, but I was interested in continuing to build a physics based pawn with better control over forced physics in certain cases.

I think I’m doing something similar if I’m understanding you correctly… It’s not locked to be upright but if the object does get knocked to the side, it will slowly reorient itself. Check the last part of this. Blueprint…

This works incredibly well during the input phase of controlling physics, thanks! the problem i’m having is that i need to control some aspect of physics after an impact. so for example, if a physics object is airborn, when it lands, it needs to apply impulses that auto-upright it. (similar to the effects of flipping an overturned vehicle in UDK)

[Edit] - your principle worked after all. instead of applying physical forces to create an uprighting constraint, i just lerped an actor rotation along the desired axis similar to your example. thanks!

You should be able to get exactly the ‘upright constraint’ behaviour from UE3 using a ConstraintComponent inside your physics vehicle, constraining the physics body to the ‘world’, setting linear DOFs to be ‘free’ and setting the angular DOFs to be ‘limited’ with soft limits.

i briefly looked at the constraint components, but didn’t realize that ‘world’ was a valid candidate as a constrain-to object. this opens all kinds of possibilities. i look forward to experimenting with these mechanics and will post some of the results.

[Edit] - works perfectly now, thanks JamesG!

is this possible at runtime? i’m creating scenarios where i need to lock constraints, but don’t see these variables exposed in blueprints.

You can modify constraint drive at runtime (see SetLinearPositionDrive etc in UPhysicsConstraintComponent) but you cannot modify constraint limits. However, if you call TermComponentConstraint, then change the settings, then call InitComponentConstraint, that should work.

I went with this approach rather than breaking and re-initializing the constraint. here is the result so far. this is all with blueprints as well.

if I were to add a constraint component at runtime for future development, how would I get the ‘world’ variable to assign to the component 2 input?

Leaving ConstraintActor2=NULL and ComponentName2=None should make it use the ‘world’.