Hi,
Just today I started coding with panda3d and it looks great.
I managed to do some stuff from the tutorial. Now I have the environment, the panda, which runs in circles, and I managed to control the camera angle by moving the mouse.
Now I want to control the position of the camera using the w a s d keys. and it works, but it does not work when I hold they key.
what I do is:
self.accept(“w”,self.setButtn,[“w”]) to catch the key. the setButtn fuction just changes the value of a variable.
then, in the moveCam task, I look whats in the variable, and do one of 4 things, like this:
s = 0.1
if self.button=="w":
pos = self.camera.getPos()
h = self.camera.getHpr()[0]+90
p = self.camera.getHpr()[1]
h_R = h*pi/180
p_R = p*pi/180
dx = s*cos(h_R)
dy = s*sin(h_R)
self.camera.setPos(pos[0]+dx,pos[1]+dy,pos[2])
self.button=""
But that only works if I keep pressing the key, it does not work when I just hold the key pressed.
How do I need to modify it to have it run with holding a key pressed? and will this work if two keys are pressed at the same time?
Thx.