camera problems

hello guys !
i’ve been seaching on this forum something about changing cameras in the middle of the game, and that’s one of the things that i wanna set on my game …
well , i started to make, and i stuck on this “changing camera”… i set 2 types of camera, and when i press the button, the camera changes to the firt one, and when i press another button, the camera come back to the firt position
what it’s happening is that the game is starting perfectly with the firt camera set up… when i press the button the camera changes to the second one ( perfect), but when a press again to return to the firt one, it mess it up, the game still runing , but the camera position changed and i just can’t see anything.
here is the cameras code:

def setViewMain(self):
        if (self.dummy != None):
            self.dummy = None
            base.camera.detachNode()
            base.camera.reparentTo(render)


        
        
        lens = OrthographicLens()
        ratio = base.getAspectRatio()
        lens.setFilmSize(100.0, 100.0/ratio)
        base.cam.setPos(0, -100, 0)
        base.cam.node().setLens(lens)
            
            
    def set3DView(self):
   
        lens = PerspectiveLens()
        base.cam.node().setLens(lens)
        base.camera.setPos(0,-100, 0)
        base.camera.setY (-80)
        base.camera.setP (180)
        base.camera.setR (180)
        base.camera.setZ (5)
            
            
        if (self.dummy != None):
            self.dummy = None
            base.camera.detachNode()
            base.camera.reparentTo(render)
            
                
        self.dummy = NodePath ("dummy")
        self.dummy.reparentTo (self.persona)
            
        base.camera.reparentTo (self.dummy)
        self.dummy.setP (15)

please, i just don’t know what to do now, does somebody can help me :

thanks for the cooperation =)

nobody ?? =’(

base.cam.setPos(0, -100, 0) 

Shouldn’t that be base.camera.setPos?

Also, you forgot to set the HPR back to 0, 0, 0 again.

and shouldn’t this “if (self.dummy != None):” be this

if self.dumme !=None:

Wouldn’t i be more effective this way:

def setViewMain(self): 
        if (self.dummy != None): 
            self.dummy = None 
            base.camera.detachNode() 
            base.camera.reparentTo(render) 


        
        
        lens = OrthographicLens() 
        ratio = base.getAspectRatio() 
        lens.setFilmSize(100.0, 100.0/ratio) 
        base.cam.setPos(0, -100, 0) 
        base.cam.node().setLens(lens) 
            
            
    def set3DView(self): 
    
        lens = PerspectiveLens() 
        base.cam.node().setLens(lens) 
        base.camera.setPos(0,-80, 0)
        base.camera.setHpr (0,180,180) 
            
        setViewMain(self)
            
                
        self.dummy = NodePath ("dummy") 
        self.dummy.reparentTo (self.persona) 
            
        base.camera.reparentTo (self.dummy) 
        self.dummy.setP (15)

thanks guys !
actully , i already tried, but it happened exactly the samething … i tried a few different things, and i almost solve the problem. Now , the game starts , i can change to the second view, and change back to the first one, but, to change again to the second view, i have to press two times the button, dont know why hahahahahahahaha

here is the code:

def setViewMain(self):
        

        lens = PerspectiveLens()
        base.cam.node().setLens(lens)
        base.camera.setPos(0,-100, 0)
        base.camera.setY (-80)
        base.camera.setP (180)
        base.camera.setR (180)
        base.camera.setZ (5)
            
            
        if self.dummy != None:
            self.dummy = None
            
            base.camera.reparentTo(render)
            base.cam.reparentTo(render and base.camera)
            
                
        self.dummy = NodePath ("dummy")
        self.dummy.reparentTo (self.persona)
            
        base.camera.reparentTo (self.dummy)
        self.dummy.setP (15)
        
            
            
    def set3DView(self):
 
        if self.dummy != None:
            self.dummy = None
            
            base.camera.reparentTo(render)
            base.cam.reparentTo(render)
        
        lens = OrthographicLens()
        ratio = base.getAspectRatio()
        lens.setFilmSize(100.0, 100.0/ratio)
        base.cam.setPos(0, -100, 0)
        base.cam.node().setLens(lens)
            base.camera.reparentTo(render)
            base.cam.reparentTo(render and base.camera) 

That makes absolutely zero sense. base.cam is already reparented to base.camera, which you should reparent to render.

            base.camera.reparentTo(render)

Also:

base.cam.setPos(0, -100, 0) 

Change that to:

base.camera.setPos(0, -100, 0)