我无法实现与我的游戏的碰撞,更具体地说是主要玩家(一旦它与我设置的盒子碰撞,它就会弹回很远)。这是设置查看器的代码:
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 = new AxisSweep3(new javax.vecmath.Vector3f(-10000, -10000, -10000), new javax.vecmath.Vector3f(10000, 10000, 10000)); DefaultCollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration(); CollisionDispatcher dispatcher = new CollisionDispatcher(collisionConfiguration); SequentialImpulseConstraintSolver solver = new SequentialImpulseConstraintSolver(); detectionWorld = new DiscreteDynamicsWorld(dispatcher, pairCache, solver, collisionConfiguration); detectionWorld.setGravity(new javax.vecmath.Vector3f(0, -2f, 0));
我正在尝试移动玩家,然后将新位置应用于碰撞盒,然后执行物理步骤并将位置设置为新的碰撞盒位置。所以基本上我有两个向量占据一个位置。
编辑:有人吗?我仍然有这个问题