Hello guys, for train my, I devellop a cubic game like minecraft, so all are right, but when I walk a little I pass trought the cube, as they are physic it is strange !
I have write the in game part on a AppState.
edit : problem solved, I have modified the dir.y and camLeft.y value to 0.5f
[java]public void update(float tpf)
{
Vector3f dir = cam.getDirection().mult(0.15f);
Vector3f camLeft = cam.getLeft().clone().multLocal(0.1f);
dir.y = 0.5f;
camLeft.y = 0.5f;
walkDirection.set(0, 0, 0);
if (left)
{
walkDirection.addLocal(camLeft);
}
if (right)
{
walkDirection.addLocal(camLeft.negate());
}
if (up)
{
walkDirection.addLocal(dir);
}
if (down)
{
walkDirection.addLocal(dir.negate());
}
player.setWalkDirection(walkDirection);
cam.setLocation(player.getPhysicsLocation());
}[/java]
For create the terrain I use a method makeCube(Vector3f position, int typeOfCube)
[java]public void makeCube(Vector3f position, int typeOfCube)
{
//Create a cube Geometry and attach it to the scene graph
Geometry cube = new Geometry(âcubeNumberâ + numberOfModel, box);
RigidBodyControl rbc = new RigidBodyControl(boxShape, 0);
cube.addControl(rbc);
bullet.getPhysicsSpace().add(rbc);
if(typeOfCube == 1)
{
cube.setMaterial(grass);
}
else if(typeOfCube == 2)
{
cube.setMaterial(beton);
}
rootNode.attachChild(cube);
rbc.setPhysicsLocation(position);//set physical location
numberOfModel++;
}[/java]
My player is physical too, I init his physic on the initPhysic() method :
[java]public void initPhysic()
{
CapsuleCollisionShape capsule = new CapsuleCollisionShape(0.5f, 2f, 1);
player = new CharacterControl(capsule, 1f);
player.setJumpSpeed(10);
player.setFallSpeed(30);
player.setGravity(40);
player.setPhysicsLocation(new Vector3f(5, 10, 5));
bullet.getPhysicsSpace().add(player);
}[/java]
In images with debug mode (sorry if images are too big) :
normal comportment
When I pass trought the pysical ground :
Have you an idea, of the problem ?
For box worlds donât use cubes! Look at custom meshes and voxels
ok, I know now for what the game lag ^^
tank
sorry If I am stupid, but have you a documentation for voxel ?
because I have try too read the boxel engineâs source, but I donât understand anything
There is plenty of information on the forums, you are not the first one to ask about voxel engines. just use the search. Really, the topic comes up nearly every week.
sorry, I have search, and I have dowload the voxel devellopment kit, bloxel source, and bloxel engine source, but I donât know how to use of it,
I think I will try custom meshe, that is more easy than read the source code of a project ^^
You should not simply download any source and think it will magically solve all your problems.
Try reading about what a voxel engine is (big hint: A Box world is, in fact, NOT composed of boxes). Try to understand what a âvoxel worldâ really is. And then, how you can make it appear on the screen (hint: create custom mesh programatically from voxel data).
And maybe you go and search the forums again, as i said, there is plenty of information here. Not only some source code and some more or less ready-to-use voxel engines, but plenty of descriptions what a boc world really is and how to manage it.
I wouldnât have told you, that the information is there, if it werenât. The question comes nearly every week.
thank you I do that, sorry for disturbance