February 2, 2020, 12:14pm
I would like to apply torque to a rigidbody from a point other than it’s center of mass. For example, if a body’s position is (1, 1, 1), then by default torque will be applied from the same point. What I would like to do is apply torque from a different point, say (0, 0, 0). Any way to do this?
I don’t think this is doable since the underlying physics engine (Ammo.js) doesn’t seem to support, in the same manner you can do it when applying a force:
m_invInertiaLocal = diagInvInertia;
void setSleepingThresholds(btScalar linear,btScalar angular)
m_linearSleepingThreshold = linear;
m_angularSleepingThreshold = angular;
void applyTorque(const btVector3& torque)
m_totalTorque += torque*m_angularFactor;
// XXX AMMO local addition to bullet
void applyLocalTorque(const btVector3& torque)
m_totalTorque += m_worldTransform.getBasis() * torque * m_angularFactor;
And I think it makes sense since a rotational force makes sense to be applied to center/origin point of the body.
February 2, 2020, 1:21pm
@Leonidas is there a workaround for this? My game won’t be able to function without this…
Not sure, what are you trying to achieve?
February 2, 2020, 1:44pm
Take a look at this👆. Use arrow keys to turn the object. If I make the circles on the end point upwards, the images don’t fall on it, but the bigger circle below it. I suspect this is because the object have moved, but the collision shapes haven’t. Or is it something else?
There are several issues with this project:
All of the SpinningCenter bodies are set to
Static, this won’t work if you are moving the objects. You are moving the objects using entity translation methods (
rotateLocal) instead of applying forces/torques to the rigid bodies.
Try updating the project to fix this and you will be in a better shape. If it still doesnt’ work try posting again, here.
February 2, 2020, 2:04pm
I don’t know why this is there, I told my dev to use torque.
I don’t want the objects to respond to gravity. How would I do it then?
Once I know the answer to this, I can fix it.
Then use Kinematic objects, this will do the trick for you, take a look at the manual towards the bottom there is a good explanation on how they work:
February 2, 2020, 2:15pm
Ok, thanks. Will try this out tomorrow, and get back with the result.
February 3, 2020, 2:00pm
I forked the project and did what you asked me to. Works great. Marking as solved.