# 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:

``````spearGo.pause()
yourSpear.wrtReparentTo(collisionentry.getIntoNodePath())``````

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 = …
…spearGo.start()

collision event takes place here:

def collide(self, collEntry):
self.enemyDeath(collEntry) #begin death seq1
print ‘Hit’

def enemyDeath(self, collEntry):

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

collEntry.getIntoNodePath().wrtReparentTo(self.hitpoint)
collEntry.getFromNodePath().getParent().getParent().wrtReparentTo(collEntry.getIntoNodePath())

****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()
self.collHandEvent=CollisionHandlerEvent()

#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.show()
#colSphereNodePath.setPos(0,0,20)

#add this object to the traverser

#accept the events sent by the collisions
self.accept('spearCol' + '-into-' + 'gladECol', self.enemyDeath)