Now, If I press the ‘arrow_up’ button, my panda does move, but only once, I expected that it would keep moving forward. I don’t get it, my ‘catchInput’ doesn’t seem to accept my buttonpress every frame, but only once. Anybody has an idea what I’m doing wrong, what’s happening?
Key events only fire once when you press it down. The usual way to do it is to listen for the down event and the up event (arrow_up-up), storing the key state in a variable, and create a movement task that moves it by the speed multiplied by the elapsed time (globalClock.getDt()) to get a correct result.
Don’t put your accept() calls into a task. You should only bind them once.
I would advise you to study the Roaming Ralph sample program, it shows how to deal with this.
The trick with the lobalClock.getDt()is to make the movement independent from the frame rate.
If you’d move the avatar (let’s say he’s in a car) 1 meter every frame then at 30fps he would move at 30 m/s (~108km/h) with a frame rate of 120 fps he’d blazed at 430km/h