I am having trouble implementing collisions with my game, more specifically the main player (once it collides with a box i have setup, it bounces far back). This is the code to setup the viewer:
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);
And this is the physics world setup:
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));
I am trying to move the player and then apply the new position to the collision box, and then do a physics step and set the position to the new collision box location. So basically I have two vectors taking in a position.
EDIT: Anyone? I am still having this issue