# Physics to cubes as terrain

hello,
i’m trying to make an endless running game (temple run style). I realized the terrain as a list of flat cubes as tiles that keep scrolling endless, but how can i make them ‘‘walkable’’?
If i add rigidbody control to objects and put them on the terrain they fall down through it, so how could i realize that?

Don’t use physics at all games like that use simple collision detection

Maybe something like this:
`if (character.getLocalTranslation().y <= floorY){ //you are on the floor. Stop falling. }`

Based on your description, only your walking objects have a RigidBodyControl? The terrain also needs one to act as physical ground (and not only as visual object in the scene).

and how could i implement the “stop falling” ?

yes, currently only my character has a rigidBodyControl, but if i add rigidBodyControl to the terrain it would fall down…

This example may help you: https://wiki.jmonkeyengine.org/doku.php/jme3:advanced:terrain_collision

Objects fall down because they have a mass. You want the object to not fall down.
I wonder what number you could use as mass in the RigidBodyControl constructor.

if i set mass 0 tiles will stay ‘‘in air’’ but my character with physic will not rest on them but will pass through them falling down… that’s just my original problem xD

Ever heard of kinematic rigid bodies? They aren’t affected by any forces, but they will apply forces to other dynamic rigid bodies.

You should have a variable speedY or something like that.
Every update you should call something like this:

``````Vector3f vec = character.getLocalTranslation();
vec.Y += speedY;
character.setLocalTranslation(vec);
speedY -= 1;// Change this for diffrent gravity
``````

When your character jumps you should set speedY to a positive value. The character will go up and then start falling down. When you detect that character should stop falling you must then set speedY to 0 (every frame).

enable the debug wireframe for physics. https://wiki.jmonkeyengine.org/doku.php/jme3:advanced:debugging
and post a screenshot of it

probably there is something wrong with the collision shapes. Also make sure that when you attach your player, it’s collision shape is above the floor. Let the player fall down from a height, on the terrain.

thank you all, i’ll try all your solutions and i’ll let you know

Made tiles kinematic… works fine… thank you!