I am trying to make some mc's follow another one which is static. I've always got this fine but for some reason the mcs don't follow a straight line or do not aim at the mc correctly :s . I really don't get what's going on and in the game I'm working on it is needed that they follow a straight line.
Here's an example for you to see:
http://www.giddelcreations.com/other...y_test_f8.html
The blue ones follow the mc by determining the distance in _x and _y in every frame, like this:
The red ones do something like that but instead of determining the distance on every frame they do it only once and the move at the same speed. These are the less accurate.Code:xq = 0.004*(_root.dude._x - _x); yq = 0.004*(_root.dude._y - _y); _x += xq; _y += yq;
The gray ones determine the angle of the mc in every frame and then follow it. Code goes like this:
Thanks so much for any help!Code:var c:Number = 0; var xs:Number; var ys:Number; var mul:Number = Math.PI / 180; onEnterFrame = function () { xq = _root.dude._x - _x; yq = _root.dude._y - _y; rot = Math.atan2(yq, xq) * 180/Math.PI; xs = Math.cos(rot * mul) * 0.7; ys = Math.sin(rot * mul) * 0.7; _x += xs; _y += ys; (...)
You can download the source here: http://www.giddelcreations.com/other...ay_test_f8.fla



This is MC. His _parents sent him to stop() by the super market to buy some _root beer if he wanted to gotoAndPlay() with his friends at the park later.
Reply With Quote