Disabling collisions momentarily

I have a situation where I want to fire missiles from a hard point near or within my ship model. The thing is, I don't want the missile collisions with the ship to activate until maybe 1 second after firing, once it has cleared the ship collision bounds. Is there a simple way to do this?

Well, simply ignore reported collisions with that ship for some time? :slight_smile:

Or in other words: That strongly depends on the way you handle that collisions at the moment…

Hmm. Well I'm probably not doing something right.  :stuck_out_tongue: Because all objects in the scene will bounce off of each other by default. I usually only do something special when a bullet hits an object or a missile hits an object. The thing is, I don't even want the default behavior to be active when the missile launches. This is probably just me being dumb and not understanding the physics system well enough.

Well, the default behaviour of a physics engine would be for stuff to bounce off when a collision occurs. :-p

If you want realism you need to make it so it doesn't hit anything to cause it to bounce instead of having to force violations of physics in order for it to work, but that's just my opinion. ;)  If you really don't want it to work then just disable the physics object until it's clear and then re-enable it.


No, no. There is a better way: To ignore collision between two object use the physics callback and ignore the contact. For an example of using that callback see the BuggeDemo (GDCCallBack). In that onContact method you can execute an contact.ignoreContact() if your missle hits the owning ship within some time frame.

Irrisor, just curious, how is that better than disabling the object until a certain time has elapsed? (need to know if I should change some code)  :-p


  • because collsions with other objects than the ship should still be detected. E.g. you would want to let the missile explode if it hits a foe within that second…

I guess it depends on what he's going for.  I assumed it was a "1 second before the missile is armed" kind of deal…like on a torpedo (at least in the movies). :o


I think it was more like "1 second until the missile has come out of the ship".

Yep. Perfect. That's exactly what I was looking for. Thank you very much!

My only question is that while in game the missile passes through the ship without any visible collision (as it is ignoring the contact), I notice that the defaultContact method in GDCCallBack is still called after it is ignored. Why would that be?

I guess it doesn't matter since it really does ignore any contact actions for that contact. But I just found it odd.

I think it's so you can get a second chance to change your mind. :slight_smile:


Slowdive said:

I notice that the defaultContact method in GDCCallBack is still called after it is ignored.

I'll change that. It's more or less a bug as you can't "change your mind" either (once ignored the contact is useless).
Btw. GDCCallBack is just the name of that one specific class as it was for the GameDev Conference  :)