Working with the Camera

Hi there,

It may be because i am still fairly new to Panda3D, or that i am just missing something, but i cant seem to get to grips with positioning the camera. All i am basically trying t do is, when i run the program, i would like the player model to be centered in the camera. But i just cant seem to get it right.

I have,

base.disableMouse()
self.camera = base.camera
self.world.setPos(0, 0 ,0)
self.world.reparentTo(self.render)
self.player.reparentTo(self.world)
self.player.setPos(0, 0, 500)
self.camera.reparentTo(self.player)
self.camera.setPos(0, 0, 0)

According to the book i am reading, Panda 1.6 Game Engine, this should “center” the player model in the camera, but no matter what i try, i just cant seem to get it right. In his book, its seems to work perfectly.

I apologize if this is basic stuff, but i have tried looking for a tutorial on just using the camera, but cant find anything except small snippets of advanced code, which i cant see any relevance to what i am trying to achieve.

If anyone could please help with this i would greatly appreciate it, or provide me with the a link to a camera tutorial so i can see where i am going wrong.

Thank you very much and have a great day.

I figured it out!

I was not taking into account the position of the camera, relative to the player model, and i had my x, y, z all mixed up! At least i think that was the problem. Anyways it’s working exactly how i want it so i think i’m learning. :laughing:

Basically

 self.camera.reparentTo(self.player.model)
 self.camera.setPos(self.player.model, 0, -250, 100)

This sets the player to be in the center of the camera when the game loads in my case. I thought it would be,

self.camera.setPos(self.player.model, 0, 0, 0)