문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top