How to get created objects move around?

hello everyone!
I’m new at Panda and what i’m trying to do is pretty simple.
here is my code:

from direct.directbase.DirectStart import *
from direct.task  import Task
from pandac.PandaModules import *
from string import *
from time import *
import os 
import math
import random


base.c = 0
base.val = 0

plight = PointLight('plight')
plight.setColor(VBase4(1, 1, 1, 1))
plnp = render.attachNewNode(plight)
plnp.setPos(5,0,0)
render.setLight(plnp)

def create():

    exec("caca%s=loader.loadModel('fleche.dae')" %base.c) 
    exec("caca%s.reparentTo(render)" %base.c)
    exec("caca%s.setX(base.c)" %base.c)       
    exec("caca%s.setTexture(loader.loadTexture('orange.jpg'))" %(base.c))
    base.c = base.c + 1
        
def boucle(task):
    if base.c > 0:
        base.val = base.val+1        
    
    return Task.cont

taskMgr.add(boucle, "boucle")


base.accept("mouse1",create)
run()

This code is working, it’s creating an arrow each time i press mouse button.

What I want is when i hit mouse button, it creates an objetc that is moving upward and i can’t figure out how to get my object in the task to make it moving.

Sorry for bad english.

thanx for helping.

Are you sure you need all this “exec” and base.val stuff?. Those lines look way too complicated.

In your thread you need something like:

model.setX(model.getX()+1)

You also shouldn’t need the if x > 0 condition. Just fire the arrow.

Also notice that in your code you start the thread only once by taskMgr.add(). You will need that in every create() call. Think about using intervals instead of threads.

Why in the world would you use exec for such a thing? Just use a dictionary or a list to store your models in.