How to copy BGE logic from one object to another using script?

I use the following code (coppied from an addon) to create a duplicate of an object ...

def copyObject(scene, name, copyobj, location ):

  # Create new mesh
  mesh = bpy.data.meshes.new(name)

  # Create a new object.
  ob_new = bpy.data.objects.new(name, mesh)
  ob_new.data = copyobj.data.copy()
  ob_new.scale = copyobj.scale
  ob_new.location = location

  return ob_new

But this does not copy the game logic from the original object.


  • $\begingroup$ this answer will show the python paths of the logic bricks data. I don't think you can do a copy() but you can step through the properties of each brick and recreate them. $\endgroup$
    – sambler
    Jan 23, 2015 at 16:17
  • $\begingroup$ thx sambler. selecting the object and using bpy.ops.object.duplicate_move seems to be working. I'll post the code. $\endgroup$
    – Bhupen
    Jan 23, 2015 at 17:11

2 Answers 2


To copy game logic from one object to one or many others:

Select the other object (or multiples using shift) first (object you would like to copy game logic nodes to)

Select the object you want to copy from (using shift to select)

Click Object->Game->Copy Logic Bricks

( or script as bpy.ops.object.logic_bricks_copy() )

Can be done for Properties as well as Physics properties.

Is this the type of copy you are looking for?

  • $\begingroup$ I was looking for copying the whole deal (as when you do with shift-D). But this script would be handy if I wanted to copy just the logic bricks. thx! $\endgroup$
    – Bhupen
    Jan 23, 2015 at 23:41

Following workaround of selecting the object and using bpy.ops.object.duplicate_move works for my case ...

def copyObject( scene, name, copyobj, loc ):
  copyobj.select = True
  l = (loc[0] - copyobj.location[0],loc[1] - copyobj.location[1],loc[2] - copyobj.location[2])
  bpy.ops.object.duplicate_move( TRANSFORM_OT_translate={"value":l} )
  obj = scene.objects[0]
  obj.name = name
  return obj

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .