# Restrict all Movement to 2d/plane for one geometry subclass

Hi!

I need some “2d physics”. The geometries that are supposed to be in this “fake 2d space” all have the same height (= “fake none”), so theoretically I could just put them between two planes and let collision detection restrict all movement to the x/z plane with brute force.

But there’s probably a better / simpler solution for that?

Use a 2d physics engine

There is a way to do this in bullet, with setLinearFactor (vec3), which constrains an axis, but because jBullet never implemented this, we don’t use it.

If you want to use this, you can: either wait until we implement native bullet completely in jME 3,1, or you can write the modifications and build the native bullet library yourself.

Use a 2d physics engine :)
Guess I should have made that clearer: I still need the y axis + 3d physics in the scene. Just not for that one geometry subclass.
<cite>@wezrule said:</cite> There is a way to do this in bullet, with setLinearFactor (vec3), which constrains an axis, but because jBullet never implemented this, we don't use it.

If you want to use this, you can: either wait until we implement native bullet completely in jME 3,1, or you can write the modifications and build the native bullet library yourself.

That sounds like what I’m looking for… maybe I’ll take a look at it, if my “brute force planes” fail to do the job.

Simplest thing might be to lose the planes and just force the velocity and position onto the plane.

i.e. if plane is in the x/z then:

velocity.y = 0
location.y = 0

Do that after the physics tick

I don’t use physics myself so not sure what the API involved would be or even how possible that is.

Oh, right, I tried that before I used the planes - but I didn’t manage to get the rotation sorted out (reset angle around z/x but leave y alone).

Would that be a better solution than planes-collision? Then I guess I’ll have to try again…

It would be less expensive and possibly more accurate than bouncing it off planes. As said above I don’t know how feasible it is with the physics api though.