Jump, fall, and after determined time it's able to jump again.

I have a jump script, the player jumps, and I want that a certain time after fall to the ground, the player is able to jump again. How do I do this in java script?

2 Answers

2

You should post your script - our telepathic powers are too limited to guess how to modify your script without knowing it! But you’re lucky: I’m receptive today, so I can visualize something like the code below to modify your script:

var jumpInterval: float = 5;     // interval between jumps (seconds)
private var nextJump: float = 0; // time to jump again
...
    // modify your jump control this way:
    if (Input.GetButtonDown("Jump") && Time.time > nextJump){
        nextJump = Time.time + jumpInterval;
        // here goes your current jump code
    }
...

Hope my extrasensory power is correct, and this can help you. If yes, I’ll risk some money in the lottery today; if not, please post your current script.

@aldonaletto Yes, your “extrasensory/telepathic power” is correct, sorry, I forgot to post my script. I tried this one solution, and it works fine, thank you.

Thanks to keep me informed: since my sensitivity seems good today, I'll definitely spend some money in the lottery! By the way, Unity Answers is different from forums: you should use the Your Answer box only to answer the question (answers are counted) - replies and comments should only be posted using the minuscule add new comment button present in questions and answers. But I know that there's no warning about this, and that only new users with strong telepathic powers could guess this rule!

Thanks for keep me informed.