Hello,
I'm a hobby game maker moving from C++ to Unity in an effort to get beyond stick-figure graphics. I've been having trouble figuring out how to 'copy' my old, very basic, programs, which I would like to do before moving on to scary new things. I'd be happy for any references to objects that behave 'like' the C++ things below - not much luck so far.
Normally, I would have some classes representing game objects (say a Penguin class and a Monkey class), all bundled into a small number of 'gamestate' objects that have pointers to everything represented on the screen. Throughout the game, Penguins and Monkeys would spawn and die and otherwise do their thing, but I would have one master list of pointers to all Penguins, and another list of pointers to all Elephants, which I could easily iterate through, find objects in (e.g. upon a mouseclick event), and otherwise act on. Without things like parameterized classes (to deal with Penguins and Monkeys in a unified way) or easy ways to save lists of pointers (to create the big list).
Maybe to make this slightly concrete, I'm interested in making a Monkey prefab, so that every monkey instantiation runs around picking up bananas independently (I don't care so much about the running around code). How could I find the particular monkey at a particular time so that (Number of Bananas)/(Distance to User) is maximized?
Thanks for your patience in reading through this. Any advice on how to ask questions here is also welcome - I've gone through some tutorial games, but none seem to be very helpful with these sorts of 'structural' questions.
Thanks! So, I can have this script floating unattached, then put a static MonkeySpawner attached to a GameObject and refer to that all over the place? In any case, it certainly looks the same. Accepting answer.
– anon19656182The script would still be attached to a gameobject - you'd just drag the entire prefab onto the prefab slot in the inspector and it'll act as if it were a monkey script with other stuff attached.
– anon85704231