New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
btTransform operator* on btVector3 missing from IDL // cannot applyForce local/relative to btRigidBody #277
Comments
For anyone looking how to apply a force local/relative to btRigidBody in ammo.js, here's how: Set the relativeForce which is a btVector3 into a btTransform using btTransform.setOrigin, then use op_mul and retrieve the resulting btVector3 using btTransform.getOrigin I'm now going to close the issue, I hope people will find this if anyone has the same trouble I did. |
Thanks @ricksterhd123! Exactly the problem I was struggling with... And thank you again for leaving a breadcrumb to this page on a 10-year-old thread, the internet needs more heroes like you 👏 |
Same here! Thanks @ricksterhd123 |
If you are using three JS, just do: |
@ricksterhd123 solution is not working for me. Seems I can only use setLinearVelocity. Which is not what I want, because then gravity is not working. |
Been trying to applyForce relative to a rigidbody, if anyone has any ideas how I may do this then please let me know. Anyway, after trying to follow the solution from this ancient forum post: https://pybullet.org/Bullet/phpBB3/viewtopic.php?t=2366 I've found this:
btVector3 relativeForce = btVector3(0,10,0);
btTransform* boxTrans;
boxRigidBody->getMotionState()->getWroldTransform(boxTrans);
btVector3 correctedForce = (boxTrans * relativeForce) - boxTrans.getOrigin();
boxRigidBody->applyCentralForce(correctedForce);
If you look in
https://pybullet.org/Bullet/BulletFull/classbtTransform.html
then you see that
btVector3 operator* (const btVector3 &x) const
is needed to achieve it, however i cannot find this definition in the IDL anywhere.
Please could someone look into fixing this? Does anyone have an alternative solution, I just don't want to waste time migrating to another physics library...
The text was updated successfully, but these errors were encountered: