my code: dpaste.com/hold/275365/
I get the error: UnboundLocalError: local variable ‘j’ referenced before assignment
What im trying to achieve: You can switch the bodies (Check)
you can choose the heads (half a check) Like each body has the joint for the head, and i made it so that if any of the bodies are reparented to avatarnp, then j = thatbody.find(’**‘joint-head’)
but i get the error: UnboundLocalError: local variable ‘j’ referenced before assignment
You’re assigning j in blocks like:
if avatarNP.getParent() == avatar1:
j = avatar1.find('**/joint_head')
Maybe the guards of the if (e.g. avatarNP.getParent() == avatar1) aren’t true, so j isn’t available. You could debug a little to see what’s happening.
However, you should remove repeated sections of code. You’ve a lot of code that is only a repetition of previous sections with little changes: in those cases you should write a function. This make your code simpler, and it’s easier to maintain it.