I am experiencing some unexpected behaviour when using ITriggerEventJob for handling collisions in our ECS with netcode for entities based game.
I created custom "CollisionDetectionSystem" to handle collissions. The system uses the ITriggerEventJob for this. When a collision is detected the "CollisionDetectionSystem" destroys the entity that collided with the other entity.
From the debug console I can see that it does register the collision and that the destroy part works (of course with the latency from when the server destroys the entity until is recognized as no longer there, all expected in a network based game).
But even though the entity no longer exists (state.EntityManager.Exists returns false) the ITriggerEventJob keeps on firing that a collision occurred between entities with same index and version but without any components.
I have been programmed to run server side.
Thus the trigger job keeps reporting a collision each frame between the destroyed entities until, and this is where it gets really strange, a new colliding entity is instantiated.
Note that I also did a non-netcode for entities version (just plain ECS) and here the ITriggerEventJob worked as expected and does not continue to fire after the colliding entity is destroyed.
It looks like some problem in the combination of "netcode for entities" and ITriggerEventJob, but could also be that I am doing something wrong with regards to Ghost configuration, system ordering, or other.
See full post here: https://forum.unity.com/threads/in-netcode-for-entities-the-itriggereventjob-keeps-receiving-collision-events-long-after-a-colliding.1522045/