Good day, I’m a software engineer and I’ve jumped into jmonkeyengine, I’ve built a simple voxel world (a collection of cube objects exported from Blender. This is the initial cube with a simple textured wrapped around the cube).
In the game, all works fine until you try to walk in-between two objects,
here is an example of what happens:
the player slides to the center of the cube being pushed by all of the surrounding cubes.
Currently the player has a CharacterControl built with:
CharacterControl control = new CharacterControl(new CapsuleCollisionShape(1.2f, 0.2f), 0.1f);
control.setFallSpeed(fallSpeed); -> 30
control.setJumpSpeed(jumpSpeed); -> 10
control.setGravity(gravity); -> 30
control.setPhysicsLocation(initialPosition); -> [0f, 0f, 0f]
and added to bullet state:
bulletAppState.getPhysicsSpace().add(ComponentUtil.getPlayer(player).getPlayerControl());
The objects are in waveform .obj format with a material attached. This is a 1x1x1 cube that is scaled down to 0.2 units as such:
Spatial cube = assetManager.loadModel(cubeName);
cube.setLocalTranslation(position); -> [0f, 0f, 0f]
cube.setLocalScale(cubeSize); -> 0.2f
With a RigidBodyControl:
RigidBodyControl rigidBodyControl = new RigidBodyControl(CollisionShapeFactory.createBoxShape(cube), 0f);
and each voxel is added to bullet:
bulletAppState.getPhysicsSpace().add(ComponentUtil.getVoxelComponent(voxel).getControl());
This system works perfectly when creating cubes using the Box model located inside jmonkey, the player can move freely. So I assume that there is different behaviour when using a Spatial over a Box type with RigidBodyControl. Or the capsule collision with the rigidBodyControl is pushing it around like a magnet.
What is my best plan of action? Should I attempt creating some collision mesh? Would it be better to create a box and somehow UV wrap it inside of jmonkey dynamically?
Perhaps there’s a setting i’m missing somewhere?
Any help would be very much appreciated, thank you!