Need some help with AI

So im making this top-down-view shooter. The player is a sphere, and moves around with AWSD buttons, and shoots in what ever direction the mouse is located on the screen.
The problem im having is that I want to make enemies (Squares) stand still on the map, and when I get close enough they start following me, and ofcourse shoot.
I allready have a script that does this, but it has some bugs, and I want to start from scratch.

I need some help to be able to do this:

  1. Enemy stand still until player get close enough, then they follow and shoot.

  2. Enemies follow player, but at the same time keeps a distance from the player. So the enemy never crash into the player.

  3. Would love a script that can make enemies shoot in both burst, single shot, and random.

  4. Want to be able to duplicate enemies to make more of them fast and easy (When I do this now, for some reason they all shoot at the same time.)

The most important thing I need help with is the enemy follow player thing, and still keep distance and maybe circle around the player at that distance, while firing at the player.

This YouTube video actually show JUST what I need:

Thats more or less the same game im making :slight_smile:

Been looking all over the net for help to do this, dont know much scripting. Please someone help me :slight_smile:

There is a useful AI script in the 3d version of the Lerpz game, where the cop robots follow Lerpz.

in the AI, you will see an attack distance, it will even show an interactive sphere of when the robot chases you, and another for the hit attack distance, which I disable.

With some finessing of the AI, and finessing of the settings, you can get some nice interaction.

I can post more specifics if needed when at my studio.

Daev

pls do :slight_smile: thx

For the AI, download the 3d Platform Game here and install it on your system. This is a non-iphone game but the AI will work anywhere.

In the 3DPlatformer project you will look under

/Assets/Scripts/Enemies for EnemyPoliceGuy.js which is simply an AI script.

You can change lots of things such as Attack Distance and different speeds, as well as pause speeds between attacks and make your baddies fast or slow. When you attach this to a bad guy you will see the area in red, that indicates the attack zone that your player enters.

You may have to add other things to your character if you want them to shoot at your player however.

For information on how to do that I’ll point you to youtube/tornadotwins

Their step by step tutorials are great and very useful for shooter type games.

I’ll attach the original script below, but you should check out the Unity demo for the 3d Platform Game, and the tutorials that go with it for more info, good stuff.

-Daev

382341–13199–$enemypoliceguy_427.js (6.15 KB)