Answer the question
In order to leave comments, you need to log in
What is wrong with C# script?
I have two scripts to generate
mazespawner maze
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class mazespawner : MonoBehaviour
{
public GameObject CellPrefab;
void Start()
{
mazegenerator generator = new mazegenerator();
mazegeneratorcell[,] maze = generator.generatemaze();
for (int x = 0; x < maze.GetLength(0); x++)
{
for (int y = 0; y < maze.GetLength(1); y++)
{
Instantiate(CellPrefab, new Vector2(x, y), Quaternion.identity);
}
}
}
}
using UnityEngine;
public class mazegeneratorcell
{
public int Y;
public int X;
public bool WallLeft = true;
public bool WallBottom = true;
}
public class mazegenerator
{
public int Width = 50;
public int Height = 50;
public mazegeneratorcell[,] generatemaze()
{
mazegeneratorcell[,] maze = new mazegeneratorcell[Width, Height];
for (int x = 0; x < maze.GetLength(0); x++)
{
for (int y = 0; y < maze.GetLength(1); y++)
{
maze[x, y] = new mazegeneratorcell(X = x, Y = y);
}
}
return maze;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question