The simpliest AI you can make.


I’m almost sure this is absolutely to simpliest AI you can make in a flash game using AS 2.0. Anyway, it’s extremely simple, and I don’t recommend you to use it, because it seriously isn’t any good. Eitherway, as you know, I like to say that you shouldn’t just copy/paste, and that’s true, you really shouldn’t.

STEP 1:

You should now make a character. Create a new MC and give it the instance name “hero”. If you want to know how to make it controllable, check out my tutorial for that.

STEP 2:

Now you need an “enemy” MC. Create one. It will use our simple AI code, that almost can’t be called AI, but it’s still a good start.


onClipEvent(load){ //When the MC have loaded
speed=5; //The speed of the enemy
}
onClipEvent (enterFrame) { //When you enter the frame, it will run the code over and over again.
if (_root.hero._x>_x) { //The enemy tries to identify to hero position
_x += speed; //It tries to get the player
}
if (_root.hero._x_y) {//The enemy tries to identify to hero position
_y += speed; //It tries to get the player
}
if (_root.hero._y<_y) { //The enemy tries to identify to hero position
_y -= speed; //It tries to get the player
}
}

So that was it, nothing really proffesional, but I will post another post where I will make a more advanced AI.

Advertisements
Explore posts in the same categories: ActionScript 2.0, Basic

Tags: , , ,

You can comment below, or link to this permanent URL from your own site.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: