In many games, especially the parkour games, characters can jump ,and while they are still in the air, they can jump again to move further and higher.
Since this is not realistic in the real world, the physics mechanism must be defined artificially. I have three ideas:
1-Whenever the "jump" key is hit in a legal time(that is, the player have not jumped or have jumped only once), the vertical speed will be SET to a specific fixed value.
This means the second jump will bring the player to a fixed height above the place where he or she performs the double jump.
However, this means the greatest height is reached when the second jump is performed at the peak of the first jump ,which is quite strange, since in most games players just hit the "jump" button rapidly twice to do highest double jump instead of waiting for a peak. Another problem with this is that since the first jump is very fast at the beginning, small difference in the time period between two jump actions will lead to a significant difference in the total height reached.
2-Whenever the "jump" key is hit in a legal time, the vertical speed will be ADDED a specific fixed value.
This means... well, the total jump height will be highly unstable, too. Simple calculation will reveal that if jumping with a speed of v reaches the height H, a jump with the initial speed of 2v will only bring the character to 1.414 H. The strategy to reach a best height also lies in performing the second jump at the peak of the first jump.
3-Whenever the second jump is performed, the program calculates the speed it needs to reach a fixed height and set the speed as that. The kinematic energy will be added a specific fixed value.
That is, no matter when the second jump is performed, the total height of the two jumps will always be the same, even if the second jump is performed when the player is going down.(which is quite weird, too.)
That's my plans, all of which don't feel quite right when tested. What's your physics mechanism adapted for your games?
Do you apply different rules when the player is going down and up? Do you have better mechanisms for this? Please do share.
(PS: the picture below is from the parkour game Oven Break, which I tried to analyze its double jump mechanism but failed...)