I need help with my walking mechanic in my game which does not work (It is third person) right now because of a bug that I can not figure out.
In your code, when you press the
w key down then your character will move for
0.75 seconds forward forever. Even when you release the
w key, this animation will continue since the transition-block is inside of a
Here are some ways to fix this
1. Use the “
when key is pressed” CoBlock
Selecting the “pressed” option will cause the code inside to run as often as possible as long as you keep holding down the button.
2. Stop the forever-loop when you release the w - key
You can do this by creating another variable that checks if you are moving forward. Whenever you are not moving forward (by releasing the
w - key), the forever loop is stopped. You can do that by using the if … else block to check for the variable and the break out of loop block.
Click to show CoBlocks
Note: When setting the
isWalking variable to
false we’re also using the stop transition block to stop the item movement.
Below you can find a remixable space in which you can try and test the CoBlocks code yourself
Hope this helps!