Hey everyone. I have been working on the script for only a short time and I thought it was finished. (At least it would do what I wanted it to do. I would definitely add to it later.) However, I keep getting this runtime error. I don’t have a clue about fixing it. The error is at the highlighted line in the image. (Line 25)
Here is the code that I am using. I have provided an image of it as well as the text so you can test it if you want. Right click on the image and press “Open image in a new tab” to view the full size image.
private var yCoordinates : float[];
private var xCoordinates : float[];
private var yPos : float;
private var xPos : float;
private var exicutable : boolean = false;
var obj : GameObject;
var resolution : int = 10;
var xIncrement : float = 1;
var a : float = 1;
var b : float = 2;
var c : float = 3;
function Start(){
yPos = gameObject.transform.position.y;
xPos = gameObject.transform.position.x;
}
function Bake(){
Debug.Log("Exicuting function Bake()");
for(var i = 0; i <= resolution; i++){//Calculate all of the positions for the y axis
Debug.Log("Entering Bake() for loop.");
yCoordinates[i] = yPos;//a*(Mathf.Pow(xPos, 2.0)) + b*xPos + c
xCoordinates[i] = xPos;
xPos += xIncrement;
}
}
function Exicute(){
Debug.Log("Exicuting function Exicute()");
exicutable = true;
}
Oh and so you have an idea about what it is I’m trying to do, I have a cube at the origin with this script attatched to it. When the code “bakes”, it calculates the x and y positions of the cube if it were on a parabola with the number of coordinates it calculates limited to the “resolution” number. After baking, the code instantiates cubes at the positions previously calculated. If that isn’t clear let me know and I’ll make sure you understand. Thanks for any help.