generating objects dinamically

hello people!
sorry if i post a lot but i’m still a newbie to panda.

I’m trying to do a an RTS and my big question of today is:

How can i generate dinamically objects like i create units in an RTS game?

I thought that using a list would be good but i don’t know how to do :smiley:
thanks for your help!
snizzo

first you create a class Unit to load your model, for instance, then use a list:

object = {}
for i in range(0,10):
     object[i] = Unit()

As of a few versions back, loading a model more than once keeps a single master geometry instance under the hood (or so says the API), so you can just load/copy a fresh model and add it to the scenegraph whenever you need more units. Just be aware that Panda will keep track of anything attached to the scenegraph regardless of whether or not you do, so if you want to remove a unit, you’ll need to explicitly remove() its nodepath before ditching your instance variable.