BGE Python issue with an Object Actuator

I’m trying to contol an ObjetActuator ReplaceMesh through a python controller
in order to dynamicaly changes some shapes while game is running …

Here’s my scene config:

File1.blend: Scene1 : some meshes
File2.blend: Scene2: the scene in which I want to use the mesh

I want to append/link (relative path) the scene Scene1 into Scene2 and be able to use the mesh from Scene1

To do so:
In File2.blend, I append/link the scene Scene1 from File1.blend
and on the object I want to change the the shape of, I put a Python controller with the following code in it:

cont = GameLogic.getCurrentController()
actu = cont.getActuator("SetMesh")
actu.setMesh("the_name_of_the_new_mesh")
GameLogic.addActiveActuator(actu, True)

I manage to get it working if:

  • the objects (containing meshes) from File1.blend are basically appended into File2.blend
  • the objects (containing meshes) from File1.blend are linked into File2.blend

but I fail to get it working if I append/link the scene Scene1 from File1.blend into File2.blend.

What’s most surprising is that the replaceMesh actuator works fine if I use a basic AND controller instead of a Python Controller (even when the whole Scene1 is linked into File2.blend).

Does anyone have a clue ?

It could be because the obect is on a hidden layer. I know I complained about objects on hidden layers not being visible to getObjectList() of the scene object. Anyway, try


scene = GameLogic.getCurrentScene()
obj = scene.getObjectList()["OBobjectName"] 

See if it can find the object you appended. If it can’t, try putting it on layer 1.