When using the "Add Object" actuator, what is the new object called?

Hello fellow Blenderheads!

I am using a script that needs to get the name per each new object. Say I have an empty, when I press space it adds a cube. When I press space it adds another cube. The original cube was called “Cube”. What are the new ones called?

I guess they are auto named Cube.001 then Cube.002 and so on

I’m fairly sure that at this stage, they are simply called the same thing. The objects are unique, but their names are not. If you want to keep track of them, you have to somehow get a reference to them (a Python game object).


You can get the reference by using any one of the “getHitObject()” methods on sensors that offer it. Also, when creating objects with the add object actuator, you can get the reference to the created object with that actuators’ “getLastCreatedObject()” method.

Note: something to think about when using “getLastCreatedObject()”:

# Given that this is the first time the add object actuator is activated:
GameLogic.addActiveActuator(act_edit_add, 1)

game_object = act_edit_add.getLastCreatedObject() # returns None Type

# because even though the command to activate the actuator is given before
# getLastCreatedObject() is called, the actual object is created after the current pulse,
# and will therefore be available on the next pulse.

Thanks Social, well explained, like Blendenzo!

Using act_edit_add.instantAddObject() actually spawns the object during the script. This allows you to do wonders with act_edit_add.getLastCreatedObject()


#Returns the object just added.
last = addActuator.getLastCreatedObject()

EDIT: Social’s usage of .getLastCreatedObject() is very useful when referencing an object outside of the script, although not necessarily if using another script to get it. Script running is almost unpredictable unless you set every controller’s run position.

Also you can rename the name of the new object with one python script fired first time the object exists. I need do that thing sometimes, for refer to them later (for example, some objects in my game had inventory objects, i access to them with the new names because i store objects in this way : [email protected]@[email protected])