Hello, I am fairly new to panda, however have some experience with openGL and other 3D engines. I am trying to set up a basic walk function that simply moves the camera forward in whatever direction it is facing.
def walk(self):
dir = base.camera.getMat().getRow3(1)
dir.setZ(0)
dir.normalize()
self.pos += dir * self.speed
base.camera.setPos(self.pos)
Theoretically this should work, the problem seems to be with the first line, it does not correctly return the camera’s direction vector, it always returns (0,1,0). Am I using the getMat() function incorrectly? or is there a better way to retrieve the camera’s current direction? Any help would be appreciated!
It seems that the camera’s position is getting reset each time through the loop, however, my mouse controls work fine, I can look around freely. I just cannot walk forward.
Here is all of my code for mouse and keyboard controls
For some reason when I print the cameras position in the walk function, it is always (0,0,0) and its direction is always (0,1,0). Am I resetting something somewhere that I am unaware of?