using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ZombieSpawnScript : MonoBehaviour
{
private bool xPositive, yPositive;
private float xClosestBorder, xFarthestBorder;
private float yClosestBorder, yFarthestBorder;
[SerializeField] private float closestSpawn, farthestSpawn;
[SerializeField] private GameObject zombiePrefab;
private void Start()
{
StartCoroutine(SpawnZombie(1, 2));
}
private IEnumerator SpawnZombie(int amount, float period)
{
while(true)
{
private float spawnPointX = Random.Range(-1f, 1f);
private float spawnPointY = Random.Range(-1f, 1f);
if(spawnPointX > 0)
{
xPositive = true;
} else if(spawnPointX < 0)
{
xPositive = false;
}
if(spawnPointY > 0)
{
yPositive = true;
} else if(spawnPointY < 0)
{
yPositive = false;
}
if(xPositive)
{
xClosestBorder = closestSpawn;
xFarthestBorder = farthestSpawn;
} else
{
xClosestBorder = -closestSpawn;
xFarthestBorder = -farthestSpawn;
}
if(yPositive)
{
yClosestBorder = closestSpawn;
yFarthestBorder = farthestSpawn;
} else
{
yClosestBorder = -closestSpawn;
yFarthestBorder = -farthestSpawn;
}
for(int i = 0; i < amount; i ++)
{
Instantiate(zombiePrefab, new Vector3(Random.Range(xClosestBorder, xFarthestBorder), 0.5f, Random.Range(yClosestBorder, yFarthestBorder)));
}
yield return new WaitForSeconds(period);
}
}
}
So I’m getting tons of errors regarding different things like “Invalid tokens” (for operators and assignment equal symbols), paranthesis and brackets needing a closing part, missing semicolons, and invalid expressions such as “else”. Does anyone know how to deal with this? Or have I missed something?