Hello
I am writing a struct for Class Robot, which is consists of an array of RobotJoints. The RobotJoints class itself consists of a Game Object, two list of doubles, and an array of integer.
The code does not work because of NullReferenceException in the line ( this.robotJoints_.joinT = gO*; )!!!_
Please find the code here:
public class RobotJoints
_{*_
* public GameObject joinT = new GameObject ();*
* public List constraintsMin = new List();*
* public List constraintsMax = new List();*
* public int[] ActiveDoFs = new int[6];*
* public RobotJoints()*
* {*
* this.joinT = new GameObject ();*
* this.constraintsMin = new List();*
* this.constraintsMax = new List();*
* this.ActiveDoFs = new int[6];*
* }*
* public RobotJoints(GameObject gObj)*
* {*
* this.joinT = gObj;*
* this.constraintsMin = new List ();*
* this.constraintsMax = new List ();*
* this.ActiveDoFs = new int[6];*
* }*
}
public class Robot
{
* public RobotJoints[] robotJoints;*
* public Robot()*
* {*
* this.robotJoints = null;*
* }*
* public Robot(GameObject[] gO)*
* {*
* for(int i=0; i<(gO.Length);i++)*
* {*
this.robotJoints_.joinT = gO*;// There is something wrong here…
}
}
}*
and this is the error:
NullReferenceException: Object reference not set to an instance of an object
Any suggestion is greatly appreciated. Thanks_