我很难实现与我的游戏,更确切地说,主要玩家(一旦它与一个盒,我已经设置,它反弹回来)的碰撞。这是设置查看器的代码:
CollisionShape myCol = new CylinderShape(new javax.vecmath.Vector3f(0.4f, 0.9f, 0.4f)); DefaultMotionState motion = new DefaultMotionState(new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new javax.vecmath.Vector3f(0, 33, 0), 1f))); javax.vecmath.Vector3f fallInertia = new javax.vecmath.Vector3f(0, 0, 0); //myCol.calculateLocalInertia(0, fallInertia); RigidBodyConstructionInfo cInfo = new RigidBodyConstructionInfo(1, motion, myCol, fallInertia); self\_Col = new RigidBody(cInfo); self\_Col.setFriction(1f); self\_Col.setRestitution(1f); self\_Col.setDamping(0.04f, 0.1f);
这就是物理世界的格局:
AxisSweep3 pairCache =新AxisSweep3(新javax.vecmath.Vector3f(-10000,-10000,-10000),新javax.vecmath.Vector3f(10000,10000,10000));DefaultCollisionConfiguration collisionConfiguration =新DefaultCollisionConfiguration();CollisionDispatcher dispatcher =新CollisionDispatcher(collisionConfiguration);SequentialImpulseConstraintSolver solver =新SequentialImpulseConstraintSolver();detectionWorld =新DiscreteDynamicsWorld(dispatcher,pairCache,solver,collisionConfiguration);detectionWorld( new DiscreteDynamicsWorld(0,-2f,0));
我试图移动播放器,然后将新位置应用到碰撞盒中,然后执行物理步骤并将位置设置为新的碰撞盒位置。基本上,我有两个矢量在一个位置上。
编辑:有人吗?我仍然有这个问题
发布于 2013-09-01 13:34:38
JBullet通常有许多从0到1的单位。恢复原状是造成你这个问题的原因,复原就是你碰撞的形状有多有弹性。你的补偿是高的,试着减少它,看看这是否有帮助。
self_Col.setRestitution(0.1f);https://stackoverflow.com/questions/15914289
复制相似问题