This project has moved. For the latest updates, please go here.

Error in CollideAll

Topics: Developer Forum
Feb 3, 2010 at 2:45 AM

I'm trying to find all geoms that are under a point,
sometimes CollideAll crashes :

System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at System.Collections.Generic.List`1.Enumerator.MoveNext()
   at FarseerGames.FarseerPhysics.PhysicsSimulator.CollideAll


Any ideas ?


Feb 3, 2010 at 12:49 PM

Have you removed objects from the physics simulator?

Feb 3, 2010 at 7:31 PM

Yes, I have.
I called physicsSimulator.Remove(body)
and then disposed the body.

Is there anything else to do when removing objects ?

Feb 4, 2010 at 9:46 AM

Try removing the geom as well.

If continue giving errors, try first disabling the bodies and geoms without removing them and see if the error persists.


Feb 4, 2010 at 12:53 PM

Actually, I'm removing just the Geom.

I need to resize it, so I remove it, build a new one and recaculate the Body MomentOfInertia.

I will try to disable and remove later.