Page 1 of 1

Best way to implement a motor on one body?

Posted: Thu Nov 16, 2017 4:47 pm
by sak
I want to implement a capsule representation for a character which behaves kind of like one of those inflatable punching bags (http://shop-boxen.de/wp-content/uploads ... -Bag-0.jpg)

Basically the character should stand up straight, but rather than locking the angular factor on the rigid body representation, it should be able to be knocked off kilter and then right itself.

I'm thinking it might make sense to accomplish this with a motor: basically I could compare the desired orientation with the current orientation and then applying an angular motor target speed to correct the difference.

The question is:

1. Does this approach make sense?

2. What's the best way to implement the motor? I see that the 6DOF constraint has motor control members: can I implement a 6DOF constraint which is only attached to one rigid body?

Re: Best way to implement a motor on one body?

Posted: Fri Nov 17, 2017 3:35 am
by xissburg
1. Does this approach make sense?

I guess. You should get similar behavior using a capsule shape with a very low center of mass (use a compound shape to displace the center of mass).

2. What's the best way to implement the motor? I see that the 6DOF constraint has motor control members: can I implement a 6DOF constraint which is only attached to one rigid body?

You can create constraints with only one body (it gets attached to a static object under the hood). You could use a btGeneric6DofSpringConstraint to make it wobble around by adjusting the spring stiffness and damping.

Re: Best way to implement a motor on one body?

Posted: Fri Nov 17, 2017 3:49 pm
by drleviathan
The low center of mass approach will Just Work. I've seen it used for exactly that purpose: a punching bag that stands up by itself.