1
$\begingroup$

I have the object I am spawning on a separate layer from what I read that is correct, but I am having errors that the key is not in the list...double checked names and everything. Can anyone maybe see something I do not?

here is the error KeyError: "CList[key]: ''breadcrumb'' key not in list" I assume it thinks there is no object with that name

and the code I used below

import bge

def main():

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

node = scene.objects['breadcrumb']
life_time = 5
#scene.addObject(object,loc,duration) *duration is in frames
if own['nodeSpawnTimer'] >= 5 and own['nodeCount'] <= 20:
    scene.addObject(node,own.worldPosition, life_time)
    own['nodeCount'] += 1
    own['nodeSpawnTimer'] = 0

main()

$\endgroup$
3
$\begingroup$

To addObject() the object has to be in an inactive layer. enter image description here

you need to use:

import bge
def main():

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

node = scene.objectsInactive['breadcrumb']
life_time = 15
#scene.addObject(object,loc,duration) *duration is in frames
if own['nodeSpawnTimer'] >= 5 and own['nodeCount'] <= 20:
    obj =scene.addObject(node,own, life_time)
    own['nodeCount'] += 1
    own['nodeSpawnTimer'] = 0

Related Documentation

$\endgroup$
1
  • $\begingroup$ thanks, I should have returned sooner I received an answer on blender artists that pointed me to 'objectsInactive'. $\endgroup$ Jun 12 '17 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.