- Home /
Noob Question, Object reference
I have the following very basic code, and I just can't seem to figure out what's going wrong. No matter what I change I get the error "An object reference is required to access a non-static member".
public Battalion battalion;
void Update()
{
Battalion newBattalion = Instantiate(battalion) as Battalion;
UnitCare.addBattalion(newBattalion);
}
Where addBattalion is a very simple:
public void addBattalion(Battalion battalion)
{
battalionList.Add(battalion);
}
$$anonymous$$aybe store as Object to Object newBattalion and then cast it when you add it to your list? :/
Answer by DryTear · Feb 03, 2013 at 04:04 AM
I think you should replace battalion(noCapitals) with GameObject
Your answer
Follow this Question
Related Questions
Passing information error 0 Answers
Is a unity object really destroyed if its destructor was never called? 1 Answer
Scriptable object saves but what about objects it references? 0 Answers
Do you have to set a object reference for every script? 0 Answers
Object Reference Not Set to an Instance of an object 0 Answers