|
I've set up an array to manage the bullets in my game. I want the amount of bullets to be varied by Unity tells me that "An instance of type 'bulletManager' (which is the name of the script) is needed to access non-static type 'amountOfBullets'." How do I get the arrays to be the size that i want, based on 'amountOfBullets'?
(comments are locked)
|
|
Well you have a couple of options. You could make amountOfBullets static, but I'm assuming you want it to be editable in the inspector. Another option is to delay instantiating bullets/bulletScripts until the first time bulletManager is called. I.e. do something like this:
Probably a better option is to not make bullets and bulletScripts static and instead use the singleton pattern to access your bullets and bulletScripts variables. Thanks. I've had to look at singleton patterns to get my head around how they work. I'm a procedural programmer and I'm having a hard time unlearning it in exchange for OOP... I'll get there :)
Jun 16 '10 at 08:14 AM
Billamu
(comments are locked)
|
