def collide(self, collEntry):
self.gladE.removeNode() #remove run animation
self.enemyDeath(collEntry) #begin death seq1
print ‘Hit’
def enemyDeath(self, collEntry): #Load and play death animation
self.gladEDeath = Actor.Actor(“Game\spear\gladEnDeath”, {“GladiatorDeath”:“Game\spear\gladEnDeath”})
self.gladEDeath.reparentTo(render)
self.gladEDeath.setPos(80,250,-10)
self.gladEDeath.setH(-90)
self.gladEDeath.setScale(1.5,1.5,1.5)
self.gladEDeath.play(‘GladiatorDeath’)
I want to stop the spear projectile so i need to call the setObjectForce function right? self.setObjectForce().spearGo.pause()? But then i need to input arguments.
Have I gone about this the wrong way altogether? I’m pretty new at this and am just trying lots of different methods until I get the required results rather than probably doing it the correct way.
I got it to work, had nothing to do with pausing the sequence in the end, just needed to get my node parenting correct, thanks for the help:
def enemyDeath(self, collEntry):
self.hitpoint = self.gladEDeath.exposeJoint(None, ‘modelRoot’, ‘Chest’)#to attach the spear to bone manipulation of specific bone
Ok this was working fine but I now get a: detected attempt to create a cycle in the scen graph
I dont know why as I havent altered any of the collision script code. Does anyone know why this error occurs? The code that generates the error is:
def collisions(self):
#sets up traverser base.cTrav = CollisionTraverser()
#initialise handler of collision
lifter = CollisionHandlerFloor()
self.collHandEvent=CollisionHandlerEvent()
self.collHandEvent.addInPattern('%fn-into-%in')
self.collHandEvent.addOutPattern('outof-%in')
#Sets up collision geometry to object in scene
colSpear = CollisionSphere(0, 0, 20, 1) #type of collision geo is tube, set Pos in line with spear
colSpearNodePath = self.spear.attachNewNode(CollisionNode('spearCol')) #sets up node path of collision (attached to spear)
colSpearNodePath.node().addSolid(colSpear) #attachs col geo to node path
colSpearNodePath.show() #show the col geo
colSphere = CollisionSphere(0,0,0,5)
colSphereNodePath = self.chest.attachNewNode(CollisionNode('gladECol'))
colSphereNodePath.node().addSolid(colSphere)
colSphereNodePath.show()
#colSphereNodePath.setPos(0,0,20)
#add this object to the traverser
base.cTrav .addCollider(colSpearNodePath , self.collHandEvent)
#accept the events sent by the collisions
self.accept('spearCol' + '-into-' + 'gladECol', self.enemyDeath)
#Load and play death animation
def enemyDeath(self, collEntry):
self.gladEDeath = Actor.Actor("Game\spear\gladEnDeath", {"GladiatorDeath":"Game\spear\gladEnDeath"}) #Load DeathAnimation
self.gladEDeath.reparentTo(render) #To render
self.gladEDeath.setPos(80,0,-10) #Set Pos
self.gladEDeath.setH(-90) #Set Rot
self.hitpoint = self.gladEDeath.exposeJoint(None, 'modelRoot', 'Chest') #To allow manipulation of specific bone, ***required for spear to follow animation,WHY?****
collEntry.getIntoNodePath().wrtReparentTo(self.hitpoint) #Attaches gladE's collision solid to hitpoint (gladEDeath chestBone)
collEntry.getFromNodePath().getParent().getParent().reparentTo(self.hitpoint) #Attaches spear to hitpoint
self.gladEDeath.play('GladiatorDeath')
self.gladE.hide()
I cant understand as this code ran fine before and did exactly what I wanted it to do. I have added code that effects the trajectory of the spear. I have since deleted all this new code but the error still generates. Feel like I cant make progress until this is sorted but cant get my head around it. any ideas?