Looking for some keen eyes to help me locate this issue. I have three symbol errors which I can’t seem to located, and it’s been two days, a bit of hair pulling and a bit too much coffee.
Assets/Scripts/EnemySpawner.cs(86,32): error CS1525: Unexpected symbol `(', expecting `,', `;', or `='
Assets/Scripts/EnemySpawner.cs(93,18): error CS1519: Unexpected symbol `return' in class, struct, or
interface member declaration
Assets/Scripts/EnemySpawner.cs(95,4): error CS1525: Unexpected symbol `}'
These are within the Update block, being the updates ‘}’ and two errors on the last block. It’s refering to the "return true; " and Transform " All EnemiesDead() { "
System.Collections;
using System.Collections.Generic;
using UnityEngine;
class EnemySpawner : MonoBehaviour {
public GameObject enemyPrefab;
public float width = 10f;
public float height = 5f;
private bool movingRight = false;
private bool movingLeft = false;
public float speed = 3f;
public float spawnDelay = 0.5f;
private float xmax;
private float xmin;
private float ymax;
private float ymin;
// Use this for initialization
void Start() {
float distanceToCamera = transform.position.z - Camera.main.transform.position.z;
Vector3 leftBoundary = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, distanceToCamera));
Vector3 rightBoundary = Camera.main.ViewportToWorldPoint(new Vector3(1, 0, distanceToCamera));
Vector3 upBoundary = Camera.main.ViewportToWorldPoint(new Vector3(0, 1, distanceToCamera));
Vector3 bottomBoundary = Camera.main.ViewportToWorldPoint(new Vector3(1, 1, distanceToCamera));
xmax = rightBoundary.x;
xmin = leftBoundary.x;
ymax = upBoundary.y;
ymin = bottomBoundary.y;
SpawnUntilFull();
}
void SpawnEnemies() {
foreach (Transform child in transform) {
GameObject enemy = Instantiate(enemyPrefab, child.transform.position, Quaternion.identity) as GameObject;
enemy.transform.parent = freePosition;
}
}
void SpawnUntilFull() {
Transform freePosition = NextFreePosition();
if (freePosition) {
GameObject enemy = Instantiate(enemyPrefab, freePosition.position, Quaternion.identity) as GameObject;
enemy.transform.parent = freePosition;
}
if (NextFreePosition()) {
Invoke("SpawnUntilFull", spawnDelay);
}
}
public void OnDrawGizmos() {
Gizmos.DrawWireCube(transform.position, new Vector3(width, height));
}
// Update is called once per frame
void Update() {
if (movingRight) {
transform.position += Vector3.right * speed * Time.deltaTime;
} else {
transform.position += Vector3.left * speed * Time.deltaTime;
}
float rightEdgeOfFormation = transform.position.x + (0.5f * width);
float leftEdgeOfFormation = transform.position.x + (-0.5f * width);
if (leftEdgeOfFormation < xmin) {
movingRight = true;
}
else if (rightEdgeOfFormation > xmax) {
movingRight = false;
}
if (AllMembersDead()) {
SpawnUntilFull();
}
Transform(NextFreePosition()); {
foreach (Transform childPositionGameObject in transform) {
if (childPositionGameObject.childCount == 0) {
return childPositionGameObject;
}
}
return null;
}
Transform AllEnemiesDead() {
foreach (Transform childPositionGameObject in transform) {
if (childPositionGameObject.childCount > 0) {
return false;
}
}
return true;
}
}
}