Hah, Game Python and Runtime Game Scene are Asynchronous (Very Frustrating) - UPBGE 3.1

Yes indeed, I finally found it. Now when I look back then I realize how many “strange and unexplicable” bugs occur, it’s just a matter of python and runtime are asynchronous.

Sure, maybe if everything occurs as I expect on script it should work, but man, after 2 years programming on upbge/bge I finally realize that.

To explain how I found this, I was declaring a variable like this:
addedObj = scene.addObject(xxx,yyy,0)
addedObj[‘propA’] = “Stuff”
print(addedObj[‘propA’])

Result: Cannot print none type of object (or something like that…)

Anyways, if you find any unexplicable bug, try to look at my post first, hope I do help you xD.

I think your code is incorrectly setup. The BGE API works fine for me.

Well, even with your example not presenting the specific script I’m talking about, actually it works just fine on a new empty scene.

The problem is that in my actual game it doesn’t seems to work, maybe because of the complexity and much commands running at the same time.

Edit: In that case, the Sphere object already have the ‘prop’ with Hello value.

Just noticed. Object life is set to 0
Thus deleting it on spawn. How can Blender get a value from a deleted (None type) object. I think this is the issue.

No, if you set the last one as 0 or just don’t specify it on command it considers the same as the actuator, infinite life time.

you can’t read out an object in the same frame as it is created, so to print the property wait a frame or use the nextFrame command. same with deleting an object you can’t delete it in the same frame as it is added.

as for add object 0 as duration is indeed unlimited time.

It makes sense, indeed maybe not all elements are asynchronous, but some do. Thanks for the reply.