Triple Jump Combo

How to make a triple jump combo like in New Super Mario Bros. for the Wii. When my player jump first time the height is normal. When he jumps after the first jump then the height is 1.5x. And if the player jump 3 times in a row the height is 2x the normal.

  • Felipe

Here’s a detailed description of how to write your script:

  1. get off your lazy butt.

  2. write the script yourself

Hope this helps :slight_smile:

And you might want to try this site called GOOGLE. I here they have a pretty big collection of information.

Since I’m not a complete jerk i’ll leave you with this:

CharacterController

reference to this when your writing your jumping script and you should be good.

Hello @BigBlob, as a way to actually answer your question and not be a total douche (ahem, only to those who probably lied about said cake yesterday…), I wrote a little ditty for you to figure out the exact same thing, sorry it’s six years later, but this didn’t seem very popular, still open, and I never answered anything before so gimme those points. The stuff below should go into your script that controls the character, i have mine in the Update() function. The character has a bool to check if grounded and there are timers set up as well. Each time the character jumps, a timer is activated (you specify the amount in unity interface) by having the float count down by time.deltatime. I will try and break up the variables set up for the script and the jump separated.

Variables:

private Vector3 moveDirection;
public float jumpForce;
public float secondJumpTimer;
public float thirdJumpTimer;
public bool firstJumpActive;
public bool secondJumpActive;
public float secondJumpTimer;
public float thirdJumpTimer;

Code in Update():

if (controller.isGrounded)
{
	moveDirection.y = 0f;
}

    if (controller.isGrounded && Input.GetButtonDown ("Jump")) 
    {
    	jumpForce = 5;
    	moveDirection.y = jumpForce;
    	firstJumpActive = true;
    }
    			
    if (controller.isGrounded && Input.GetButtonDown ("Jump") && firstJumpActive && secondJumpTimer > 0.1f) 
    {
    	jumpForce = 7.5f;
    	moveDirection.y = jumpForce;
    	secondJumpTimer = 0f;
    	firstJumpActive = false;
    	secondJumpActive = true;
    }
    
    if (controller.isGrounded && Input.GetButtonDown ("Jump") && secondJumpActive && thirdJumpTimer > 0.1f) 
    {
    	jumpForce = 10.0f;
    	moveDirection.y = jumpForce;
    	thirdJumpTimer = 0f;
    	firstJumpActive = false;
    	secondJumpActive = false;
    }
    
    if (secondJumpTimer >= 2.0f) 
    {
    	jumpForce = 5f;
    	secondJumpTimer = 0f;
    	firstJumpActive = false;
    }
    
    if (thirdJumpTimer >= 2.0f) 
    {
            jumpForce = 5f;
    	thirdJumpTimer = 0f;
    	secondJumpActive = false;
    }
    
    if (firstJumpActive)
    {
    	secondJumpTimer += Time.deltaTime;
    }
    
    if (secondJumpActive) 
    {
    	thirdJumpTimer += Time.deltaTime;
    }

After that you want to make sure the common wire, fan wire, and tri wire are free of any nasty stuff and reattach them to the capacitor, oh wait, hold on do i get the ability to live on my own friends and a rations nwo.

Although the way you've written this isn't as clear as it could be, I think I understand what you're trying to ask. The key to a triple jump is for your script to remember how many times you have jumped before, and to know when to reset that number of prior jumps.

One way is to have a simple timer which measures how long you have been in contact with the ground. If you jump before you've been on the ground for a set time (probably less than a second), the jumping streak continues, increasing an integer which stores how many consecutive jumps you have performed. Your jumping behaviour would then depend on that variable, so on your first jump you only go so high, then on your second jump it goes higher etc. Finally you'd need to make it so that your timer stops and resets itself as soon as you press jump (and restarts itself when you next hit the ground), and your consecutive jumps value resets itself whenever your timer runs over it's predifined between-jump value, or when your jumps reached three. This way, if you've stopped on the ground for too long then you're back to your first jump. To get a double or triple jump you need to perform each jump rapidly after you land from the previous one. It sounds complex, but it isn't really if you just break it down into manageable chunks.

Finally here's a script;

function Update(){
    print ("The cake is a lie!");
}