URGENTLY!
Someone help, i made 2d runner game, spawner isn’t working. I used 3 spawn variants, but new objects spawns wisout components, i need this project tomorrow . Help please
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spawner : MonoBehaviour
{
public GameObject[] EnemyVariants;
private float timeBtwSpawn;
public float startTimeBtwSpawn;
public float decreaseTime;
public float minTime = 0.65f;
private void Update()
{
timeBtwSpawn -= Time.deltaTime;
if (timeBtwSpawn <= 0)
{
int rand = Random.Range(0, EnemyVariants.Length);
Instantiate(EnemyVariants[rand], transform.position, Quaternion.identity);
timeBtwSpawn = startTimeBtwSpawn;
if (startTimeBtwSpawn > minTime)
{
startTimeBtwSpawn -= decreaseTime;
}
else
{
timeBtwSpawn -= Time.deltaTime;
}
}
}
}