I didn’t find it into to API documentation but I tried to add properties on the scene instead of objects and it’s working quite well. But I wonder if I can do it? Can it cause some issues or is that fine?
scene = bge.logic.getCurrentScene()
scene["myProp"] = "property"
Hello! Many types of objects in the bge support item assignment… I can’t see any reason why do without… But I can make mistake.
You can say bge.blabla = “blabla” and this works too. Or bge.logic.myList = []
use logic.globalDict – it’s a dictionary assigned to the logic specifically for this. It also avoids writing over any other functions in logic/bge. For example: if you try logic.events[0] = [“foo”], it won’t work, because logic.events is a thing.
My first idea was to store the property in the globalDict but I read in the doc that the globalDict wasn’t made to store GameObjects. That’s why I tried scene[“prop”]. It’s logical that the prop will die with the scene. It’s then just perfect for me. Thanks
This is really nice! Thanks for the info. I used it to store character information between scenes and it works incredibly well! I couldn’t do simpler without it