I think I’ve come pretty far, but whats going on here I can’t figure out by my own:
I’m using multiple blend files for enemies and stuff which I link into the main level blend file via groups.
As I understand it blender creates empties and uses dupli groups to “link” to the one in the other blend file.
So there are multiple named empties “Enemy.001”, “Enemy.002” and so on and one invisible linked original “Enemy”.
But what happens exactly on game engine initilisation? Are the emties replaced by newly created duplicates
of “Enemy”? Or are they still there? (At least I can access them via ‘groupObject’) On what does the python code operate when I write “cont.owner.xyz()”? What do I get if I access scene[‘Enemy.001’]? Is there any documantation on this? Or tools which I can use to get better insight?
I’m constantly stumbling on stuff which isn’t working as I would expect it but although on stuff which works which I wouldn’t expect to. So knowing how this is internally done would help me a lot to continue from there on.
Instantiating acts the same way as AddObject. The group objects are added while inheriting the transformation from the instantiating object. The group object will preserve their relative relationship to the group center.
No they do not replace the instantiating object. Beside the python properties there is no further relationship between instantiating object and instance members.
depends on what cont contains ;).
I guess you mean the current controller (SCA_IController). Obviously SCA_IController.owner is the game object that owns the controller.
This is invalid code. There is no index on scene.
I think you mean KX_Scene.objects[ key ] where key is an object name.
You can get both, the instantiating object or any instantiated object. Be aware names are not unique. This search method gives you ANY object with the given name, without any error or warning. So I recommend to avoid it. Better search through all objects looking for multiple objects with the same name.
I do not think so. But you can use the Analyzer to inspect your scene.
So after linking - lets say 100 - instances of “Brick” (it’s a Jump’n’Run) I finally end up with 200 objects: 100 Empties named “Brick.001…100” and 100 copies all named “Brick” all with their own controllers and so on? But this explains why parenting did never worked the way I expected it to.
So in my game initalization I could delete all these groupObjects and free some resources?
Ok. That names aren’t unique is valuable info, too. Indeed I didn’t expext this. So I assume they aren’t stored in a map (like I expected) but a list with some fancy accessor method.
Yeah. Been there a lot but didn’t find anything regarding initialisation. Am I holding it wrong?
Thanks. This is a nice starting point and I can extend it to show me more stuff I’m interessted in.
One additional question: using ‘groupObject’ I can get from a linked object to it’s instantiating object. Is there the other way, too?
There seems to be at least one additional implicit connection between an object and its ‘groupObject’.
If you use the ‘groupObject’ in newObj = scene.addObject( ‘GroupObjectName’, someobject ) this will not only create a new empty but although its ‘groupMembers’. This can be a little irritating if you try to animate the ‘newObj’. (I guess this is what I mean that some things work which i expect not to but others don’t which I expect to work…)
Regards & thanks again.
I just found your guide to linking Libraries. Perhaps you could update it to reflect this stuff. Currently it says: “Pivot objects do not know the instance objects they added”