In my game I have multiple actors called reqjecs that move towards an actor called the requester that is located at the center of the screen.
I do this by applying force towards the requester on all the objects on every frame. This simulates a center point gravity:
However in my new version I want the reqjecs to move in a spiral motion (circling) towards the requester. How can I achieve this?
I do this by applying force towards the requester on all the objects on every frame. This simulates a center point gravity:
Code: Select all
public function forceTowardsRequester()
{
for each(var actor:Actor in reqjecActors)
{
var a:Number = requesterActor.body.GetPosition().x - actor.body.GetPosition().x;
var b:Number = requesterActor.body.GetPosition().y - actor.body.GetPosition().y;
var c:Number = Math.sqrt(Math.pow(a, 2)+Math.pow(b, 2));
var c2:Number = c / reqjecSpeed;
var aa = a / c2;
var bb = b / c2;
var point:b2Vec2 = new b2Vec2(actor.body.GetPosition().x, actor.body.GetPosition().y);
var force:b2Vec2 = new b2Vec2(aa, bb);
actor.body.ApplyForce(force, point);
}
}However in my new version I want the reqjecs to move in a spiral motion (circling) towards the requester. How can I achieve this?