third person double jump

hey guys , i want a double jump to this script , i removed if (IsGrounded()) for unilimited jumps , but me all i want is just 2 jumps , how could i modify this script please , btw im using the default third person character controller from unity , thanks !

function ApplyJumping ()
{
	// Prevent jumping too fast after each other
	if (lastJumpTime + jumpRepeatTime > Time.time)
		return;

	if (IsGrounded()) {
		// Jump
		// - Only when pressing the button down
		// - With a timeout so you can press the button slightly before landing		
		if (canJump && Time.time < lastJumpButtonTime + jumpTimeout) {
			verticalSpeed = CalculateJumpVerticalSpeed (jumpHeight);
			SendMessage("DidJump", SendMessageOptions.DontRequireReceiver);
		}
	}
}

1 Answer

1

You could add a double jump boolean variable. Set it to false if grounded, true if in the air then one last calculation where if they jump again in the air, set the boolean back to false.

You could also just have an integer counter. Something that looks for the number of jumps performed and caps it at two then resets when the player touches the ground again.

dude please can u edit it for me im a quit noob a coding please help , here's the whole script : http://sharetext.org/6i9Z

–