Re-Adding Body

0 views
Skip to first unread message

Bobby5808

unread,
Jun 29, 2009, 7:16:58 AM6/29/09
to Physics2D.Net
Hi Ive made an emitter in my game that emits a body every few
seconds.Each body has a short lifespan so they expire soon. Also, If
there are any expired items, then instead of creating a new body I
will readd that body to the engine.

For some reason though, the more times the bodies are readded, the
seem to become lighter and gradually drift upwards faster and faster.

I have GlobalFluidLogic added, could it possibly be that the Body is
being added again and again to the Logic, and not being removed when
its expired?

Thats all I can think of that could be the cause, Ive tried just about
everything else. If that is the case, how do I fix it?

Thanks

Bobby5808

unread,
Jun 29, 2009, 7:44:09 AM6/29/09
to Physics2D.Net
I managed to trace the bug, I found it just after posting this
thread :)

In PhysicsEngine.cs, under RemoveExpiredBodies, change this:

for (int index = 0; index < logics.Count; ++index)
{
logics[0].RemoveExpiredBodies();
}

to this:

for (int index = 0; index < logics.Count; ++index)
{
logics[index].RemoveExpiredBodies();
}

A nasty little bug... :)

JonoPorter

unread,
Jun 29, 2009, 11:11:10 AM6/29/09
to Physics2D.Net
Great find. Thanks for posting this I'll get this into the SVN ASAP.
Reply all
Reply to author
Forward
0 new messages