Jan 12, 2011 at 6:22 PM
Edited Jan 12, 2011 at 9:42 PM
I would like to dispose a fixture in it's own OnCollision.
The problem is: if I have multiple contacts and because of that I cannot dispose the body without getting Error in the next OnCollision (that happens in the same moment because of multiple contacts on multiple different fixtures).
I have tried to use if (contact.next == null) body.dispose; I thought that means: if there is not another contact then there is not another OnCollision and I could dispose the body because it isn't needed anymore.
But the problem is that sometimes I get:
contect.prev != null and
contact.next == null and I do not get another OnCollision.
Or sometimes I even get contact.prev == something and contact.next == something, although I have only 2 bodies which are in collision with the OnCollision's body.
I hope you understand what I mean xD
Just to be sure:
I have one bullet which hits two Enemies at the same time and I need to dispose it properly without getting an error in the second OnCollision.
Thank you very much!
K, I have have managed to do it with (bullet.UserData as Bullet).Fixture.Dispose(); at the end and if (bullet == null) return false; at the beginning, so if a bullet hits two enemies at the same time it get's disposed at the first enemy's
OnCollision, and the second one's OnCollision doesn't do anything =D
I thought there was maybe a better way for this to handle both enemies and dispose after the last one, but for now it's ok.. although I would still appreciate a hint =D
Good night ; )