Positioning the camera behind the player

Currently I’m using the roaming ralph code. I’ve reparented the camera to ralph, but I can’t get the camera to be positioned behind him. Right now it is looking at him from the back right.

base.camera.reparentTo(self.ralph)
base.camera.setPos(self.ralph.getX(),self.ralph.getY()+0,0)

I’ve tried changing the numbers in the second line of code, but just can’t get the camera to go behind him. Could anyone explain to me the second line, or offer any suggestions on how to fix this? Thanks!

Once your camera has been parented to ralph, its local coordinates become relative to ralph. Thus, as far as your camera is concerned, ralph is at (0, 0, 0), the point (10, 0, 0) is 10 feet to ralph’s right, the point (0, 10, 0) is 10 feet in front of ralph, the point (0, 0, 10) is 10 feet above ralph–and the point (0, -10, 0) is always 10 feet behind ralph.

base.camera.reparentTo(self.ralph)
base.camera.setPos(0, -10, 0)

David

Awesome, thanks!!