A simple question about collision

What is the simplest way of doing something like

spatial.dontCollide() or rigidBody.dontCollide()

such that the object is not used in any collision detection.

Hum… The simplest way is not to add it to the physical space !

1 Like

Yang,

Thanks for your reply. I didn’t make myself clear. I still want Dynamic Newtonian motion. But no collision detection.

Oh… Right. I’ve seen this somewhere. Let me look…
Yes. It’s right here in the tutorials : https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:physics_listeners#collision_groups

You have to create a group for limiting collisions to this group. Even if it’s empty (thus no collision…)

Well, I wrote these lines - and the two objects still bounce off of each other. What am I missing?

object1.spatial.getControl(classOf[RigidBodyControl]).
setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_01);
object2.spatial.getControl(classOf[RigidBodyControl]).
setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_02);

I still would like a spatial.dontCollide method :o) - which I would write right now if only I knew how.

I believe you have to set the setCollideWithGroups as well:

[java]fiveInchGun[i].Turret.getControl(RigidBodyControl.class).setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_04);
fiveInchGun[i].Turret.getControl(RigidBodyControl.class).setCollideWithGroups(PhysicsCollisionObject.COLLISION_GROUP_02 | PhysicsCollisionObject.COLLISION_GROUP_04);
fiveInchGun[i].Barrel.getControl(RigidBodyControl.class).setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_05);
fiveInchGun[i].Barrel.getControl(RigidBodyControl.class).setCollideWithGroups(PhysicsCollisionObject.COLLISION_GROUP_02 | PhysicsCollisionObject.COLLISION_GROUP_05);[/java]

These lines make sure that the turret and the barrel do not collide with each other in my application, while they DO collide with everything which is in group 2.

Dear Husky & Yang,

Thank-you, thank-you. The object passes through things, and still keeps its Newtonian dynamics - yey. The thing is, the main reason for wanting to do all this was I thought it would speed up the ‘frame rate’ if I took an object or objects out of the collision detection process. Surprisingly to me, the frame rate was the pretty much the same before and after. Weird. Interesting. I shall have to investigate.

Thanks again.

Andre