Set Position of multiple bodies

Posted by philipp on Game Development See other posts from Game Development or by philipp
Published on 2014-04-22T18:37:16Z Indexed on 2014/08/22 4:28 UTC
Read the original article Hit count: 213

Filed under:

I have a character composed of five bodies which are tied together by a lot of joints. On of them is the overall chassis, to which all forces and impulses are applied to move the whole Character.

All in all that works very fine, except one thing: I need to set the Position of the Character so that it get Beamed from one place to the other in one single frame.

Unfortunately I cannot get this to work. I tried the following code, without any success…

playerbodies.forEach(function (bd) {
    bd.SetLinearVelocity(new b2.Vec2());
    var t = bd.GetTransform();
    t.p.x -= 10;
    bd.SetTransform(t, bd.GetAngle());
});

How can I make that happen?

© Game Development or respective owner

Related posts about box2d