Assmembling a robot from parts with physics enabled.

Hi everyone,
I’ve been trying to solve this problem for quite a few months now. I’m still new to Panda3D, but I have read and ran nearly all the build-in tutorials, and a series of Collision examples and Physics examples. I feel comfortable with the panda terminology and i’ve gotten some simple simulations to run great.

In my game, I want to have a series of robot parts that you can assemble into a robot. Once assembled, I need to detect collisions between other objects in the world and each individual part. That robot can also do stuff like move around, rotate parts, etc, primarily through the control of the parts, and not of the whole robot itself. e.g. To move the robot, we ask the wheels to provide a force, subsequently all the parts move that are attached to the wheels.

The main problem I keep running into is some way to ‘fasten’ the parts to each other or to some Host. Lots of reading leads me to Multi-part actors, Actor sub-parts (which are different things?), parenting nodes to one another, setting joints and skeletons, etc. I can’t get them to work though. Perhaps there’s a way to set things intangible? Or make the PhysicsCollisionHandler not push certain objects?

I’ve been trying to implement it in many ways, but always seem rife with problems. What is the correct way to implement this? Here’s some examples of what I’ve tried:

–1
Each part is an Actornode. Parent them all to one other ActorNode. All part-actornodes and the host-actornode have CollisionNode attached to them along with a nodepath which is the model from loadModel.
Problem: Gravity pulls all the parts to the floor and the bot falls apart. CollisionHandlerPusher pushes all the parts away and it explodes.

–2
One actornode. Each part is a Nodepath just loaded with differnt models. Each part’s nodepath is given a different CollisionNode.
Problem: The ‘wheels’ part and other parts do not exhbit friction, so it slides around on ice all the time. If the bot tips over, it slides forever in a non-realistic way.

–3 Variation of 1, with the collision node for the host-actornode extremely tiny from setScale(0.001). ForceNodes set on the parts to counteract gravity.
Problem: Any acceleration causes the parts to keep going in the same path until they fly apart again.

–4 Variation of 2, with the CollisionNode for the only ActorNode huge and encompasses all of the parts in some sort of shell.
Problem: This collision shell pushes all the parts out of it with the PhysicsCollisionHandler, specifically the CollisionHandlerPusher.

Any help would be very appreciated!

Ok. well I think I figured it out! Here’s my render.ls() if anyone’s curious how I got it to work how I wanted:

PandaNode render S:(CullFaceAttrib RescaleNormalAttrib)
  ModelNode camera
    Camera cam ( PerspectiveLens ) T:q(pos 0 -20 10 hpr 0 -16.6992 0)
      PerspectiveLens fov = 39.3201 30
  ForceNode gravity forcenode (1 forces)
  CollisionNode floor (1 solids) [showcase]
  ActorNode Megabyte root actornode T:(pos 0 0 5)
    ModelRoot Gun #1 model T:(pos 1.5 0 3)
      GeomNode Cube (1 geoms: S:(ColorAttrib))
      CollisionNode Gun #1 colnode (1 solids) [bot: 763e4cd8-150a-445f-87c5-3cfdf77c9659]
    ModelRoot Steel Armor #0 model T:(pos -1.5 0 1 scale 1 2 2)
      GeomNode Cube (1 geoms: S:(ColorAttrib))
      CollisionNode Steel Armor #0 colnode (1 solids) [bot: 763e4cd8-150a-445f-87c5-3cfdf77c9659]
    ModelRoot Gun #0 model T:(pos -1.5 0 3)
      GeomNode Cube (1 geoms: S:(ColorAttrib))
      CollisionNode Gun #0 colnode (1 solids) [bot: 763e4cd8-150a-445f-87c5-3cfdf77c9659]
    ModelRoot Lithium Ion Battery model T:(pos 0.5 0 1 scale 0.3)
      GeomNode Cube (1 geoms: S:(ColorAttrib))
      CollisionNode Lithium Ion Battery colnode (1 solids) [bot: 763e4cd8-150a-445f-87c5-3cfdf77c9659]
    ModelRoot Steel Armor #1 model T:(pos 0 0 4 scale 2 2 1)
      GeomNode Cube (1 geoms: S:(ColorAttrib))
      CollisionNode Steel Armor #1 colnode (1 solids) [bot: 763e4cd8-150a-445f-87c5-3cfdf77c9659]
    ModelRoot Wheels model T:(scale 2 2 0.5)
      GeomNode Cube (1 geoms: S:(ColorAttrib))
      CollisionNode Wheels colnode (1 solids) [bot: 763e4cd8-150a-445f-87c5-3cfdf77c9659]
    ModelRoot 360 fisheye camera model T:(pos 0 0 2 scale 0.3)
      GeomNode Cube (1 geoms: S:(ColorAttrib))
      CollisionNode 360 fisheye camera colnode (1 solids) [bot: 763e4cd8-150a-445f-87c5-3cfdf77c9659]
    ModelRoot Steel Armor #2 model T:(pos 1.5 0 1 scale 1 2 2)
      GeomNode Cube (1 geoms: S:(ColorAttrib))
      CollisionNode Steel Armor #2 colnode (1 solids) [bot: 763e4cd8-150a-445f-87c5-3cfdf77c9659]
    ModelRoot Raspberry Pi B+ model T:(pos -0.5 0 1 scale 0.3)
      GeomNode Cube (1 geoms: S:(ColorAttrib))
      CollisionNode Raspberry Pi B+ colnode (1 solids) [bot: 763e4cd8-150a-445f-87c5-3cfdf77c9659]

Basically, my structure is render-> Actor Nodepath -> Bunch of Model Nodepaths -> Collision nodes and Geom Nodes on each model nodepath.

This way the actor controls the physics, responds to gravity and everything. But the parts all exhbit friction and respond as expected!