Can someone help me with this behavior?

JHSpencer

  • Posts: 5
hi, I'm trying to make my first game, but I can't seem to get behaviors down quite well. I'm working on my first behavior (walking) and I can't seem to get the actor to stop right away when I release the left or right arrow keys, that and the walking animation keeps playing when I release either key. Can anyone tell me what I need to add or change? I've attached a screen shot to this post. If it doesn't show up, let me know.

Hectate

  • *
  • Posts: 4643
Just get rid of the "if False" stuff - I'm not sure what that's even checking with the statement like that - usually it would just be the "otherwise" (also known as "else", basically - all other cases) - and it's also in the wrong spot. Regardless, it's not needed in this case.

The typical solution would be to - at the very top of the "always" wrapper - set the speed to 0. What happens is each frame the speed gets set to zero and then if the key is pressed (according to your existing blocks) it gets changed to your desired speed instead. Once the behavior is finished doing it's job, it'll move the player according to whatever the last speed was. If the key was never pressed that frame, the speed will stay set at 0.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

JHSpencer

  • Posts: 5
Just get rid of the "if False" stuff - I'm not sure what that's even checking with the statement like that - usually it would just be the "otherwise" (also known as "else", basically - all other cases) - and it's also in the wrong spot. Regardless, it's not needed in this case.

The typical solution would be to - at the very top of the "always" wrapper - set the speed to 0. What happens is each frame the speed gets set to zero and then if the key is pressed (according to your existing blocks) it gets changed to your desired speed instead. Once the behavior is finished doing it's job, it'll move the player according to whatever the last speed was. If the key was never pressed that frame, the speed will stay set at 0.

Thanks! That was really helpful. I finally got it to work  :D