Can't get my model's y grow up(make it move)

Here is my code:

import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.filter.CommonFilters import CommonFilters 

#Load the ship
viewm = loader.loadModel("ship.egg")
viewm.reparentTo(render)
x = 8
y = 16
z = 0
h = 0
p = 0
r = 0
s1 = 2
s2 = 2
s3 = 2
viewm.setPosHprScale(x,
                     y,
                     z,
                     h,
                     p,
                     r,
                     s1,
                     s2,
                     s3)
#Bloom
render.setShaderOff()
filters = CommonFilters(base.win, base.cam) 
filters.setBloom(blend=(0, 0, 0, 1),desat=-0.5,intensity=2.0,size=1) 
#Move the ship
if 1==1:
        viewm.setY(viewm,  y+1)

run()

I tried lots of other possiblities, but I just have no, no idea what is bad, is it that y is not going to get bigger or that the position doesn’t update?

To move the ship, you have to update its position every frame. To do so, create the task:

def move(task):
    #Move the ship
    viewm.setY(viewm, 1)
    return task.cont
taskMgr.add(move, "moveTask")

Or, you can use event system: if a movement key is pressed, move the ship forward.

def move():
    viewm.setY(viewm, 1)
base.accept("w", move)

PS: Of course, in real life a bit more elaborate code is required but you can figure it out, I believe.

if 1==1:
        viewm.setY(viewm,  y+1) 

The point is, that command gets executed only once.
Also, since you are setting the Y relative to itself the object will always be moving with speed 17 forward - I dont think that’s what you want, is it?

You should probably put this in a task. Put this before the run() call:

def moveTask(task):
  # Move the ship 1 unit forward
  viewm.setY(viewm, 1)
  # Tell the task manager to continue looping this task next frame:
  return task.cont

# Add the task to the task manager
taskMgr.add(moveTask, "move the ship")

Also, keep in mind that since you’re doing relative positioning, it will move with speed 2 instead of speed 1 (since the object is scaled).

EDIT: Oh, birukoff beat me to it :wink:

спасибочки!
thanks!
I must say I would never figure that out on my own :smiley: