I need help with a problem I get in my code. I am writing a code to generate a maze using Prim’s Algorithm. This is the code I get the error on: `function SetAdjacents()
{
var x : int;
var y : int;
for(x = 0; x < size.x; x++)
{
for(y = 0; y < size.y; y++)
{
var cell : Transform;
cell = grid[x,y];
var cScript : CellScript = cell.GetComponent(CellScript);
if(x - 1 >= 0)
{
cScript.adjacents.Add(grid[x-1,y]);
}
if(x + 1 < size.x)
{
cScript.adjacents.Add(grid[x+1,y]);
}
if(y - 1 >= 0)
{
cScript.adjacents.Add(grid[x,y-1]);
}
if(y + 1 < size.y)
{
cScript.adjacents.Add(grid[x,y+1]);
}
}
}
}`
I get the error on all the lines of codes that say cScript.adjacents.Add(etc.) The cScript that I take the variable adjacents is here:
#pragma strict
var adjacents : Transform[];
var position : Vector2;
var weightCell : int;
function Start () {
}
function Update () {
}
I haven’t done much with the second script.
Thanks for your help!