I'm adding an object to my scene using bge.logic.getCurrentScene().addObject("Object Name"). But the object I want to add is linked from another file and the scene it's being added to is linked to a .blend controlling everything. Due to that I'm getting an ValueError saying that the requested name "ObjectName" did not match any KX_GameObject in this scene.

So how can I add the object from the other file or is there another way around it? I also uploaded a .zip containing 3 .blends: a library containing the group, a level (the group from the library is linked to it) and the main control .blend controlling everything. The level scene is linked to it. Here's the link.

I just reproduced a working example with two files, see the sceenshot below:

The left file is the library, containing an object "Suzi" which is part of the group "grpSuzi". I set up some simple rigid body physics here.

The right file is the "game", containing an empty named "spawn" which has the logic attached as seen in the screenshot. I added the "grpSuzi" on Layer two in this file. It made no difference whether I wrote "Suzi" or "grpSuzi" in the addObject() call. Once I pressed "P" in the game file (right) and the spacebar, the mesh appeared (twice).

But once I misspelled the name like "Suz", I ended up with the error you described. Are you sure there is no typo?!

• The name of the object is saved in a file and loaded in back again at another time so there's no chance of it being a typo. The object with the name given in the error also exists as a linked object so it can't be saved wrong. – palkonimo Jul 21 '16 at 16:15
• Hmm - hard to guess what could be wrong otherwise. Can't you provide a stripped down example *.blend showing the issue? You can upload them here easily: blend-exchange.giantcowfilms.com/?ref=be-community-add-2 – AeroLynx Jul 21 '16 at 17:47
• Ok, forgot to mention that the scene the object is being added to is also linked to a file controlling everything. I edited the main post now – palkonimo Jul 21 '16 at 18:16
• Ok, I looked at your *.blends and now roughly get what you are talking about. Maybe this post helps? blender.stackexchange.com/questions/51567/… I have no solution at hand for this and am not sure if there is one. – AeroLynx Jul 21 '16 at 18:42
• Ok, I fixed it by only sending a message from the main control scene to the linked scene and adding the object there, works perfectly now. So it's basically just doing what you did in your answer. I don't really know what the issue was. Maybe scene.addObject() adds objects from the scene it's called in even though the scene the object is being added to is a different one. Thanks :) – palkonimo Jul 21 '16 at 23:10