# Lerp Interval and Locking KeyStrokes?

First I’ll try and explain best I can what I’m trying to achieve. What I’m creating is a grid based game where the main character moves smoothly between each grid on a keystroke. What I want is if the player is still pressing the key after the character has reached the first square I want it to continue into the second.

This is the code I’m using atm

``````		tester = False

if(self.keyMap["left"]!=0 and not tester):
tester = True
myInterval1=LerpPosInterval(PodInit.pod,1.0,
Point3(PodInit.pod.getX()-6,50,0))
myInterval1.start()
if(myInterval1.isStopped()):
tester = False
myInterval1.finish()
``````

What this does is when I press the key the character rockets off to like -30, when in reality I only want it to go to -6.

``````if(self.keyMap["left"]!=0):
myInterval1=LerpPosInterval(PodInit.pod,1.0,Point3
(PodInit.pod.getX()-6,50,0))
if(myInterval1.isStopped()):
myInterval1.finish()
myInterval1.start()``````

What this one does is on pressing the key the player moves to -6 and stops. Then on each keystroke moves an additional -6. Making it look lurchy.

Any help would be appreciated!

Thanks!

So, you only want it to check for the key state at the end of the interval, as the last thing it does before the interval stops. And only then, if the key is held down, do you want to start a new interval.

So, put the logic that makes this check inside a function, and call that function at the end of the interval by appending a Func(myFunc) inside a sequence, like this:

``myInterval1=Sequence(LerpPosInterval(...), Func(myFunc))``

Note that you don’t have parens following myFunc: it’s Func(myFunc), not Func(myFunc()).

David

I think I follow what you are saying. I’m still pretty new to Panda so I’ll try and figure it out! Thanks!

I’m not entirely sure how to implement what your suggesting…

if I got what you’re trying to do (kinda old fallout gameplay) this showcase could provide all you need