If adding those additional tests help, then the sender is not the same as the vehicle body/turret. For example, if the event is attached to the incoming missile, then even after the vehicle gets removed, the missile's Space will still be non-null, so the sender's space will still be non-null.But I don't know why. You see ?
Another potential problem is the use of the pair's EntityB property:
Code: Select all
if (pair.EntityB != null && (string)pair.EntityB.Tag == "missile")
There is no guaranteed order for the pair's objects. The missile associated with the event might be related to EntityA, or it might be related to EntityB. By only checking EntityB, some cases will be missed. Consider making use of the 'sender' and 'other' parameters, or testing both EntityA and EntityB.
CreatingContact is an 'immediate' event, as opposed to the ContactCreated 'deferred' event. Immediate events run inside engine execution. Further, if multithreading is being used, immediate events will be called from another thread. Busting in during the middle of execution and corrupting the book-keeping with a remove would be bad enough by itself, but doing it from an asynchronous context is a recipe for unpredictable disaster.2/ I think also ( question 2 ), that when I delete a thing in the creatingContact event, bepu have bugs. But it's occure only when the objet is colliding with multiple objets. Why ?
If you meant ContactCreated instead of CreatingContact, then I do not have sufficient information to diagnose the issue.