I’m new to panda3d and I’m messing around with the tutorials and sample programs.
I want to modify the Asteroids program so that the camera follows overhead the player’s ship. So no matter how the ship moves, the camera is always directly overhead of it.
I tried to take code from https://www.panda3d.org/manual/index.php/Controlling_the_Camera and put it into the asteroids code https://www.panda3d.org/manual/index.php/Sample_Programs:_Asteroids, but nothing seems to work.
Can someone give me the minimal set of changes to the Asteroids sample that would make this work along with some explanation?
Any help is greatly appreciated.
Here is what I have tried so far:
At the end of the updateShip method I have tried every permutation of the following:
base.camera.setX(self.ship.getX())
base.camera.setZ(self.ship.getZ())
base.camera.lookAt(self.ship)
base.camera.setPos(self.ship.getX(), base.camera.getY(), self.ship.getZ())
At the start of the file I imported ShowBase
from direct.showbase.ShowBase import ShowBase
And I made World an instance of ShowBase instead of DirectObject
#class World(DirectObject):
class World(ShowBase):
I’ve tried the code with and without a call to ShowBase’s init method:
def __init__(self):
#ShowBase.__init__(self)
When I do call ShowBase.init(self), I get this error:
“StandardError: Attempt to spawn multiple ShowBase instances!”
I assume that error stems from ShowBase being some kind of global object that was already initialized?