AI Shooter

I need a script that makes a character (No animation, like it was a simple cube) to be in some waypoints (I dont how to make waypoints) and in a certain distance of my player, shoot at me at a certain speed.
Please, Im a noob, can someone tell me what to do and give the scrip???

I’m not going to give you a script, but I’ll give you some ideas that you can research and learn about:

  1. Waypoints can be stored in a List or Array. A waypoint is basically a position, you can have a list or array of Vector3 structs to keep track of the position.
  2. A good way to move an object between waypoints is the Vector3.Lerp function. This will move the object from one position to another over time.
  3. You can use Vector3.Distance to calculate the distance between two positions (e.g. your player and one of the objects)
  4. If that distance is below a certain value then start shooting, but let’s save that part for later - get things moving first, then maybe come back and ask for advice on the shooting part.

Start small. Get a cube on the screen, create two variables with two different positions, and get the cube moving between them using Lerp. Those two variables are basically your waypoints.

To shoot, you would need to do this,

var target : Transform;
   var distance : float;
function Update () {
	target = GameObject.FindWithTag("Player").transform;
    if(target){
    var dist = Vector3.Distance(target.position, transform.position);
             if(dist >= distance){
                    //Your shoot script here.
                       }
                    }
                 }

Set target as your target you want to shoot, and distance to how close you have to be until you shoot.