Bullet/Canon terrain collision Detection

Hi,



after much searching and physics section reading, this problem i have has me stumped,

Im using the Hello Physics canon code (except with a fire particle emitter) and when this coupled with a rigid body control it shoots perfectly and bounces off terrain as expected, however i want the canon/bullet to die after it hits the terrain or another object, so i added in a PhysicsCollisionListener

which unfortunately picks up the terrain and character object as a collision even though i start the canonball fall from +100f on the y-axis,



basically it keeps reporting that its colliding with the terrain and character (oto at CapsuleCollisionShape(4, 10):wink: so i cant kill it,



what ive tried so far:

  • heightfieldCollisionShape on the terrain
  • the different get methods of PhysicsCollisionEvent
  • debug mode on physics space to see collision shapes, only the bullet/canon sphere shape showed up.



    Thanks.

One method ive found is using applied impulse and checking if its non zero (meaning it hit something)



[java]if(event.getAppliedImpulse()>0){[/java]



the only problem i have now is that direction and position from where it starts is all wrong, i thought i fixed it yesterday, its most likely cos its hitting the player.

Try do in an update loop:

[java]CollisionResults result = new CollisionResults();

terrain.collideWith(canonBall,result);

if (result.size() > 0){

//Canonball has touched the ground.

[/java]

I thought that, but im trying to keep everything modular and PhysicsCollisionListener does just that, checking for change in impulse works, as i should be able to check if its terrain or player object, if player → deal damage