Dynamic body and Line Joint

So here's my dilemma:
I have a ground-like object created. A box about 400px wide and 50 px tall. I have a polygon (called wedge) made with 5 Vertices to look like a spear/spike (or 5yr old's drawing of a house). I need the point at the top to line up with the top edge of the ground (they overlap), and then at certain intervals in the game an impulse applied to the object so it pops up and drops back down.

Now I thought maybe I could use a Line Joint to solve this problem, however, the wedge just bounces up and down rapidly, when it shouldn't 😕 . If the wedge is set to Dynamic that's when this occurs, so I tried static, and it did nothing, I then tried kinematic hoping that would help but I received same results as the static. Should I be using a different joint, or what would work best in this scenario ❓ I placed the object in an open area to test it before I pushed it off screen for it's actual location.

Also an option I thought of but can't use: I can place several bodies together to make one big concave polygon so that the wedges sit in a hole and just pop up, but then I will have gaps between the tips and the ground itself, which I just cannot have.

Any ideas, or any good tutorials on accomplishing this task would be greatly appreciated. Also I am using 2.1a 😀
One possible solution is to make your spear out of two fixtures and shapes. Have one that is the core shape you want to collide with the ground, and the other the tip shape that collides with everything else. Filter the tip shape so it doesn't collide with the ground.

like this I imagine
|---|
| | <--- one shape
|---| <--- will collide flat with ground on this edge.
\ / <--- second shape
\/

That way, the tip will appear to be embedded in the ground, but will still cause collisions with any other dynamic objects you may have.
I can kind of see where your going with that. But I'm still not sure why the body keeps bouncing on the Line Joint, Also I'm still rather new to Box2D and AS3. Anyway here is a picture of the effect i am trying to achieve:

Image

As you can see, the little object on the left is the wedge placed below the surface of the ground, and the object on the right is what it should be like when it pops up, then return to original state. Keep in mind that marbles will be sitting inside the container so they get mixed by the wedges. I hope this helps clarify the goal i wish to achieve. Again thank you for any help I receive. 🙂

*EDIT*
ok, I get the idea of using a filter, and how that would all work, how exactly would I implement the contact filter class? Would it be done the same as creating my own custom contact listener class? And if so, then it would probably be best to set user data on the wedge, and its already done on ground, so I can be selective in which two objects are being filtered then.
Actually, its even easier than that. All you have to do is specify a filter during the construction of your objects( you CAN do it at run time but I'm not going to get into that here )

b2FixtureDef has a filter property of type b2FilterData. This has three properties that are useful; categoryBits, maskBits and groupIndex. You are probably concerned with group index. Here is an excerpt from b2FilterData.as.

Code:
   /**
   * Collision groups allow a certain group of objects to never collide (negative)
   * or always collide (positive). Zero means no collision group. Non-zero group
   * filtering always wins against the mask bits.
   */
   public var groupIndex: int = 0;


So to make your spear and ground not collide, simply define both of their fixture defs with a matching negative group index.
ok that made a lot of sense in figuring that out, however, since that is the route I'd like to go that means I won't need to use a joint of any kind and can place the spikes in little cavities.
Except. I tried creating the cavities similar to the way I created the spikes by making a class specifically for boundary drawing. When I run the game though I am getting an Assertion Failed Error and I don't know why. Here is a copy of the new class and what the error looks like.

Code:
public var my_body         :   b2BodyDef    = new b2BodyDef();
public static var botP      :   int       = 144 / PhysiVals.worldScale;
public static var topP      :   int         = 0 / PhysiVals.worldScale;
      
public static var L0      :   int         = 0 / PhysiVals.worldScale;
public static var L1      :   int         = 71 / PhysiVals.worldScale;
public static var L2      :   int         = 77 / PhysiVals.worldScale;
public static var L3      :   int         = 147 / PhysiVals.worldScale;
public static var L4      :   int         = 153 / PhysiVals.worldScale;
public static var L5      :   int         = 223 / PhysiVals.worldScale;
public static var L6      :   int         = 229 / PhysiVals.worldScale;
public static var L7      :   int         = 299 / PhysiVals.worldScale;
public static var L8      :   int         = 305 / PhysiVals.worldScale;
public static var L9      :   int         = 375 / PhysiVals.worldScale;
public static var L10      :   int         = 381 / PhysiVals.worldScale;
      
//top vectors
public static var tv0      :   b2Vec2       = new b2Vec2(L0, topP);
public static var tv1      :   b2Vec2       = new b2Vec2(L1, topP);
public static var tv2      :   b2Vec2       = new b2Vec2(L2, topP);
public static var tv3      :   b2Vec2       = new b2Vec2(L3, topP);
public static var tv4      :   b2Vec2       = new b2Vec2(L4, topP);
public static var tv5      :   b2Vec2       = new b2Vec2(L5, topP);
public static var tv6      :   b2Vec2       = new b2Vec2(L6, topP);
public static var tv7      :   b2Vec2       = new b2Vec2(L7, topP);
public static var tv8      :   b2Vec2       = new b2Vec2(L8, topP);
public static var tv9      :   b2Vec2       = new b2Vec2(L9, topP);
public static var tv10      :   b2Vec2       = new b2Vec2(L10, topP);
      
//bottom vectors
public static var bv0      :   b2Vec2      = new b2Vec2(L0, botP);
public static var bv1      :   b2Vec2      = new b2Vec2(L1, botP);
public static var bv2      :   b2Vec2      = new b2Vec2(L2, botP);
public static var bv3      :   b2Vec2      = new b2Vec2(L3, botP);
public static var bv4      :   b2Vec2      = new b2Vec2(L4, botP);
public static var bv5      :   b2Vec2      = new b2Vec2(L5, botP);
public static var bv6      :   b2Vec2      = new b2Vec2(L6, botP);
public static var bv7      :   b2Vec2      = new b2Vec2(L7, botP);
public static var bv8      :   b2Vec2      = new b2Vec2(L8, botP);
public static var bv9      :   b2Vec2      = new b2Vec2(L9, botP);
public static var bv10      :   b2Vec2      = new b2Vec2(L10, botP);
      
public function Bounds()
{
   DrawBounds(214,300,40,600,"leftWall");
   DrawBounds(635, 300, 40, 600, "rightWall");
   DrawGround();
}
      
//static public function get world():b2World { return _world; }
      
public function DrawBounds(px,py,w,h,ud):void
{
   //my_body = new b2BodyDef();
   my_body.position.Set(px/PhysiVals.worldScale, py/PhysiVals.worldScale);
   var my_box:b2PolygonShape = new b2PolygonShape();
   my_box.SetAsBox(w/2/PhysiVals.worldScale, h/2/PhysiVals.worldScale);
   var my_fixture:b2FixtureDef = new b2FixtureDef();
   my_fixture.shape=my_box;
   my_fixture.density = 0;
   my_fixture.restitution = .3;
   my_fixture.friction = .6;
   var world_body:b2Body=PhysiVals.world.CreateBody(my_body);
   world_body.SetUserData(ud);
   world_body.CreateFixture(my_fixture);
}
      
public function DrawGround():void
{
   my_body.position.Set(425 / PhysiVals.worldScale, 602 / PhysiVals.worldScale);
         
   var leftSide:b2PolygonShape = new b2PolygonShape();
   leftSide.SetAsEdge(tv0, bv0);
   var leftFixt:b2FixtureDef = new b2FixtureDef();
   leftFixt.shape = leftSide;
         
   var top:b2PolygonShape = new b2PolygonShape();
   top.SetAsEdge(tv0, tv10);
   var topFixt:b2FixtureDef = new b2FixtureDef();
   topFixt.shape = top;
   topFixt.filter.groupIndex = -1;
   topFixt.restitution = 0.1;
         
   var spacer1:b2PolygonShape = new b2PolygonShape();
   spacer1.SetAsArray([tv2, bv2, bv1, tv1], 4);
   var sFixt1:b2FixtureDef = new b2FixtureDef();
   sFixt1.shape = spacer1;
         
   var spacer2:b2PolygonShape = new b2PolygonShape();
   spacer2.SetAsArray([tv4, bv4, bv3, tv3], 4);
   var sFixt2:b2FixtureDef = new b2FixtureDef();
   sFixt2.shape = spacer2;
         
   var spacer3:b2PolygonShape = new b2PolygonShape();
   spacer3.SetAsArray([tv6, bv6, bv5, tv5], 4);
   var sFixt3:b2FixtureDef = new b2FixtureDef();
   sFixt3.shape = spacer3;
         
   var spacer4:b2PolygonShape = new b2PolygonShape();
   spacer4.SetAsArray([tv8, bv7, bv7, tv7], 4);
   var sFixt4:b2FixtureDef = new b2FixtureDef();
   sFixt4.shape = spacer4;
         
   var spacer5:b2PolygonShape = new b2PolygonShape();
   spacer5.SetAsArray([tv10, bv10, bv9, tv9], 4);
   var sFixt5:b2FixtureDef = new b2FixtureDef();
   sFixt5.shape = spacer5;
         
   var bot:b2PolygonShape = new b2PolygonShape();
   bot.SetAsEdge(bv0, bv10);
   var botFixt:b2FixtureDef = new b2FixtureDef();
   botFixt.shape = bot;
         
   var rightSide:b2PolygonShape = new b2PolygonShape();
   rightSide.SetAsEdge(tv10, bv10);
   var rightFixt:b2FixtureDef = new b2FixtureDef();
   rightFixt.shape = rightSide;
         
   var world_body:b2Body=PhysiVals.world.CreateBody(my_body);
   world_body.SetUserData("ground");
   world_body.CreateFixture(leftFixt);
   world_body.CreateFixture(topFixt);
   world_body.CreateFixture(sFixt1);
   world_body.CreateFixture(sFixt2);
   world_body.CreateFixture(sFixt3);
   world_body.CreateFixture(sFixt4);
   world_body.CreateFixture(sFixt5);
   world_body.CreateFixture(botFixt);
   world_body.CreateFixture(rightFixt);
}


Code:
Assertion Failed
   at Box2D.Common::b2Settings$/b2Assert()
   at Box2D.Collision.Shapes::b2PolygonShape/SetAsVector()
   at Box2D.Collision.Shapes::b2PolygonShape/SetAsArray()
   at Bounds/DrawGround()
   at Bounds()
   at Arbles/CreateLevel()
   at Arbles()
   at DocumentClass/startGame()
   at DocumentClass/onRequestStart()
   at flash.events::EventDispatcher/dispatchEventFunction()
   at flash.events::EventDispatcher/dispatchEvent()
   at StartScreen/onClickStart()


Now the body itself is not convex but each shape is, would that cause a problem, and would I be better off in making each one of the shapes a separate body instead? I'm very confused as I have never seen this error befor.
Ok well I decided to go the route of separating them to different bodies and defining them as boxes instead.

Question though. How can I set my wedges/spikes to pop out of the ground to their fullest extent set regardless of the # of dynamic bodies above? I noticed that when I have say 10 or so above one it doesn't move as far. I set them to move with applyImpluse and I don't want to make the # too high because then if there is only 1 or 2 marbles above one it'll be like they got shot out of a cannon.
You probably want a prismatic joint, but there are many ways.

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