Hi, I am writing my own little engine that sorts and manages my game content for me.
Its built up of functions and arrays that allow me to add up to 50 models (I can change the number) etc.
For some odd reason when I run the program (with my test program to test the engine) it seems as though the model doesn't load. Can any one help?
The error message is: "Object reference not set to an instance of an object."
Here is the AddModel() code in my engine:
public int AddModel(string _address)
{
if (_modelindex != MODEL_LIMIT)
{
string new_address = "\\..\\" + _address;
_models[_modelindex] = content.Load<Model>(new_address);
_modelindex++;
return (_modelindex - 1);
}
else
{
return -1;
}
}
The code is red is the line that the error is linked to. As the link to the file is back one file I need to add the "file://..//" to it. I have tried most combinations.
Here is where I initialise the model array:
public Model[ _models = new Model[MODEL_LIMIT];
And MODEL_LIMIT is 50 (static).
And when I add the model in my game here it is:
car = g.AddModel("Objects\\tank");
Now this above, car is an integer that g.addmodel returns to which will allow the user to link straight to the model if they wish to do something with it.
Can anyone help?
Cheers!