Thrown projectil from camera

Hi guys,

Newbie here… :mrgreen: This is my case: I’m trying but without successs thrown a projection from camera position. First I created a ball using the Smiley sphere model and then set its position and hpr to the same of, this way I could use the mouse to direct the camera and by consequence aim the target. The result is bizarre: the ball is thrown from everywhere except from the camera position!

This is the code piece:,-45,0)
def fire():
    # load the ball model
    self.ball = loader.loadModel("smiley")

    # the ball will be thrown from camera position and in the same direction
    # setup the projectile interval
    self.trajectory = ProjectileInterval(self.ball,
                                         startVel=Point3(15, 0, 0),

Sure I’m misunsdertanding some concept but the question is WHICH… :frowning: Any help is welcome!

Ok, nevermind. I solved this question. I used the method listed by @Hollower here:

For who may interest:

from direct.showbase.ShowBase import ShowBase
from import Actor

app = ShowBase()

app.acceptOnce("mouse3", app.enableMouse)

environ = loader.loadModel("environment")

panda = Actor("panda")

pandaInterval = panda.hprInterval(5, (360,0,0), (0,0,0))

bullets = []
bulletSpeed = 50.0
bulletLife = 5.0    # seconds bullet will remain in the scene

class Bullet(object):
        # model is left unparented because it will be copied
        model = loader.loadModel("smiley")
        def __init__(self, pos, hpr, speed, life):
            self.node = Bullet.model.copyTo(render)
            self.node.setPosHpr(pos, hpr)
            self.speed = speed
   = life
            self.alive = True
        def update(self, dt):
            if not self.alive:
   -= dt
            if > 0:
                # You should use the "fluid" versions of these functions
                # if you intend them to work with the collision system.
                self.node.setFluidY(self.node, self.speed * dt)
                self.alive = False

    # Every frame this task calls update on each bullet in the bullets list.
    def updateBullets(task):
        dt = globalClock.getDt()
        for bullet in bullets:
        return task.cont

    def shoot():
        global bullets
        bullets = [b for b in bullets if b.alive] # remove any dead bullets
        bullets.append( Bullet(,, bulletSpeed, bulletLife) )

app.accept("space", shoot)
taskMgr.add(updateBullets, "updateBullets"),-250,70)

Very important: bullet speed must be positive (different from original code which is negative).