Flash 8 AS2
Hey, what i am trying to do is get a movieclip head towards another movieclip when it hitTests with a certain radius (have a movieclip for radius) and this is my code
50% of it works, although when aproaching one mc from the other side it rejects it instead of heading towards the mc
function ai1() {
var _s1:Number = enemy_mc._x-hero_mc._x;
var _s2:Number = enemy_mc._y-hero_mc._y;
var _k:Number = _s1/_s2;
var _speed:Number = 5;
enemy_mc.onEnterFrame = function():Void {
if (_root.enemy_mc.radius.hitTest(_root.hero_mc.heroh)) {
this._x += _speed;
this._y += _speed/_k;
}
};
}