This project has moved and is read-only. For the latest updates, please go here.

Creating objects OnCollision

Topics: Developer Forum
Feb 14, 2013 at 4:48 AM
I'm trying to create a simple circle in an oncollision handler but i am getting an assert fail (island.cs line 444). What am I supposed to do?

My Code:
        var b = BodyFactory.CreateCircle(world, 0.5f, 1.0f, active.Position, null);
        public void Add(Body body)
            Debug.Assert(BodyCount < _bodyCapacity);
            Bodies[BodyCount++] = body;
Feb 14, 2013 at 9:21 AM
Just a wild guess, but perhaps you are not allowed to create new bodies at this time?

What you could try instead is set a flag and create the Body in your Update method before you call World.Step.
Feb 18, 2013 at 5:36 AM
I'm copying this to an issue to see if this can be improved in the future.
Feb 18, 2013 at 5:36 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.