Hello there, I’m stuck trying to change some code.
There was a declaration of a 2D array called drawPoints in a function which looked like this:
void DrawOrbits () {
CelestialBody[] bodies = FindObjectsOfType<CelestialBody> ();
var virtualBodies = new VirtualBody[bodies.Length];
var drawPoints = new Vector3[bodies.Length][];
int referenceFrameIndex = 0;
Vector3 referenceBodyInitialPosition = Vector3.zero;
// Initialize virtual bodies (don't want to move the actual bodies)
for (int i = 0; i < virtualBodies.Length; i++) {
virtualBodies _= new VirtualBody (bodies*);*_
drawPoints = new Vector3[numSteps];
}
I am trying to decompose the DrawOrbits() function in many functions, so I tried this in my class:
public int numSteps = 1000;
private CelestialBody[] bodies;
private VirtualBody[] virtualBodies;
private Vector3[][] drawPoints;
private int referenceFrameIndex = 0;
private Vector3 referenceBodyInitialPosition = Vector3.zero;
void Start() {
/* InitializeVirtualBodies() and drawPoints;*/
bodies = FindObjectsOfType();
virtualBodies = new VirtualBody[bodies.Length];
for (int i = 0; i < virtualBodies.Length; i++) {
virtualBodies = new VirtualBody(bodies*);*
drawPoints = new Vector3[numSteps];
if (bodies == centralBody && relativeToBody) {
referenceFrameIndex = i;
referenceBodyInitialPosition = virtualBodies*.position;*
}
}
And now I get this error: Assets\Scripts\Debug\OrbitDebugDisplay.cs(17,25): warning CS0649: Field ‘OrbitDebugDisplay.drawPoints’ is never assigned to, and will always have its default value null
I don’t get how to declare drawPoints correctly, the code seems to take it like it was 2 differents variables.
Thanks for your help!