reparentTo...

Hey,

I’m working with the ralph example included in Panda3d. I’ve inserted a box into the render node, and I’m trying to let ralph pick up the box and walk around with it.

What I’m doing is something like:

if(pickedUp()):
box.reparentTo(ralph)

But the thing is, when ralph picks up the box it vanishes… any ideas?

Remember that the box has its own position, which is relative to its parent. When you change the parent of the box from whatever it is originally (render?) to ralph, the relative position stays the same but the parent has changed, and therefore the net position will change dramatically. I bet the box is zooming somewhere far away.

You probably want to change the box’s position when you change its parent, for instance with something like this:

box.setPos(0, 0, 0)

but that will probably put it at Ralph’s feet, so you might want to put it somewhere like:

box.setPos(0, 1, 3)

(on a random guess).

David