Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- else {
- var r:MovieClip = MovieClip(parent);
- dist = Math.sqrt((target.y - y) * (target.y - y) + (target.x - x) * (target.x - x));
- var smod:int = dist/10;
- var xdif:int = (target.x - target.lx) * smod;
- var ydif:int = (target.y - target.ly) * smod;
- if (smod > target.eta) {
- var wp1:MovieClip = r.waypoints[target.c];
- var wp2:MovieClip = r.waypoints[target.c+1];
- var smod2:int = target.speed * (smod - target.eta);
- cx = wp2.x - wp1.x;
- cy = wp2.y - wp1.y;
- if (cx != 0) { cx = (cx > 0) ? wp1.x + (1 * smod2) : wp1.x + (-1 * smod2); }
- else { cx = wp2.x; }
- if (cy != 0) { cy = (cy > 0) ? wp1.y + (1 * smod2) : wp1.y + (-1 * smod2); }
- else { cy = wp2.y; }
- }
- else {
- cx = target.x+xdif;
- cy = target.y+ydif;
- }
- dist = Math.sqrt((cy - y) * (cy - y) + (cx - x) * (cx - x));
- speed = dist/smod;
- angle = Math.atan2(cy - y, cx - x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement