The above animation has been used for 3 sets of animation, going into a jump from standing position, jumping and landing. It took about a whole day to complete, because I wanted it to look smooth.
To first setup the animation, I needed to create some new variables in the create action:
Once I created the code, I altered the jump code, so it requires the into jump animation to finish, until the player jumps into the air:
Afterwards I wrote the animation code, which tells the program when to push the character upwards and when to change the animation to the rising/falling animation:
Once this code is finished, the program then should check through this code to see if the requirements have been met:
The above code is changing the animation_action variable, because it will need to be used when hitting the ground.
Now that the jump code has been finished, this is what I have:
With all the jumping done, I added this code in to setup the landing code:
All this is doing is changing the animation_action variable. This is so the program can tell the animation is now playing and not just waiting.
From this point I added in the animation code:
This code will reverse the animation speed to -2 (I know it says 0.2, that’s because I forgot to change it when taking this screenshot). Once the animation has reached a certain point, it will bring the animation_action back to default, which means it can be used again. Here is the landing animation screenshot:
The animation is now complete, sort of. The animation is complete, but with it complete there were quite a few bugs, glitches and errors, which I needed to fix. I didn’t take screenshots of the code fixes, because I thought it wouldn’t be that necessary.
Some examples of issues I encountered were:
- Spelling error – I misspelled a value, so it wasn’t doing what I wanted it to do.
- Animation playing when a movement key is pressed – The issue was a weird one, the problem of the animation playing, was because of the run function I had. With it unlocked it played animation when the movement key was held down, but only at a certain point.