You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed this completely by accident, but I fear this library is not stable enough to use because of this. I ended up with an extra b2Vec2 that I wasn't using, so I deleted it, but it caused my physics spawn to stop working. Made some other changes and now I had to add two unused b2Vec2 instances to get it to work. Makes absolutely no sense. All I can think is it's some kind of odd race condition?
// this "zero" vec2 does nothing and is not referenced anywhere but if I comment it out nothing spawnsconstzero=newb2Vec2(0,0)constpos=newb2Vec2(options.x,options.y)letshapeconstfixture=newb2FixtureDef()fixture.density=1.0fixture.friction=0.3shape=newb2CircleShape()shape.m_radius=options.radiusconstbodyDef=newb2BodyDef()bodyDef.set_type(b2_dynamicBody)bodyDef.set_position(pos)constbody=this.world.CreateBody(bodyDef)body.CreateFixture(fixture)body.SetTransform(pos,0)body.SetAwake(true)body.SetEnabled(true)
The text was updated successfully, but these errors were encountered:
Still don't fully understand what's going on, but it seems destroying the pos b2Vec2 I was using after each spawn makes it work, without adding unused b2Vec2 objects. Very strange! I get that the objects are pooled in this version, which is great but I don't understand how that could even cause this behavior as it didn't stop working after the first spawn, it just didn't work at all. I also was not reusing b2Vec2s for each spawn, I was creating new ones so not sure how that would affect it but it does.
I noticed this completely by accident, but I fear this library is not stable enough to use because of this. I ended up with an extra b2Vec2 that I wasn't using, so I deleted it, but it caused my physics spawn to stop working. Made some other changes and now I had to add two unused b2Vec2 instances to get it to work. Makes absolutely no sense. All I can think is it's some kind of odd race condition?
The text was updated successfully, but these errors were encountered: