Physics is unstable =/

it's a simple 3d pong game, where your have the pong ball and the player plank to not let it fall.



the problem is… it won't bounce proprialy! the ball sometimes just change it's direction when it colides on one of the walls, like, it's going X+ Y+ Z-, then it bounces in the left wall (invert Z), but instead it does X+ Y- Z+, it indeed inverted Z axis but inverted Y too, and now the ball is falling back before it should, and i guess the players will not like it ;D



since it's realy hard to explain, so i will just disponibilize the netbeans project in svn.



you can get anonimously the project form here: https://svn.inf.ufsc.br/guedez/3D-Pong



edit: aparently it can be read by anonymous by default :smiley:

i have just set space.setAccuracy(0.0001f); the problem persists, but at least it's minimal in occorence, what's the default value for it? is it a good approach?



edit: just noticed it is not! it now likes to crash when the ball gets below the player board, what should be impossible, since the board is a 50x10x50, and the ball radius = 30, the board is glued to the ground… but it does happen…



any better idea?



edit:edit: hmm, it wasen't glued to the ground… oh well, anyways!

Somewhere it was mentioned that the physics engine likes the average scale to be 1.0… Your ball being 30 units, quite large from the recommended.

I think 30 shouldn't be a problem.



I have found the problem is stressed when small things (0.01 order)  interact with large objects (200+).

I haven't look at your code yet, but are you using tri-mesh collision accuracy? If so, don't. Try using the sphere primitive for your ball.

im using a sphere primitive for colision on the balls, a static node (with a box primitive for collision) for the player board(that moves with "setLocalTranslation" based on mouse movements), and a node with 6 TriMeshes planes using generated physics geomety with triangle accuracy(if i remove triangle accuracy from the 6 TriMeshes it returns the following error mensage: "java.lang.IllegalArgumentException: scale must not have 0 as a component (geom 'My Mesh')!").

One thing to note is that static nodes are not meant to move. I imagine that is what is throwing off the simulation.

that would certainly explain odd behaviour when the ball collides on the player board(or whatever it's  called).

However it won't explain the odd behavior with the ball colliding with the walls and changing direction improprialy, since the "moving static" node is not included on this collision