Hi all,
i’ve got a bit of an issue that I can’t quite get a handle on. I’m trying to reparent the camera to my player object, without loosing the default mouse behaviour for now and ofcourse with an offset (so that its not inside the model).
For this i’ve tried the following code snippet:
from direct.showbase.DirectObject import DirectObject
class Player():
def __init__(self):
self.model = loader.loadModel("models/ship/ship")
self.model.setScale(0.01)
self.model.reparentTo(render)
self.model.setPos(0,0,0)
print "Setting base.camera.pos"
base.cam.setPos(0,-20,10)
base.cam.lookAt(self.model)
base.cam.reparentTo(self.model)
Result: Camera has a nice offset - Default mouse behaviour is not available.
If however I replace base.cam.* with base.camera.* (this was actually my first try as thats the recommendation) - the mouse behaviour still works, but the camera doesn’t get an offset.
When I remove the reparentTo, everything works as expected - but I’d need to keep the pos relative to self.model myself, instead of the engine doing that for me.
(Note: this is a seperate class file, called by main.py - will not function as standalone code )
Anybody know how I can make it that it has both the default mouse functionality and the offset?
Thanks for any insite any of you can give.