I need an overlay HUD scene to get a mesh from the main scene for mesh replacement. So far I have the code that makes the HUD get the main scene, and I can easily get objects from other scenes this way.
This is what I have:
from bge import logic
cont = logic.getCurrentController()
obj = cont.owner
scenes = logic.getSceneList()
for i in scenes:
if i.name == "main":
main = i
spawn = main.objects["spawn"]
item = spawn['item']
###this is where I'm stuck
if item == "crate":
r = main.meshes["cratemesh"]
#or something like
r = main.objects["crate"].mesh
You may have to link the object (and mesh) across scenes - I’m not sure if an object in one scene can access a mesh from another.
I had them linked across scenes earlier which worked alright, I just thought it would be easier to have it access the original mesh from the main scene.
[EDIT1]: I found this http://www.blender.org/documentation/250PythonDoc/bge.types.html#bge.types.KX_GameObject.meshes
But I’m not too familiar with the bge.types module, and I’m not even sure if this would do any good for what I need.
Unfortunately, that may not work because the replaceMesh function works with mesh names, not a direction to the object’s mesh data itself. You can just use the name of the mesh: