[Solved]Single gravity point at the center of the screen

In a project I'm working on there are Actors called Reqjecs. These Reqjecs should always move towards the center of the screen. When they get there they will be destroyed. The Avatar however should not be effected by this gravity. Al tough he should be able to bounce the Reqjecs away. Eventually these Reqjecs should always continue their journey towards the center of the screen.

My question is: what's the best way create a central gravity point that only effects the Reqjecs?
Box2D has no standard for radial gravity. Leave Box2D's default gravity vector at zero. Loop through all the Reqjecs before each Step and manually apply the appropriate radial gravitational force.

Be aware that the ApplyForce function does not allow you to change the force in the middle of the timestep. The force you specify at the beginning of the timestep will be used until the end of the timestep. This could cause problems, particularly with modeling satellites, or slingshot behavior which involves rapid changes in the gravitational force as two bodies move closer and further apart. I don't know of any solution, aside from sidestepping the problem by applying a maximum cap on the magnitude of the force and destroying objects that get too close to the center, as you already said.
Use ApplyForce on them. That's what it's there for.
Gravity strength is usually Math.pow(distance,-2), in the direction of the center, but for your game you might want something more... balanced. So play with different forces pushing stuff towards the center.
Thanks for your advice... I have it up and running. 🙂
Code:
ApplyForce(force:b2Vec2, point:b2Vec2):void;

force - here I modified the code that I used for my old LinearVelocity version. I'm not happy with the results yet but at least it's working. I guess this part will require some tweaking. The main problem I'm experiencing is that, sometimes, the bodies (reqjecs) never seem to reach the center of the screen (after I hit them with the Avatar) and keep circling around it.

Question: any simple solution to this problem?

point - If I'm correct than this is the center of the body (Reqjec) that I'm applying this force on.

/edit: Here's the code I'm currently using (I'm currently testing with only one Reqjec):
Code:
         if ( reqjecBody )
         {
            var a:Number = requesterBody.GetPosition().x - reqjecBody.GetPosition().x;
            var b:Number = requesterBody.GetPosition().y - reqjecBody.GetPosition().y;
            var c:Number = Math.sqrt(Math.pow(a, 2)+Math.pow(b, 2));
            
              var d:Number = c / reqjecSpeed;
            var aa = a / d;
            var bb = b / d;
            
            var point:b2Vec2 = new b2Vec2(reqjecBody.GetPosition().x, reqjecBody.GetPosition().y);
            var force:b2Vec2 = new b2Vec2(aa, bb);
            
            reqjecBody.ApplyForce(force, point);
         }
Looks good. Things will tend to circle with gravity, they call this orbiting 😉 . Just put in some damping and everything will eventually fall into the center.
Thanks a lot again... with linearDamping it's really working the way that I imagined it. 😀

Original thread: https://box2d.org/forum/viewtopic.php?t=1844