as new and exited with the jmonkey power, i tried to combine some of the beginners tutorials.
The town.zip was loaded and used as terrain with RigidBody as control. The “player” creates sphere bullets that have also RigidBody of mass 1 and LinearVelocity set.
Now, why the collision does not always work? Do i need to change the bulletAppState.getPhysicsSpace().setAccuracy ?
Apart from that, i tried to make the test even cooler(hotter in fact ) and add flames on collision with terrain. So i used inside the bullet controller:
if ((!on_fire) && (this.spatial.collideWith(this.app.getRootNode().getChild(“main-scene_node”).getWorldBound(), results)>0))
CollisionResult closest = results.getClosestCollision();
System.out.println("What was hit? " + closest.getGeometry().getName() );
for (int i=0; i < results.size();i++)
is seems that it collides with itself!!??? Collision with the terrain is not recorded
Should i use ghostcontrol instead?
Thank you for your time! i hope that this make sense!
Tried the GhostControl and now it seems to collide with the terrain (in the air???)
What i am missing??
First, dont use ghostcontrol.
Second, for terrian, use mass = 0.
Now, what are you using in the objects physics ? Kinematic ? Just Rigid Body ?
Thank you for your reply! Yes i used mass of zero as shown below:
Spatial sceneModel = assetManager.loadModel("main.scene");
CollisionShape sceneShape =CollisionShapeFactory.createMeshShape((Node) sceneModel);
sceneModel.addControl(new RigidBodyControl(sceneShape, 0));
I used just rigidbody:
ball_phy = new RigidBodyControl(1f);
The strange is that when i replaced the terrain with a geometry (box), the bullet was colliding only when touched the ground (as supposed to).
Is town.zip your creation ?
It may be an problem in your model, try to change it in blender.
I saw other new players having this kind of problem, I never had, but I guess you may need to do some “fix” like make an biguer box behind the ground.
Bullet is another engine, you will not find much help here in the forum about bullet problems, you may consider post some questions in their forum as well.
No it is from the beginners tutorials(Collision detection).
Just thought that it was something common or known issue
The same behavior can be noticed when using heightmap (at least in my case).
I have already used the debugger of the Bullet, to view the triangles, but nothing strange is found in the air!
Now, regarding the collision accuracy, should it be changed? (sometimes the bullets are crossing the buildings)
Good news wagfeliz! It seems that i have found the solution
if ((!on_fire) &&
reversed it to
if ((!on_fire) && (((Node)this.app.getRootNode().getChild("main-scene_node")).collideWith(this.spatial.getWorldBound(), results)>0))