Arrows

Here is a testbed example showing two bodies, with the rear one set to a higher linearDamping value.
Code:
package TestBed{ 
  import Box2D.Dynamics.*;
  import Box2D.Collision.*;
  import Box2D.Collision.Shapes.*;
  import Box2D.Dynamics.Joints.*;
  import Box2D.Dynamics.Contacts.*;
  import Box2D.Common.*;
  import Box2D.Common.Math.*;
 
  public class TestArrow extends Test{
   
    public function TestArrow(){
     
      // Set Text field
      Main.m_aboutText.text = "Arrow";
      var mps = m_physScale;
      // Add bodies
      var sd:b2PolygonDef = new b2PolygonDef();
      var bd:b2BodyDef = new b2BodyDef();
      //bd.isBullet = true;
      var b:b2Body;
      sd.density = 10.0;
      sd.friction = 0.5;
      sd.restitution = 0.1;
     
      sd.SetAsOrientedBox(4/mps,4/mps);
      bd.position.Set(50/m_physScale,300/m_physScale);
      b = m_world.CreateBody(bd);
      b.CreateShape(sd);
     
      b.SetMassFromShapes();
     
      sd.SetAsOrientedBox(12/mps,2/mps);
      sd.density = 0.1;
      bd.position.Set(38/mps, 300/mps);
      bd.linearDamping = 5;
      var b2 = m_world.CreateBody(bd);
      b2.CreateShape(sd);
     
      b2.SetMassFromShapes();
     
     
      var r:b2RevoluteJointDef = new b2RevoluteJointDef()
     
      r.Initialize(b, b2, b.GetPosition());
     
      m_world.CreateJoint(r);
       
      b.ApplyForce(new b2Vec2(300, -100), b.GetPosition());   
    }
  }
}
android wrote:
Here is a testbed example showing two bodies, with the rear one set to a higher linearDamping value.

Yeah! That's the best solution ! Good job!

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