and -> problems with reparenting

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")
        print "Setting",-20,10)

Result: Camera has a nice offset - Default mouse behaviour is not available.

If however I replace* with* (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 - will not function as standalone code :wink:)

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.

I believe the problem you’re having is reparentTo is making the camera inherit the position of self.model when you call it. You could try reparenting it first and then calling setPos() to make it work in the new reference frame.

Maybe it did but it was too small to notice. Nodes inherit scale from their parent, and you have set the parent’s scale to 0.01. Try setPos(0,-2000,1000) and see if that is where you wanted it.

Something else to try is reset the trackball with the following lines: