- Home /
Question by
tekiro_devil · May 04, 2012 at 04:30 AM ·
nullreferenceexceptiondungeon
repeated nullreferenceexception errors
Trying to make a BSP dungeon, keep getting nullreferenceexceptions over and over again, when I fix one another pops up a few lines later. Can't figure this one out tho..
using UnityEngine; using System.Collections;
public class BSP_Dungeon
{
public BSP_Node root;
public BSP_Node[] leafNodes;
public BSP_Node[] oldNodes;
public void doSplits()
{
this.clearRooms(this.root);
this.oldNodes = this.leafNodes;
if(this.oldNodes == null)
this.oldNodes[0] = new BSP_Node(); //attempted fix...nothing is working ;_;
this.leafNodes = null;
for(int i=0; i < this.oldNodes.Length; i++) //original error figure its because of oldnodes is null but I try and put something in oldNodes ^^^^^^ and still throws exception...
{
BSP_Node n1 = new BSP_Node();
BSP_Node n2 = new BSP_Node();
n1.parent = this.oldNodes[i];
n2.parent = this.oldNodes[i];
n1.sister = n2;
n2.sister = n1;
int target = Random.Range(this.minSplit, this.maxSplit);
target = target / 100;
Point start = new Point(0,0);
Point end = new Point(0,0);
using UnityEngine;
using System.Collections;
public class BSP_Node
{
public BSP_Node currentNode;
public BSP_Node root;
public BSP_Node parent;
public BSP_Node sister;
public BSP_Node[] rightChild;
public BSP_Node[] leftChild;
public BSP_Node()
{
this.currentNode = null;
this.root = null;
this.parent = null;
this.sister = null;
}
}
I really can't figure this stuff out. Looked at probably 2 dozen of these error's threads and none seem to fit..most are easy fixes like check if it's null but I know it's null but not sure how to fix it..Any help appreciated
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613071056im_/https://answers.unity.com/themes/thub/images/avi.jpg)