Collision with box ? not in physic

Hello,

I want to create a game build only with cube.

I create my cube like that :

[java] private void setUpBox(){

/** A simple textured cube – in good MIP map quality. */

Box boxshape1 = new Box(new Vector3f(-3f,1.1f,0f), 1f,1f,1f);

Geometry cube = new Geometry(“My Textured Box”, boxshape1);

Material mat_stl = new Material(assetManager, “Common/MatDefs/Misc/SimpleTextured.j3md”);

Texture tex_ml = assetManager.loadTexture(“Interface/Logo/Monkey.jpg”);

mat_stl.setTexture(“m_ColorMap”, tex_ml);

cube.setMaterial(mat_stl);

rootNode.attachChild(cube);

}[/java]

but how add collision ? in the HelloCollision, i didn’t find something than can help me …

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_picking

Yes, it’s the collision by shooting, but how can i get if my charactere (in fps camera mode) hit a cube ?



what i have to get exactly it’s a world build with cube where you can’t passthrough if you understand :slight_smile:



it’s hard to explain, but their is a game based on the same id (all build in cube), it’s minecraft : http://www.youtube.com/watch?v=0VWnQHS-ffs

i didn’t want to copy it, i want to create a new type of game based on players versus players on a server where you can build your kingdom.

Collidable.collideWith(otherCollidable). So terrain.collideWith(myBox)

Thank you, i will try it, i think it’s was i was looking

@normen

Witch type of collision class i have to use ?

CollisionShape or CapsuleCollisionShape or an other ?

i didn’t understand how to put a collision between my box (??class) and my char (CapsuleCollisionShape class).



ps: i didn’t want to put gravity or moving of my box by the physics



thank you for all your answere :slight_smile:

Thats the physics classes you don’t want to use. The collision system we are talking about is based on geometry and doesnt need any special collision shapes.

But i didn’t understand how use it with collision for exemple, your town is auto build and i don’t understand how build a collision world …

Do you get an exemple of building a world ?

Theres nothing auto-built here. I dont understand what you mean. If you dont want physics movement there can be no physics collisions, for anything else you can use the collision system and check if two Spatials collide that way.

yes, for sure i didn’t say than someone do the work for me :smiley:



but i’m trying this and it’s doesn’t work …



my box with jmonkey face

[java]private void setUpBox(){

/** A simple textured cube – in good MIP map quality. */

Box boxshape1 = new Box(new Vector3f(-3f,1.1f,0f), 1f,1f,1f);

Geometry cube = new Geometry(“My Textured Box”, boxshape1);

Material mat_stl = new Material(assetManager, “Common/MatDefs/Misc/SimpleTextured.j3md”);

Texture tex_ml = assetManager.loadTexture(“Interface/Logo/Monkey.jpg”);

mat_stl.setTexture(“m_ColorMap”, tex_ml);

cube.setMaterial(mat_stl);

rootNode.attachChild(cube);

}[/java]

my player (flyCam)

[java] flyCam.setMoveSpeed(100);[/java]



check the collision ? you said than :

[java]Collidable.collideWith(otherCollidable). So terrain.collideWith(myBox) [/java]

So, i have to do

[java]flyCam.collideWith(cube)[/java]

but their is a synthaxe error …

The cam is no Collidable, BoundingVolumes and Spatials are.

1 Like

thank you, it’s exactly what i need :slight_smile:

You know that with the javadoc you can see the class structure pretty well? It even shows what classes implement what interfaces, extend what other classes etc.

We could make the Camera a collidable though!

We have the CameraNode for that no? Its bringing everything with it so we dont have to hack it into the cam… But if you think its easy to do… :slight_smile: