I still don't know what I'm doing wrong... The body stays at angle = 0.5 radians from the create time till the impact time! I'm using Box2D XNA.
This is my code of initializing the world...
And here is the object creator void:
Because I need to create them dynamically in runtime with unknown quantity. And the result looks like this: https://www.dropbox.com/s/due3u98gd83gxwp/sol.JPG
What am I wrong?
This is my code of initializing the world...
Code: Select all
Gravity = new Vector2(0, -10);
PhysicsWorld = new World(Gravity, true);
And here is the object creator void:
Code: Select all
public void AddRectShape(float X1, float Y1, float W, float H)
{
BodyDef bf = new BodyDef();
PolygonShape P = new PolygonShape();
// Testing stuff: keep the first one stay right and rotate the another.
if (BodiesCount == 0) bf.type = BodyType.Kinematic; else { bf.type = BodyType.Dynamic; bf.angle = 0.5f; }
bf.position = new Vector2(X1, Y1);
P.SetAsBox(W, H);
FixtureDef fx = new FixtureDef();
fx.density = 0.0f;
fx.shape = P;
fx.restitution = 0.5f;
Body b = PhysicsWorld.CreateBody(bf);
b.CreateFixture(fx);
BodiesCount++;
}
Because I need to create them dynamically in runtime with unknown quantity. And the result looks like this: https://www.dropbox.com/s/due3u98gd83gxwp/sol.JPG
What am I wrong?