I’m pretty new to Unity and game dev in general, but this problem genuinely makes no sense to me, where as all other problems I’ve encountered so far I’ve been able to solve on my own.
When in the unity editor, I get this error message:
Assets\Scripts\LevelGen\LevelGeneration.cs(90,45): error CS1513: } expected
Here’s my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LevelGeneration : MonoBehaviour
{
public Transform[] startingPositions;
public GameObject[] rooms; // index 0 = LR, index 1 = LRB, index 2 = LRT, index 3 = LRBT
private int direction;
public float moveAmount;
private float timeBtwRoom;
public float startTimeBtwRoom = 0.25f;
public float minX;
public float maxX;
public float minY;
private bool stopGeneration;
private void Start()
{
int randStartingPos = Random.Range(0, startingPositions.Length);
transform.position = startingPositions[randStartingPos].position;
Instantiate(rooms[0], transform.position, Quaternion.identity);
direction = Random.Range(1, 6);
}
private void Update()
{
if (timeBtwRoom <= 0 && stopGeneration == false)
{
Move();
timeBtwRoom = startTimeBtwRoom;
}
else
{
timeBtwRoom -= Time.deltaTime;
}
}
private void Move()
{
if (direction == 1 || direction == 2) // move right
{
if (transform.position.x < maxX)
{
Vector2 newPos = new Vector2(transform.position.x + moveAmount, transform.position.y);
transform.position = newPos;
int rand = Random.Range(0, rooms.Length);
Instantiate(rooms[rand], transform.position, Quaternion.identity);
direction = Random.Range(1, 6);
}
else
{
direction = 5;
if (direction == 3)
{
direction = 2;
} else if (direction == 4)
{
direction = 5;
}
}
} else if (direction == 3 || direction == 4) // move left
{
if (transform.position.x > minX)
{
Vector2 newPos = new Vector2(transform.position.x - moveAmount, transform.position.y);
transform.position = newPos;
direction = Random.Range(3, 6);
}
else
{
direction = 5;
}
}
else if (direction == 5) // move down
{
if (transform.position.y > minY)
{
Vector2 newPos = new Vector2(transform.position.x, transform.position.y - moveAmount);
transform.position = newPos;
in rand = Random.Range(2, 4);
Instantiate(rooms[rand], transform.position, Quaternion.identity);
direction = Random.Range(1, 6);
}
else
{
// stop generation
stopGeneration = true;
}
}
Instantiate(rooms[0], transform.position, Quaternion.identity);
}
}
I can’t figure out what the issue is, and in visual studio it tells me that there are “no errors found.”
Anybody know what the problem is?