Camera Help

Hello,

I’m having trouble placing the camera. I had it working at one point, and now it’s just inside the model. I’ve been scratching my head trying things for about 2 hours now, and I just can’t see what I’m missing. Maybe you brilliant cats can help!

Here’s the code: awesometi.me/wp-content/uploads/ … follow.zip

I have a sky dome that should be visible ala PiratePanda’s sky dome script ([Sky Sphere Script)). When I do not specify a camera, I can see the sky dome.

When I specify a camera (lines 40-44) at any coords, I’m inside the spaceship model and the skydome is not visible.

What am I doing wrong here, cats?

You need to add the following line to your initialization code somewhere:

base.disableMouse()

Hmm, that does change the perspective of the ship a teensy bit.

It was this:

With base.disableMouse() it becomes

But I want it to look like this

but with a camera that follows the player. Any ideas, anyone?

Replace the camera using:

base.camera.setPos()
base.camera.lookAt()

You can use the panda3D tools to help you finding the position you want:

from panda3d.core import loadPrcFileData
loadPrcFileData("", “want-directtools #t”)
loadPrcFileData("", “want-tk #t”)

I messed around with the code last night and by adding “base.disableMouse()” I was able to achieve what you’re asking for. Have you tried changing the distance you are setting the camera to? I tried several different values and each seemed to give the expected result. This is the camera setup code:

# Camera code, follow the ship
self.camera = base.camera
self.camera.reparentTo(self.m)
self.camera.setPos(self.m, 0, -400, 10)

Changing the -400 to different values should change the position of the camera in relation to the model.

Okay, you’re right - I got it now. It’s working, although I don’t see what’s different. Maybe putting it in the instance of the class, with self.camera = base.camera?

/shrug/

Okay, moving on to learning how to use a dummy node to make a smoother camera follow. :smiley:

Thanks!!