Pregunta

I know it breaks physics laws, but although there are often practical reasons to change instantaneously the position and orientation of a body in a game, most physic simulation libraries won't allow it, so Bullet Physics won't either.

So, I'd appreciate any suggestion or comment on this one.

By the way, teleportation comes to mind that requires those instant changes. Also a more exotic application could be inertia - for instance when tilting or rotating a portable device with accelerometer, so that objects would appear to be static in relation to the user. Augmented reality shouldn't sound cheesy.

¿Fue útil?

Solución

Assuming that I understand your question correctly, I'd recommend checking out BulletDynamics/Character/btCharacterControllerInterface.h and/or BulletDynamics/Dynamics/btActionInterface.h. Oftentimes one wants to "bend the rules" when implementing character movement - to implement teleporting, for example, one could use the void warp(const btVector3& origin) method from btCharacterControllerInterface.

Personally, I've had the best luck inheriting directly from btActionInterface, storing a pointer to a btGhostObject that I can update and implementing my logic from there, but YMMV.

Note: If you're just wanting to change the position and orientation, you should be able to call the void setWorldTransform(const btTransform& worldTrans) method for btRigidBody.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top