I’m getting a UnboundLocalError: local variable ‘rotor00’ referenced before assignment. error. I know about variable scoping, which is why this one confuses me.
This is a model of a motor, I’m swapping out parts to demonstrate how it works. rotor00 is is a blender object.
The affected code is…
if ‘rotTotal’ not in rotor:
rotor00 = scene.objects[‘rotor00’] #make the rotor00 object useable by the bge.
print(‘set rotors’, rotor00.visible) # print out rotor00 visibility, it works properly, rotor00 has been set to False
if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.RKEY]: #read the keyboard
if rotor[‘rotTotal’] == 0: #rotTotal controls which objects get displayed
It throws the error flag on the last line of the code. If this were a function I could see why there would be a problem, but it’s only an if statement.
Any ideas on what is happening?