How do I create linked rigid bodies?

Hello,

I originally wrote my own 3D engine in OpenGL + Bullet Physics (and a bunch of other libraries) in order to make a virtual creature evolution simulation. I now want to try to do the same in Unreal Engine 4. Unfortunately, I have no clue where to start or how to do anything, since examples either do not exist or use blueprints (I want to use C++). Could any of you give me some code snippets for creating some rigid bodies and linking them together with motorized joints, or at least point me in the right direction?

Thank you for any help you can offer.

#Video

I have a video on this topic here

in my case the joints were not meant to allow any mobility, but I could have just as easily done that

#UPhysicsConstraintComponent

The key word for your entire goal is this:

UPhysicsConstraintComponent

Look up some info here on this answer hub with that keyword

I’ve posted elsewhere on this topic

EDIT nvm its hard to find stuff that way

here’s how you create the component:

UPhysicsConstraintComponent* ConstraintComp = NewObject<UPhysicsConstraintComponent>(RootSMA);
if(!VISVALID(ConstraintComp)) return;

Here’s how you activate the constraint:

//~~~ Init Constraint ~~~
ConstraintComp->SetConstrainedComponents(RootSMA->StaticMeshComponent, NAME_None, TargetSMA->StaticMeshComponent,NAME_None);

Assuming you are linking two static mesh actors.

All properties are set via

ConstraintComp->ConstraintInstance = //your own FConstraintInstance

check out the source code for “ConstraintInstance.h”

it has all that you want.

Limit motion, limit angles!

Limit Twists!

or Lock things all together!

Yay!

:slight_smile:

Rama

Thanks for the response! The information you gave me on the constraints will certainly be useful, but I first need to figure out how to make rigid bodies before I link them together. How would I go about making a simple box-shaped rigid body? Sorry for such a noob question!