[Solved] Water

Really I don't get your code (that's why it's not working)
You are checking for the reaction force limit on every contact 😮 😕
Really, (on each frame) you must go through all joints and check their reaction force... ➡️ 😐
ooooh ok. I'll do that.
K so would this work?
Code:
for (var jj:b2JointDef = joint.m_jointList; jj; jj = jj.next)
{
   if (jj.GetReactionForce().Length()>forceLimit)
   {
      m_world.DestroyJoint(jj);
   }
}

I tested it and it runs without errors, but none of the joints are breaking. I also turned forceLimit down to 1;
var jj:b2JointDef ---> very funny 😀


var jj:b2Joint
= joint.m_jointList... once again I don't get it!

for (var jj:b2Joint = m_World.GetJointList(); jj; jj = jj.next)
Um... sorry I told you I was new. I appreciate you helping. None of the joints are breaking still.
http://addeventlistener.deviantart.com/ ... -111953580
Code:
var joint:b2DistanceJointDef;
var forceLimit:int = 1;
      
function Update(event:Event){
   
   FRateLimiter.limitFrame(frameLimiter);
   
   UpdateMouseWorld();
   m_world.Step(m_timeStep, m_iterations);
         
   for (var bb:b2Body = m_world.m_bodyList; bb; bb = bb.m_next) {
      if (bb.m_userData is Sprite) {
         var bb_mc = bb.m_userData;
         if (!bb.IsSleeping()){
            bb_mc.x = bb.GetPosition().x * m_physScale;
             bb_mc.y = bb.GetPosition().y * m_physScale;
            bb_mc.rotation = bb.GetAngle() * (180/Math.PI);
         }
               
         for (var cc:b2ContactEdge = bb.m_contactList; cc; cc = cc.next) {
            if (cc.other.m_userData is Box&&bb.m_userData is Water){
               stage.removeChild(bb.m_userData);
               m_world.DestroyBody(bb);
               break;
            }
         }
               
         for (var dd:b2ContactEdge = bb.m_contactList; dd; dd = dd.next) {
            if (dd.other.m_userData is Water&&bb.m_userData is Water){
                     
               var ddPoint:b2Vec2 = new b2Vec2(dd.other.GetPosition().x, dd.other.GetPosition().y);
               var bbPoint:b2Vec2 = new b2Vec2(bb.GetPosition().x, bb.GetPosition().y);
                     
               joint = new b2DistanceJointDef();
               joint.Initialize(dd.other, bb, ddPoint, bbPoint);
               m_world.CreateJoint(joint);
               break;
               
               for (var jj:b2Joint = m_world.GetJointList(); jj; jj = jj.next)
               {
                  if (jj.GetReactionForce().Length()>forceLimit)
                  {
                     m_world.DestroyJoint(jj);
                  }
               }
            }
         }
      }
   }
}
So
for (var bb:b2Body = m_world.m_bodyList; bb; bb = bb.m_next) {
this goes through all the bodies in the world.

for (var dd:b2ContactEdge = bb.m_contactList; dd; dd = dd.next) {
This thing(as far as I can see, never used it) handles every contact(collision) for each body.

and
for (var jj:b2Joint = m_world.GetJointList(); jj; jj = jj.next) {
this thing goes through all the joints in the world, like a first loop, but with joints.

At the moment you are trying to check all joints everytime you check a body, and every time if the body have a collision. That's not right!
Place your joint loop after your handle-all-bodies loop.

I'm not that good in explaining, especially in English.
I get this error once I put it out of the body loop.

1119: Access of possibly undefined property next through a reference with static type Box2D.Dynamics.Joints:b2Joint.
Use GetNext(), not next. Next time it tells you something is undefined, you should look up what it should be rather than giving up.
Yeah you're right. sorry bout that.... so I changed it to GetNext(). Now I'm confused. When you grab the guitar, the joint is destroyed, but grabbing the water does nothing. None of the joints between particles are being destroyed either.
http://addeventlistener.deviantart.com/ ... ubmitted=1

Original thread: https://box2d.org/forum/viewtopic.php?t=2226