# firing / throwing a cube ... ProjectileInterval

I just started playing with the Projectile Interval. Below is my first code sample. I created a target object and parented it to my player so it is always 44 units in front of the player. So no matter where I move to, I can throw a box 44 units ahead.

Note 1: The target object is parented to the player so it will always stay 44 unites in front of the player.
Note 2: To set the endPos for the projectile, a .getPos(render) was used. If .getPos() is used, the value will always be the same because .getPos is relative to the parent and the position relative to the parent isn’t changing, its remaining (0,44,1).
Note 3: The gravityMult can be set from 0 and up. The higher the number the bigger the arch. A value of 0.1 is pretty linear.

This is the snippets of the relevant code:

``````class World (DirectObject):
def __init__(self):
.....
#set up a 'leading' cube, player
self.Icube.reparentTo(render)
self.Icube.setPos(0,0,0)
self.Icube.setColor(1,1,1,1)

#target object ... light
self.plight3 = PointLight('plight3')
self.plight3.setColor(VBase4(1, 1, 1, 1))
self.plight3.setAttenuation(Point3(0,0.6, 0))
self.plnp3 = self.Icube.attachNewNode(self.plight3)
self.plnp3.setPos(0,44,1)
render.setLight(self.plnp3)

self.accept("space",self.fireF)

def fireF (self):

cube.reparentTo(render)
cube.setColor(0,0,1,1)

self.trajectory = ProjectileInterval(cube,
startPos = self.Icube.getPos(),
endPos = self.plnp3.getPos(render),
gravityMult = 0.7, duration = 1)
self.trajectory.start()
``````

If you want to litter the ground with cubes, here is some more code. Add the line below to the init function:

and the code below replaces the fireF function:

``````    def fireF (self):