Very confused

I was messing a round with a skySphere for my game

##############################################
#                                         #IMPORT#                                          #
##############################################
from pandac.PandaModules import *
##############################################
#                           #External Class IMPORT#                                   #
##############################################
from shapes.shapeGenerator import Cube, Sphere
##############################################
#                                           #NEW CLASS#                                   #
##############################################


class SkyBox1():

    def __init__(self, camera, boxOrSphere):
        self.cameraNode1 = camera
        if boxOrSphere == str("Box"):
            self.loadSkyBox()
        if boxOrSphere == str("Sphere"):
            self.loadSkySphere()

    def loadSkySphere(self):
        self.Sphere = Sphere(10)
        self.snp = render.attachNewNode("Sphere Node")
        self.Sphere.reparentTo(self.snp)
        self.snp.setTwoSided(True)
        texture = loader.loadTexture("SpaceTexture.jpg")
        self.Sphere.setTexture(texture)
        #self.snp.reparentTo(self.cameraNode)
        #self.snp.setBin("Background", 0)
        #self.snp.setDepthWrite(False)
        #self.snp.setCompass()

and when i import it

from SkyBox1 import *

it breaks my camera class

##############################################
#                                         #IMPORT#                                          #
##############################################
from direct.task.Task import Task
from direct.task.TaskManagerGlobal import taskMgr
##############################################
#                           #External Class IMPORT#                                   #
##############################################
from panda3d.bullet import BulletSphereShape
from panda3d.bullet import BulletRigidBodyNode
##############################################
#                                           #NEW CLASS#                                   #
##############################################


class Camera():

    def __init__(self, nodeToFollow, world):
        self.np = nodeToFollow
        self.world = world

        self.attachCamera()
        base.accept("wheel_up", self.cameraMove, extraArgs=[1])
        base.accept("wheel_down", self.cameraMove, extraArgs=[-1])
        #self.makeCameraCollision()

    def attachCamera(self):
        self.cn = render.attachNewNode('cameraNode')
        self.cn.setPos(self.np.getPos())
        base.camera.reparentTo(self.cn)
        base.camera.setPos(0, -10, 10)
        base.camera.lookAt(self.np)

    def cameraMove(self, arg):
        base.camera.setY(base.camera.getY() + arg)
        base.camera.setZ(base.camera.getZ() - arg)

    def makeCameraCollision(self):
        #nodes
        node = BulletRigidBodyNode('Box')
        node.setMass(0)
        self.ccnp = render.attachNewNode(node)
        self.ccnp.reparentTo(self.cn)

        #shapes
        shape = BulletSphereShape(.5)

        #nodes
        node.addShape(shape)

        #bullet world
        self.world.attachRigidBody(node)

which is called here

def createCamera(self, nodePath):
        self.camera = Camera(nodePath, self.world)

when skybox1 is imported i get this error with the camera class TypeError: Camera() argument 1 must be string or read-only buffer, not libpanda.NodePath and when its not imported it works fine 0.o i tried renaming SkyBox.py to SkyBox1.py thinking that the name was conflicting with a panda module but that did not work lol. Any ideas?

Panda already has a class named Camera, you should name your class something different.

Ill give that a try when I get home, buy why importing the sky box class break my camera code? It works if I don’t import or use sky box lol

When you do

from pandac.PandaModules import *

it imports Panda’s Camera class with the name Camera.

When you do

from SkyBox1 import *

it imports your own Camera class with the name Camera.

Whichever one you import first will be overwritten by the second one. That is one of the problems that comes up when doing “import *”. You could do

import SkyBox1

then if you need to refer to your camera class, you would refer to it as

SkyBox1.Camera

how does import SkyBox1 also import my camera class? i was importing my camera class before i started working on the skybox, and skybox only accesses a variable from camera class. My player class did as well before i started on my skybox. the only import of my camera class is with the other imports in my main file. ( i changed the name of the camera class and it works great, just trying to figure out what caused it to break out of the blue lol)

I’d guess that somewhere along the line you changed the order of which thing got imported first and that affected what “Camera” was referring to.