# How do I copy box2d data from one body to another?

I want to copy all Box2D-related data (position, velocity, rotation, impulse, ...) from one body to another.

This is what I've got working (with box2djsweb):

var t = body.GetTransform();
other_body.SetTransform(t);

var vel = body.GetLinearVelocity();
other_body.SetLinearVelocity(vel);


I think that covers most things, but judging by the behaviour, I've missed something. It's as if it's a frame or tick behind. Also, this isn't placing the other_body in the exact location as the the original body.

Is there a better way to do this?

Box2D has a CreateBody function in the b2World class that takes another body as a definition. Which uses the 'definition body' to create a new body. This does not copy the fixtures/shapes attached to the body.