Hi,
I try to use the Box2dFlash 2.1a b2Controllers for the following scenario:
In my world, I have two types of physical objects (which are b2bodies with a b2circleShape) - "ParentCircles" and "ChildCircles". They are arranged randomly in a 0 gravity world.
Now, I want ParentCircles to attract their ChildCircles, so that ChildCircles arrange around the ParentCircles. To create attractive forces between ParentCircles and ChildCircles, I attach a b2GravityController to the world for each ChildCircle:
This does obviously not what I want. The circles do move around, but they don't seem to attract. I wonder if I misunderstand the b2GravityController or the use of b2Controllers in general.
- Do I have to call gravityController.Step(WHATGOESHERE); at each world step?
Thanks for your help,
M
I try to use the Box2dFlash 2.1a b2Controllers for the following scenario:
In my world, I have two types of physical objects (which are b2bodies with a b2circleShape) - "ParentCircles" and "ChildCircles". They are arranged randomly in a 0 gravity world.
Now, I want ParentCircles to attract their ChildCircles, so that ChildCircles arrange around the ParentCircles. To create attractive forces between ParentCircles and ChildCircles, I attach a b2GravityController to the world for each ChildCircle:
Code:
for each (var childCircle:ChildCircle in allChildCircles) {
//create controller:
var controller:b2Controller = world.AddController(new b2GravityController());
var gravityController:b2GravityController = controller as b2GravityController;
// set gravity:
gravityController.G = 50;
//add the bodies that should attract each other
gravityController.AddBody(childCircle.body);
gravityController.AddBody(parentCircle.body);
}
//create controller:
var controller:b2Controller = world.AddController(new b2GravityController());
var gravityController:b2GravityController = controller as b2GravityController;
// set gravity:
gravityController.G = 50;
//add the bodies that should attract each other
gravityController.AddBody(childCircle.body);
gravityController.AddBody(parentCircle.body);
}
This does obviously not what I want. The circles do move around, but they don't seem to attract. I wonder if I misunderstand the b2GravityController or the use of b2Controllers in general.
- Do I have to call gravityController.Step(WHATGOESHERE); at each world step?
Thanks for your help,
M