Why does collision detection stop?

I have an Enemy game object that has a RigidBody and a Box Collider (with trigger) on it. I also have a Player game object that has two child objects each with a trigger Box Collider on it - one called Shell and the other called RangeFinder.

The idea is that as the Enemy moves forward, if it collides with the RangeFinder child object, the Player starts firing Bullet objects at the Enemy. If the Enemy hits the Player’s Shell object, the Enemy stops moving.

Naturally, if a Bullet object hits the Enemy object, the Enemy takes some damage and the Bullet is destroyed.

This all works perfectly for me until the Enemy stops moving (and this is based on a simple flag in the Update function). When the Enemy stops, its as if they become transparent to the Bullets.

The RangeFinder is still working because the Bullets keep getting fired but the Bullets pass straight through the Enemy.

If I tell the Enemy to start moving again, the Bullets again hit the Enemy but the moment the Enemy stops moving, the Bullets pass through again.

Can anybody explain this strange behaviour? And how do I go about getting it so that it works correctly?

set collision mode to continuous for the enemy. it should be in their collider options. to save memory, normal collision mode is interpolated or something like that which means it skips frame so I don’t know what, which is not good for fast moving objects and small objects, also try setting the bullet collider as continuous, actually colliders doing seemed to be that well adapted for bullets that move fast, there is continuous detection mode I don’t know tell what you reckon.

Thanks Zoom. I did think of that pass-through situation too but that didn’t fix it.

But you did get me thinking and I did some testing. If you are testing for a collision between two objects and only one has a RigidBody attached, then if the object with the RigidBody is stationary, it doesn’t matter what the other object does. It will never trigger a collision trigger event of any sort. But if the RigidBody object is moving, then both objects receive the collision trigger events.

To my mind, this doesn’t make a whole lot of sense. The collision trigger event should occur regardless of whether the RigidBody object is moving. The only reason I even have a RigidBody on the object in the first place is that Unity won’t recognise collisions otherwise. When you don’t care about the physics of the collision, it seems redundant and ineffecient to me to have to attach RigidBodies to every object just to guarantee that you get the collision trigger event.

Move ur bullet inside FixedUpdate()[so u can get exact/even time interval] and then keep its collision mode continues dynamic[coz its moving very fast], make ur enemy collision mode continues.