name of a newly created objekt and "target them"

hi! i need to know how to target an objekt that have been created ig whit the additem function using a python script. for example, if i ig add 10 new boxes, how do i target the 6th of them to for example get “LocRotScale?”

sry 4 my bad eng, hope i get understod anyway

I did it this way:

By adding it give each a unique id or whatever.

Then you need only to get the id you want.


import bge

scene = bge.logic.getCurrentScene()
own = bge.logic.getCurrentController()

own = cont.owner

new_object = scene.addObject('ObjectName', own)

try:
    bge.logic.object_list.append(new_object)
except AttributeError:
    bge.logic.object_list = [new_object]

added_objects = bge.logic.object_list

index = 5

if len(added_objects) >= index + 1:
    target = added_objects[index] 
    # Do something with target object


sounds like a plan!
but how exactly do you give an added objekt an id? :spin:

nice script, but why do you asign the valu “own” 2 times? is the first “own” supose to be “cont”? :slight_smile:
anyway rly nice, and thanks for the help :slight_smile: