projectile sequence

Hello there,

Am attempting to make a spear hit a character and cannot figure out how to stop the projectileInterval sequence I have create when a hit is generated:

spearThrow = ProjectileInterval(self.spear,startPos = self.spear.getPos(),startVel = Point3(x,0,z),duration = 1) #defines projectile force and trajectory
spearGo = Sequence(spearThrow) #interval to sequence
spearGo.start() #begins the spearGo sequence

When a collision is made i want to attach the spear to the animated death of a character so it remains stuck through the character.

I think I can just attach the spear node to the character but I think it wont let me at the time of the collision as the sequence is still playing.

Is there anyway round this? I believe I can do it with a task but I like the spear is effected by gravity in the projectileInterval function.

Any help would be greatly appreciated.

you can pause the sequence, then do whatever you want with the spear, i think

Yeah, try something like this when a collision occurred:


or something like that.

cheers for the input,

my projectile interval is in a function where the force can be defined:

def setObjectForce(self, x, z):
if (self.began == False):
spearThrow = …

collision event takes place here:

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”})

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.

Many thanks once again

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



****I could only get working with exposeJoint, spear wouldnt follow the animation otherwise, why is this?

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()
    #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 #show the col geo
    colSphere = CollisionSphere(0,0,0,5)
    colSphereNodePath = self.chest.attachNewNode(CollisionNode('gladECol'))
     #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'GladiatorDeath')

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?