point of impact

I'm looking for the point of impact so i can add a graphic there.
im using beginContact.
the contact is between a sensor-dynamic bullet and a static wall.

the wall is listening for the bullet.

Code:
public function handleBeginContact(e:ContactEvent):void {
   var b:BodyShape = e.relatedObject as BodyShape;
   if(!b)return;
   if(b is shot){
      e.contact.
      doExplode(new Point(e.contact.GetManifold().localPoint.x, e.contact.GetManifold().localPoint.y));
      b.remove();
   }
}


if i use the x and y of the bullet it is not exact, and is often off the wall a little ways, i would like it to be precisely where the bullet contacts the wall.

i appreciate that the variable i used is specifically labeled local point.
i am looking for a global point
i am not sure what this point is local to (perhaps one of the two bodies, perhaps something else) it seems to return 0.

i've also tried

Code:
e.worldManifold.GetPoint()


but that seems to return null.
sketchbookgames wrote:
if i use the x and y of the bullet it is not exact, and is often off the wall a little ways

You mean the position of the bullet body right? Would the closest point on the wall to the bullet position be a good enough approximation?
Quote:
Would the closest point on the wall to the bullet position be a good enough approximation?


yes that would be much closer than what i have now, which is using the bullet position. which is often the farthest part of the bullet from the wall (due to my reg point)
Ok, a couple of things:

1. You mentioned you're using a sensor for the bullet. I believe sensors don't generate actual contact points which is why you're getting null. I've gotten in the habit of not using sensors for bullets for exactly this reason (since you can just manually disable contacts anyway), but I believe you can force contact point generation by calling either contact.Evaluate() or contact.Update() (I can't recall which one at the moment) off of the contact event.

2. You want to use the world manifold if you want the contact points in world coordinates. Call getWorldManifold() off of the contact event. You'll probably get null if you're dealing with a sensor though.
ah, not using sensors would probably do the trick, thanks mayobutter! i will try that.

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