[SOLVED] Capsule bug jump

When i run and press jump jump jump jump
character (capsule) Jumping higher and higher

capsuleShape = new CapsuleCollisionShape(1.4f, 3f, 1);

    characterControl = new PlayerControl(capsuleShape, 0.05f);

    characterControl.setJumpSpeed(20);

    characterControl.setFallSpeed(100);
    characterControl.setGravity(60);
    // characterControl.setPhysicsLocation(new Vector3f( 0.9f,  0.02f, 0.22f));
1 Like

You can use the isOnGround() method to check whether the player is able to jump or not.

1 Like

characterControl
capsuleShape

has not method isOnGround().
how i can check it?

1 Like
if (characterControl.onGround()) {
    characterControl.jump();
}
1 Like

Thanks

1 Like

Not work at windows

1 Like

Not work at linux then too.

2 Likes

Use BetterCharacterControl and you wont have the problem.

2 Likes

Unlike the code these controls?

1 Like
  protected void checkOnGround() {
        TempVars vars = TempVars.get();
        Vector3f location = vars.vect1;
        Vector3f rayVector = vars.vect2;
        float height = getFinalHeight();
        location.set(localUp).multLocal(height).addLocal(this.location);
        rayVector.set(localUp).multLocal(-height - 0.1f).addLocal(location);
        List<PhysicsRayTestResult> results = space.rayTest(location, rayVector);
        vars.release();
        for (PhysicsRayTestResult physicsRayTestResult : results) {
            if (!physicsRayTestResult.getCollisionObject().equals(rigidBody)) {
                onGround = true;
                return;
            }
        }
        onGround = false;
    }

source from better character control.

1 Like
  Vector3f rayVector1 = new Vector3f(moveSpatial.getWorldTranslation().x,characterControl.getPhysicsLocation().y + 2,characterControl.getPhysicsLocation().z);

               
                Vector3f rayVector2 = new Vector3f(moveSpatial.getWorldTranslation().x,moveSpatial.getWorldTranslation().y - 3,moveSpatial.getWorldTranslation().z  );
                
                
                Ray physicsDownRay = new Ray(rayVector1,rayVector2);

                CollisionResults results = new CollisionResults();


                instance.sceneModel.collideWith(physicsDownRay, results);

This method collides 90% of level…

Bad fix block jump by timeout

if (Jump) {
long currentTime = System.currentTimeMillis();

            if(jumpTime <  currentTime){   
                jumpTime = currentTime + jumpTimeOut;
                characterControl.jump();
            }   
       }
1 Like