3

I create 2 Spartials and set one as RigidBodyControl, second as BetterCharacterControl. Both are boxes of sizes = (10f, 1f, 10f) and (0.5f,0.5f,0.5f).

 floor = createFloor();
 CollisionShape sceneShape = CollisionShapeFactory.createMeshShape(floor);
 landscape = new RigidBodyControl(sceneShape, 0);
 floor.addControl(landscape);
 rootNode.attachChild(floor);

 character = createCharacter();
 player = new BetterCharacterControl(1F,1F,0.01f); 
 character.addControl(player);
 rootNode.attachChild(character);

 bulletAppState.getPhysicsSpace().add(landscape);
 bulletAppState.getPhysicsSpace().add(character); 
 landscape.setPhysicsLocation(new Vector3f(0,-4,5));
 player.warp(new Vector3f(0,0,0));

Now if i run it ... the character just bounces on the floor and i don't know why. If i use the standard CharacterControl it works, though. I'am aware that the character box doesn't match the shape but that shouldn't be the problem i guess.

Thanks in advance!

EMP
  • 31
  • 3

3 Answers3

1

Did you try and turn on debugging?

bulletAppState = new BulletAppState();
bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
stateManager.attach(bulletAppState);
bulletAppState.setDebugEnabled(true);

Using debugging could help you see the collision shapes.

Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424
0

thanks for sharing the debug tip. The problem was:

player = new BetterCharacterControl(1F,1F,0.01f); 

You shouldn't create a Cylinder that has a smaller radius than the sizes.

player = new BetterCharacterControl(1F,1F,1F); 

worked fine.

EMP
  • 31
  • 3
0

In my case, I needed to increase the height of my character by increasing BetterCharacterControl(1.5f, 1f, 1f) to BetterCharacterControl(1.5f, 6f, 1f). I'm not sure why this solved the problem for me, but it did.

devinbost
  • 4,658
  • 2
  • 44
  • 57
  • did you find a better fix for this? so basically your 1f tall char became a giant :(, I think we may need to change the mass, but that all is too messy, I think bettercharctrl could be fixed/improved instead. We can extend that class to expose several variables and override methods, that I am trying to do to fix things up. – Aquarius Power Jan 15 '15 at 16:50
  • Yes, you can see where we ended up here: https://github.com/devinbost/jMathGame3d (I haven't worked on this project in a while because it was for a school assignment, but we did solve this particular problem.) – devinbost Jan 15 '15 at 19:29