hello! so i have this script to make the enemies spawn with a delay… and what i need is that every time an enemy spawns, it attacks the player with a projectile.
public class TimedSpawn : MonoBehaviour {
public GameObject spawnee;
public bool stopSpawning;
public float spawnTime;
public float spawnDelay;
// Use this for initialization
void Start () {
InvokeRepeating ("SpawnObject", spawnTime, spawnDelay);
}
public void SpawnObject (){
Instantiate (spawnee, transform.position, transform.rotation);
if (stopSpawning) {
CancelInvoke ("SpawnObject");
}
}
}
hi;
well when u instantiate them first thing they need is to find the player Transform;
so u can do it with :
GameObject.Find
or any other way !
then the player need to face that transform like :
transform.LookAt(player);
or any way u do it;
then u need to shoot the bullut or object for this u need to Instantiate it with this code:
Instantiate ( bullutObject);
your bullut should have a code attached to it to move forward and get to the player;
transform.Translate(Vector3.forward * MoveSpeed * Time.deltaTime);
these are some example steps i told u ;
u need to work on each step and make it ;
ask me any question u have;
good luck ;