The setPos of the camera is useless in my codes

Why can’t I set the position of the camera?
But if I add it to taskMgr, it will run successfully
:face_with_monocle:

from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture

class World(ShowBase):
    def __init__(self):
        super().__init__()
        self.camera.setPos(0, 10, 0)
        self.camera.reparentTo(self.render)
        self.model = self.load_model('smodels/pan.egg')
        self.model.reparentTo(self.render)
        self.model.setPos(0, 20, 0)

    def load_model(self, path):
        model = self.loader.loadModel(path)
        textures = model.findAllTextures()
        for texture in textures:
            texture.setMagfilter(Texture.FTNearest)
            texture.setMinfilter(Texture.FTNearest)
        return model

app = World()
app.run()

In short, I believe that it’s because you haven’t called “self.disableMouse()”.

To explain: Panda by default applies a built-in control-system that use the mouse to move the camera. And since this control-system is moving the camera, it overrides any other attempt to move the camera.

However, ShowBase provides a method to disable this default control-system: the “disableMouse” method. With that method called (usually near the start of the program, but after initialising ShowBase), the camera should respond to calls to “setPos”, etc. as expected!

Oh! Successfully! ThanX!
:smiling_face_with_three_hearts:

1 Like