I'm creating a rectangular body:
(Java)
And trying to rotate it (by 45 degree angles) like this:
However, it doesn't seem to me like the bounding box is being rotated. Since the body is taller than it is wide, when it is rotated 90 degrees it'll move partway through other fixed bodies (and other times it will stop short of coming into contact with another fixed before). I printed the vertices of the shape, and they appear to move, however when I printed the OBB of the shape, it doesn't change at all.
Am I doing something wrong, or is this supposed to be how it works?
(Java)
Code:
// define the body
BodyDef bodyDef = new BodyDef();
//bodyDef.allowSleep = false; //?
bodyDef.position.set(new Vec2((float)x/10f, (float)y/10f));
body = world.createBody(bodyDef);
// create the body
PolygonDef rect = new PolygonDef();
rect.setAsBox((float)sprite.getWidth()/20f, (float)sprite.getHeight()/20f);
body.createShape(rect);
BodyDef bodyDef = new BodyDef();
//bodyDef.allowSleep = false; //?
bodyDef.position.set(new Vec2((float)x/10f, (float)y/10f));
body = world.createBody(bodyDef);
// create the body
PolygonDef rect = new PolygonDef();
rect.setAsBox((float)sprite.getWidth()/20f, (float)sprite.getHeight()/20f);
body.createShape(rect);
And trying to rotate it (by 45 degree angles) like this:
Code:
body.setXForm(body.getPosition(), (float)(Math.toRadians(45*angle)));
However, it doesn't seem to me like the bounding box is being rotated. Since the body is taller than it is wide, when it is rotated 90 degrees it'll move partway through other fixed bodies (and other times it will stop short of coming into contact with another fixed before). I printed the vertices of the shape, and they appear to move, however when I printed the OBB of the shape, it doesn't change at all.
Am I doing something wrong, or is this supposed to be how it works?