3
$\begingroup$

This is my code:

def textanim():
    print("GOGO")
    print("end")
    scene = bge.logic.getCurrentScene()
    print("end")
    scoreAnim = scene.objectsInactive["scoreAnim"]
    print("endNach anim")
    scoreSpawn = scene.objects["TextSpawn"]
    print(scoreAnim)
    print("end")
    c = scene.objects["Cube"]
    newText = scene.addObject(scoreAnim,scoreSpawn)
    newText["anim"] = True
    print("all lines were ececutet (hopefully)")

This is my result:

enter image description here

As you can see, not all the lines are executed, but there aren't errors either.
As Chebhou said the problem is the line where i try to load the FontObject:
scoreAnim = scene.objectsInactive["scoreAnim"]
I copied this at the beginning of another function and than this function isn't executed anymore.
So there is any problem with loading Font objects. Although I have it on an Inactive layer

This function should duplicate a score text object. The duplicated object than should then play an animation and slide to a corner. The score is saved.

Here you can download the .blend
2D car Game

$\endgroup$
3
  • $\begingroup$ Can you share the blend with the code or at least the full code (for example how and from where do you call this function)? $\endgroup$ – Lev Jul 13 '15 at 0:01
  • $\begingroup$ probably an error at the line scene.objectsInactive["scoreAnim"] which is ending the function, be sure that "scoreAnim" is on inactive layer $\endgroup$ – Chebhou Jul 13 '15 at 0:06
  • $\begingroup$ but shouldn't i get an error than ? $\endgroup$ – Toger Jul 13 '15 at 11:09
1
$\begingroup$

After some time i now found the solution. The problem was that this code was executed in a Try execept function. thats why i got no error (my bad). But the actual problem was that the object i was looking for wasn't in the list. this is caused beacause the object was parented to an object on an active layer but the object itself was on an inactive layer. I searched in both lists (scene.objectsInactive and scene.objects) but the object wasn't in any of them.

fazit: you shouldn't parent objects on different layer when one of those layer is Inactive.

$\endgroup$
1
  • $\begingroup$ A good example of catching unexpected errors (=always tell what error you expect). Yes, objects parented to objects that are not loaded with the scene will not be loaded as well (e.g. parenting to curves) $\endgroup$ – Monster Jul 30 '15 at 8:50

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.