First: sorry for bad english, but i am german.
2.:
This is my code:
x = 0
x1 = 0
y = 0
y1 = 0
z = 0
z1 = 0
class MyApp(ShowBase):
def up(self):
z = z + 0.25
camera.setPosHpr(Vec3(x1,y1,z1),Vec3(x,y,z))
z1 = z
def __init__(self):
self.accept("h",self.up)
app = MyApp()
app.run()
if i press “h”, there comes an error:
File "C:\Panda3D-1.7.2\direct\showbase\EventManager.py", line 61, in eventLoop
Task
self.doEvents()
File "C:\Panda3D-1.7.2\direct\showbase\EventManager.py", line 55, in doEvents
processFunc(self.eventQueue.dequeueEvent())
File "C:\Panda3D-1.7.2\direct\showbase\EventManager.py", line 124, in processE
vent
messenger.send(eventName)
File "C:\Panda3D-1.7.2\direct\showbase\Messenger.py", line 388, in send
self.__dispatch(acceptorDict, event, sentArgs, foundWatch)
File "C:\Panda3D-1.7.2\direct\showbase\Messenger.py", line 473, in __dispatch
method (*(extraArgs + sentArgs))
File "script.py", line 20, in hoch
z = z + 0.25
UnboundLocalError: local variable 'z' referenced before assignment
:task(error): Exception occurred in PythonTask eventManager
Traceback (most recent call last):
File "script.py", line 48, in <module>
app.run()
File "C:\Panda3D-1.7.2\direct\showbase\ShowBase.py", line 2630, in run
self.taskMgr.run()
File "C:\Panda3D-1.7.2\direct\task\Task.py", line 502, in run
self.step()
File "C:\Panda3D-1.7.2\direct\task\Task.py", line 460, in step
self.mgr.poll()
File "C:\Panda3D-1.7.2\direct\showbase\EventManager.py", line 61, in eventLoop
Task
self.doEvents()
File "C:\Panda3D-1.7.2\direct\showbase\EventManager.py", line 55, in doEvents
processFunc(self.eventQueue.dequeueEvent())
File "C:\Panda3D-1.7.2\direct\showbase\EventManager.py", line 124, in processE
vent
messenger.send(eventName)
File "C:\Panda3D-1.7.2\direct\showbase\Messenger.py", line 388, in send
self.__dispatch(acceptorDict, event, sentArgs, foundWatch)
File "C:\Panda3D-1.7.2\direct\showbase\Messenger.py", line 473, in __dispatch
method (*(extraArgs + sentArgs))
File "script.py", line 20, in up
z = z + 0.25
UnboundLocalError: local variable 'z' referenced before assignment
i have shorten the code.
i dont know how the error comes.
can anyone help me?