Posted: Mon Oct 08, 2007 9:10 pm Post subject: Artificial Inteligence
Artificial intelligence means that one object will follow another. To make A.I. happen, first you need to make an object and convert it into a Movie Clip. Instance name it "player" without the quotes and paste this code:
That makes the Movie Clip move with the arrow keys.
Next make another Movie Clip. Open the actions panel and paste this code:
Code:
onClipEvent(load){
spd=10; //Set enemy speed
}
onClipEvent(enterFrame){
//Rotate enemy to face player
Xdiff=_parent.player._x-_x;
Ydiff=_parent.player._y-_y;
radAngle=Math.atan2(Ydiff,Xdiff);
_rotation=int((radAngle*360/(2*Math.PI))+90);
updateAfterEvent();
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum