[Solved] Water

Hey,
So I'm trying to simulate water. You probably saw my last post. I made the circles stick together on impact, but now they look like clumps of goo 🙂 I'm trying to figure out a way to loosen the joints so they break easily like real water.
http://addeventlistener.deviantart.com/ ... -111953580
No idea on the fix, but it looks cool. 😀
Looks like you are using revolute joints 😕
Use distance joints instead
Use GetReactionForce to break them
Yeah they're distance joints. They do kinda seem like revolute joints though since they're added on impact.. So I read a bit about GetReactionForce in the user manual. How do I use it?
on each frame call your update function for each distance joint
Code:
public var forceLimit:int=4000;
public var torqueLimit:int=500;
public function update() {
if (yourjoint.GetReactionForce().Length()>forceLimit || Math.abs(yourjoint.GetReactionTorque())>torqueLimit) {
   world.DestroyJoint(yourjoint);
}
}

Example: http://img132.imageshack.us/img132/9884/gamemainqy7.swf
(left click to grab, space to release, don't double click
throw things to the box(not too hard, circles around 15-25 damage,rectangles around 10-15 damage) and they will stuck in the box, then you can pull em out)
I think you don't need torqueLimit thingy, just delete it.
Hey, thanks for replying. That's really cool. I like the sticking. So I put it in, and I got these two errors. I'm not sure how to fix them. You can probably tell I'm new to box2d 🙂

1067: Implicit coercion of a value of type Box2D.Dynamics.Joints:b2DistanceJointDef to an unrelated type Box2D.Dynamics.Joints:b2Joint.

1061: Call to a possibly undefined method GetReactionForce through a reference with static type Box2D.Dynamics.Joints:b2DistanceJointDef.
I really don't know why, but in my code it's like that:
Code:
(yourjoint as b2DistanceJoint).GetReactionForce().Length()>forceLimit

This shouldn't help, but try!
i say keep it the way it is. call FLOAM CATCHER
Haha it's a nice idea, but I'm making it for a different game. Yeah that didn't work Neosano. Here, I'll put my code up for my Update function.
Code:
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;
            }
                  

//here it is
            if (joint.GetReactionForce().Length()>forceLimit)
            {
               m_world.DestroyJoint(joint);
            }
         }
      }
   }
}

Thanks!

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