MC follow another MC, PERFECTLY!
Hi, it's been ages since I've been here. Hope to get some answers, as this was the first flash forum I got to know when starting with Flash :)
So I've like searched the WHOLE internet (just kidding) to find the solution to my problem. Due to the disappointment, I've been led to ask this question myself.
So, I have this Movieclip with these movements:
Actionscript Code:
onClipEvent(enterFrame){
if(Key.isDown(Key.LEFT)){
this._x -= speed;
this._rotation = 0;
_root.axe_mc._rotation = 0;
} if(Key.isDown(Key.RIGHT)){
this._x += speed;
this._rotation = 180;
_root.axe_mc._rotation = 180;
} if(Key.isDown(Key.DOWN)){
this._y += speed;
this._rotation = 270;
_root.axe_mc._rotation = 270;
} if(Key.isDown(Key.UP)){
this._y -= speed;
this._rotation = 90;
_root.axe_mc._rotation = 90;
}
And on the walls (this is only for the Right-side wall):
Actionscript Code:
onClipEvent(enterFrame){
if(this.hitTest(_root.hero)){
_root.hero._x += 5;
}
}
I want the hero movieclip to change into different costumes, but if I do that, it will also affect the Walls. If I make a costume, LARGER than the movieclip, or even smaller than, the hero movieclip won't be able to move as freely... You get it, right?
In order to prevent this, I made another movieclip, and will make the costumes there. On this movieclip, I have put this code:
Actionscript Code:
onClipEvent(enterFrame){
this._x = _root.hero._x;
this._y = _root.hero._y;
}
Working good, but the only problem is, this costume movieclip's _x and _y aren't 100% following hero's _x and _y. I know of updateAfterEvent(); but that doesn't work. According to myself, updateAfterEvent(); only works when using onMouseMove, true?
Anyways, how to make the costume movieclip follow the hero movieclip, SMOOTHLY and PERFECTLY? Because, this follow mc script is ruining the Wall hittest ;(
Thanks in Advance :D