I’m using a loop to expose joints in a level and place rocks and collision sphere’s at the joints, which works great. I want the rocks to break (play an animation) when you hit them, and then detach the rock node from the scene graph. I have problems when calling the animation on the parent of the collision sphere. Here’s my code:
# for each rock, we need to expose the joint, and create a collision sphere at the pos of the joint
for i in range (1, 114):
self.rockJoint = self.tube.exposeJoint(None,"modelRoot","r" + str(i) )
self.rockModel = Actor.Actor("models/Ice2.egg",
{'shatter' : "models/Ice2-Shatter"} )
self.rockModel.reparentTo(self.rockJoint)
self.rockSphere = CollisionSphere(0, 0, 0, 1.5)
self.rockSphereNodePath = self.rockModel.attachNewNode(CollisionNode('rColNode' + str(i) ))
self.rockSphereNodePath.node().addSolid(self.rockSphere)
self.rockSphereNodePath.show()
I’m not including my collision checking code, because the collisions work. But I’ll include my collision function that gets called on a collision
def collide(self, entry):
if(self.alreadyCollided):
None
else:
self.alreadyCollided = 1
# get the parent of the collision sphere node path, which is the rock/spike geometry
self.sphereHit = entry.getIntoNodePath()
self.geomHit = self.sphereHit.getParent()
self.breakAnim = self.geomHit.actorInterval('shatter')
print self.sphereHit.getParent()
self.shatterSeq = Sequence( self.breakAnim, Func(self.GeomHit.detachNode) )
Sequence( Func(self.pauseAll), self.shatterSeq, Func(self.resumeAll), Wait(1), Func(self.resetCollision) ).start()
The error I get is: NodePath instance has no attribute ‘actorInterval’
I think my problem is that every time I expose a joint, I overwrite the self.rockModel object, but I figured if I could get the parent of the collisionNode that was hit, that would be the geometry that I needed to animate, but panda doesn’t like this.
Any suggestions?