Hey guys,
Today I started to play with python in BGE. And understood that I’m not quite used to principles how do the script works in BGE.
As I understand there is main cycle in BGE that works all the time and I can control actions that goes on in this cycle. May be I didn’t describe the process absolutely correctly but I guess It’s approximately correct
So I have question: How do I declare and initialize global variables in BGE script?
Because if I declare variable in any place, for example x = 0, then in every iteration of the cycle x will become 0.
While writing got thought maybe I can access some blender built in features, because I can access owner of the controller in any moment and get position of object.
But I do have also other small misconceptions and things I do not understand for example if I get position of owner with owner.getPosition() (I know It’s deprecated :))
after that change location of object with some_actuator.setDLoc(x,0,0,True) (I know It’s also deprecated :)) and than again get position of owner with owner.getPosition() it returns the same result it returned first time even thou x wasn’t 0 and position of object changed. I guess it has something to do with that BGE main cycle works with pulses and does some thingsasynchronously with my script.
So if there are some wise and willing to help people I would be grateful for some help
Maybe somebody could paste some good example how correct and structured script should look in BGE, or give some good links to tutorials or explanations of how does python scripts works in BGE, because it’s hard to find something even with google
And sorry that post is so long