Hello all,
I’m playing arround with the game engine and manage to do what I want exepcted this thing :
duplicating objects.
I plan to organise my scene with layers and my base objects and props will be duplicated from an original (on layer 11 for example)
Here is my code :
import Blender, bpy
from Blender import Mathutils
scene = Blender.Scene.getCurrent()
own = GameLogic.getCurrentController().owner
########################
#Spawn mob script...
try:
if own["monsters"]<3:
#localisation au hazard
posx = Mathutils.Rand(0, 2)
posy = Mathutils.Rand(0, 2)
#on cree une nouvelle instance de notre objet
mob = Blender.Object.New("Mesh","cedMob")
mob.link(bpy.data.meshes["MonsterMesh"])
#On le place dans la scene
mob.setLocation(posx, posy, 1) #toujours a la meme hauteur par contre
#attachement a la scene
scene.link(mob)
scene.update()
own["monsters"] = own["monsters"]+1
print "Nouveau cree"
else:
print "Stop! Deja trop de monstres ont ete crees."
except Exception, e:
print "Erreur" + str(e)
Sorry for the comments in french.
This works but the objects doesn’t display in realtime, but after the game ends…
Moreover, it’s a bad method, because it links a mesh to a new object, but in the future, it’ll be caracters and I need everything else, like bones and modifiers…
My second question is, how can I clone an object, not simply a mesh?
Many documentations are saying opposing ideaes and it’s confusing,
I’ve read there is a duplicate method for objects, but the only working example is the one I’m testing…
Can someone redirect me to a good reference? I don’t really get the one on blender.org, I can’t understand how it’s organized… in fact, a reference is good after reading a good guide, that’s what I’m missing.
Sorry to be confusing but it’s late and I spent too much time on a small problem like that and I can’t think really clearly anymore.
Thank you for reading, and even more for answering.