Hi there
I having problems duplicating multiple instances of an object on a hidden layer to a visible layer. I can only copy one instance of the object. Maybe I’m placing them all in the same location?
Here is my method
the hidden object is on layer 5
an empty on the visible layer with the following code attached reads the the coordinates from a text file.
the empty has an ‘edit object actuator’ which then adds the single object to the scene.
# alien dispenser script
# make sure layer 5 is hidden!
cont = GameLogic.getCurrentController()
own = cont.getOwner()
if own.first_run == 1:
own.first_run = 0
alien_dispenser = cont.getActuator('alien_dis_act')
print 'attempting to open test file'
text_file = open('C:\Fob\Blender\Scenes\Data\level_test.txt', 'r')
alien_xyz = [0, 0, 0]
for line in text_file:
own.alien_count += 1
# for each line extract the x,y and z coords into a 3 element list
result = line.split(' ')
# remove '
' from z coordinate and convert string to integer
alien_xyz[0] = int(result[0])
alien_xyz[1] = int(result[1])
alien_xyz[2] = int(result[2])
# scale up game index coordinates to world coordinates
alien_xyz[0] = ((alien_xyz[0] * 2) + 1)
alien_xyz[1] = ((alien_xyz[1] * 2) + 1)
alien_xyz[2] = ((alien_xyz[2] * 2) + 1)
print alien_xyz
own.setPosition (alien_xyz)
thanks for your help in advance!