Collision geometry in animation

Hello community!

I’m new to the wonderful world of panda3d; we were just introduced two weeks ago. I’ve learned a lot since then. I’m currently having a problem whose solution may be so obvious I’m missing it.

I’ve created a model and animation in blender and successfully exported it (verified by using in the hello panda tutorial). There is a collision sphere built into the model, which I can access when it is loaded as a static model (and verified with another program I wrote).

My problem is trying to access that collision sphere when I load the model with the Actor() command. For example,

#load the ice cube
		self.icecube = loader.loadModel("ice_cube2")
		##self.icecube = Actor("ice_cube2")
		self.icecube.reparentTo(render)
		self.icecube.setPos(50,50,0)
		self.icecube.setH(-45)
		self.icecube.setCollideMask(OFF)
		
		#set up icecube's collision geometry
		raygeometry = CollisionRay(0, 0, 2, 0, 0, -1)
		icecubeCollider = self.icecube.find("**/ice_box_collider")
		icecubeCollider.node().setFromCollideMask(WALL|P2BODY)
		icecubeCollider.node().setIntoCollideMask(P1BODY)
		
		icecubeRay = self.icecube.attachNewNode(CollisionNode("icecubeRay"))
		icecubeRay.node().addSolid(raygeometry)
		icecubeRay.node().setFromCollideMask(FLOOR)
		icecubeRay.node().setIntoCollideMask(OFF)

works just fine with a static model with collision geometry, but

#load the ice cube
		self.icecube = Actor("ice_cube2", {"walk": "ice_cube2-walk"})
		self.icecube.reparentTo(render)
		self.icecube.setPos(50,50,0)
		self.icecube.setH(135)
		self.icecube.setCollideMask(OFF)
		self.iceWalkControl = self.icecube.getAnimControl("walk")
		self.iceIsMoving = False
		
		#set up icecube's collision geometry
		raygeometry = CollisionRay(0, 0, 2, 0, 0, -1)
		icecubeCollider = self.icecube.find("**/ice_box_collider")
		icecubeCollider.node().setFromCollideMask(WALL|P2BODY)#!!!
		icecubeCollider.node().setIntoCollideMask(P1BODY)
		
		icecubeRay = self.icecube.attachNewNode(CollisionNode("icecubeRay"))
		icecubeRay.node().addSolid(raygeometry)
		icecubeRay.node().setFromCollideMask(FLOOR)
		icecubeRay.node().setIntoCollideMask(OFF)

gives me an !is_empty() error at the line with the #!!!. Is it even possible to load collision geometry inside an actor, or does it have to be generated and attached in the code?

Thanks so much for your help! If I missed a relevant thread somewhere, please point me to it and keep the ribbing to a minimum :slight_smile:

I think you cant really have 2 ‘meshes’ (geomsnodes) in an egg, one rigged. Like you cant have 2 rigged ‘meshes’ in an egg (how would Panda know which one to play animation on?).
If you want to use collisionSphere, you can simply make one in code and use the functions to render it. Then you could simply resize it until you are happy.
Or you could make one in a modeller and load it with loadModel. The 1t option looks faster/easier though.