Camera is not updating when setting the position.

I’m trying to understand the coordinate system of Panda3D so I’m trying to move the camera based on keystrokes.
The problem is that the camera doesn’t update its position. It seems to twitch in the direction of movement but then goes back to the original position.
Here’s the code:

from direct.showbase.ShowBase import ShowBase
from direct.showbase.DirectObject import DirectObject
from direct.task import Task

from panda3d.core import loadPrcFileData
from panda3d.core import Geom



class MotionApp(ShowBase, DirectObject):

	ground = None

	def __init__(self):
		ShowBase.__init__(self)  # Load the environment model.
		DirectObject.__init__(self)
		self.setup_scene()
		self.setup_keys()

	def setup_keys(self):
		self.accept('o-up', self.switch_to_oobe)
		self.accept('z-up', self.move_positive_x)
		self.accept('x-up', self.move_negative_x)
		self.accept('a-up', self.move_positive_y)
		self.accept('s-up', self.move_negative_y)
		self.accept('q-up', self.move_positive_z)
		self.accept('w-up', self.move_negative_z)

	def setup_scene(self):
		self.ground = self.loader.loadModel('models/box.egg')
		self.ground.reparentTo(self.render)
		self.ground.setPos(0, 0, 0)

		self.camera.lookAt(0, 0, 0)

		#self.camera.setPos(-1, 0, 0)
		self.oobe()

	def switch_to_oobe(self):
		self.oobe()

	def move_positive_x(self):
		x_pos = self.camera.getX()
		print('x_pos: ' + str(x_pos))
		self.camera.setX(x_pos + 0.1)

	def move_negative_x(self):
		x_pos = self.camera.getX()
		print('x_pos: ' + str(x_pos))
		self.camera.setX(x_pos - 0.1)

	def move_positive_y(self):
		self.camera.setPos(self.camera.getX(), self.camera.getY() + 0.1, self.camera.getZ())

	def move_negative_y(self):
		self.camera.setPos(self.camera.getX(), self.camera.getY() - 0.1, self.camera.getZ())

	def move_positive_z(self):
		self.camera.setPos(self.camera.getX(), self.camera.getY(), self.camera.getZ() + 0.1)

	def move_negative_z(self):
		self.camera.setPos(self.camera.getX(), self.camera.getY(), self.camera.getZ() - 0.1)


if __name__ == '__main__':
	motion_app = MotionApp()
	motion_app.run()

How do i make it so that the camera actually changes position and not get stuck in its original position?

You forgot: base.disableMouse()

It’s not necessary to inherit from DirectObject explicitly, since ShowBase already derives from it.

Yeah, this is an annoyance that most if not all new Panda users stumble over. And there will be plenty more, unless the default behaviour will be changed to not have the camera controlled by the mouse. Because that’s what disableMouse actually does, not that it will cause your mouse to stop working.
At the very least, it could be renamed to something more sensible, like “disableCameraController”.
Sorry for the rant :stuck_out_tongue: .