Disable collision response for a RigidBody for a short time?

Is this doable in any way at all?
I’m doing this for projectiles I guess it would make more sense to just go with a GhostControl, but those don’t seem to report collisions correctly (they just mostly report other ghostcontrols) and seem to have a huge performance impact compared to regular RigidBodyControl. CCD enabled, that is. The performance difference is 60fps with rigidbodies and game breaking freezes with ghosts. Is there any reason why such a thing would happen?

I’m not using any collisiongroups and would prefer not to because there is a limited number of them and I’d need way too many if I chose to go down this route.

I did find an ancient thread about something simmilar and someone suggested this:

That would be ideal, but I cant seem to find this method or that demo anywhere at all, so I assume this was for Jme2 or Jme1?

You can make a CollisionGroupListener and return false in the callback while you don’t want any collisions.

Is there such a thing? I’m still using 3.0 btw.

No, I just made that up right now to post here :chimpanzee_rolleyes:

https://javadoc.jmonkeyengine.org/com/jme3/bullet/collision/PhysicsCollisionGroupListener.html

2 Likes

This is only called when the collision will happen based on the collisionGroup and collideWithGroups settings in the PhysicsCollisionObject

Also, would there be one that gets called on every collision?

Huh? It gets called every time the objects would actually collide.

Yes, in case they are in different collisiongroups and have the collideWithgroups set to eachother. I have everything in group 01. I guess I could put half of everyhing in one group and the other half in another and have them collide each other but I’d rather not as it seems like a poor workaround.

I don’t get what you mean. No, they don’t need to have different collision groups.

If according to your collision/collidewith settings the objects would not collide the method doesn’t get called. If they do they do get called. Its exactly as I said, if the objects would actually collide the method WILL get called.

Ah, now I see, I forgot to add the listener to the physicspace and that’s why it wasn’t getting called. Sort of jumped to conclusions too quickly :stuck_out_tongue:

Works as intended now :chimpanzee_smile:

Just another question, if you have multiple objects that have listeners and they return different booleans for the method but for the same collision, which one then counts? The random last one on some list?

Any false in the mix should disable the collision.