My idea is a 2D game where the player has a base in the center and enemies spawn in one of 10 spawn points and then move towards the middle. I wrote this code but there is an error. Can someone help??
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemySpawn : MonoBehaviour
{
private float spawnRate = 2f;
private float timer = 0f;
public GameObject enemy;
public int spawnerNumber;
public GameObject[] spawner;
void Update()
{
timer += Time.deltaTime;
if(timer > spawnRate)
{
timer = 0f;
Spawn();
if(spawnRate > 0.1f)
{
spawnRate -= 0.01f;
}
}
}
void Spawn()
{
spawnerNumber = Random.Range(0, 10);
Instantiate(enemy, new Vector3(spawner[spawnerNumber].transform.position), Quaternion.identity);
}
}
The error it gives me is:vector 3
does not contain a constructor that takes in 1 arguments