Parent a Physics Object to an Animated Character?

Using Panda3d 1.9.3, I’ve created a test game based on ‘Roaming Ralph’ with an animated actor character, then added a physics ActorNode with gravity force and a smiley model parented to it with a collision node. The smiley falls under gravity and bounces off the terrain in various ways depending on the CollisionHandler I define - CollisionHandlerQueue, CollisionHandlerPusher, CollisionHandlerFluidPusher, PhysicsCollisionHandler or CollisionHandlerFloor.
So far so good, but I’d like to be able to reparent the physics ActorNode/smiley to the actor character’s right hand as in ‘Looking and Gripping’ so my character can pick up and throw the smiley which then travels under gravity and bounces off the terrain.
Using self.ActorNodePath.reparentTo(self.RightHand)
seems to separate the smiley model/collision sphere from its physics ActorNode, so the smiley un-renders while the physics ActorNode drops through the terrain and keeps dropping.
Any ideas?
Brian

I’ve made some progress but I’m still a bit puzzled.
Here’s how I define my physics object:
na = loader.loadModel(get_object(this_physics_object).eggfile)
node = NodePath(“PhysicsNode”)
node.reparentTo(render)
an = ActorNode(this_physics_object+“actor_node”)
ANP = node.attachNewNode(an)
ANP.setPos(this_startpos)
base.physicsMgr.attachPhysicalNode(an)
na.reparentTo(ANP)
ANP.node().getPhysicsObject().setMass(35)

Here’s how I pick it up:
if in_hand==False:
in_hand=True
thrown=False
self.feedback_text=‘Held’
node.reparentTo(self.RightHand)
ANP.setPos(0,0.1,0)

And here’s how I throw it:
elif in_hand==True:
in_hand=False
thrown=True
self.feedback_text=‘Thrown’
self.thruster_force = LinearVectorForce(20,20,900)
self.thruster_force.setMassDependent(1)
self.thrusterFN.addForce(self.thruster_force)
ANP.node().getPhysical(0).addLinearForce(self.thruster_force)
node.reparentTo(render)
ANP.setPos(self.you.getX(),self.you.getY()+0.5,self.you.getZ()+1)
self.ThrowImpulseStartTime = globalClock.getFrameTime()
ANP.setHpr(90,0,0)

Each cycle of TaskMgr I check and when appropariote cancel the throw force:
if thrown and
(globalClock.getFrameTime()>=self.ThrowImpulseStartTime +.6):
ANP.node().getPhysical(0).removeLinearForce(self.thruster_force)
thrown=False

I’d expect the object to appear in your hand when you pick it up then fly/down in a parabola when you throw it. What actually happens is:

  1. When you pick up, it jumps into the your hand and shrinks to a tiny size, but then it drops out of your hand and rolls downhill to a local low point (I use the PhysicsCollisionHandler)
  2. When you throw, it returns to normal size and flies in a seemingly random trajectory which is sometimes the expected parabola but often some other weird flight path.
    Am I doing something wrong or can’t the physics engine be used this way?

I’ve now sorted this; basically when I pick up the physics object, I ignore all the physics nodes and just re-parent the Model to the character’s hand. Then when I throw it, I recreate the physics node hierarchy from scratch.
Brian