Search Unity

Double Jump Help

Discussion in 'Scripting' started by KarneeKarnay, Feb 3, 2013.

  1. KarneeKarnay

    KarneeKarnay

    Joined:
    Sep 3, 2012
    Posts:
    61
    Hi I'm currently trying to get a double jump feature in my game. I'm using the default First Person Controller. I've looked around and someone suggested this but I'm not sure where to put it.

    Code (csharp):
    1. function DoubleJump{
    2. Jump();
    3. Jump();
    4. }
    Any help would be appreciated. Also has anyone translated the FPC into c#? Not so good with JavaScript.
     
  2. FlyingAce

    FlyingAce

    Joined:
    Jan 12, 2013
    Posts:
    58
    Wel for a double jump you don't want to call the jump function twice. You want to have the player have the ability to call it whenever he/she presses the key in the air.

    For instance, right now in the script, the function can only be called when the player controller is grounded. So you could make a variable called
    doubleJumped : boolean;

    and when you're player is in the air, if this value is false you can call the jump function again (maybe reduce the power but that's not necessary) so you can only double jump once per jump

    And when the player becomes grounded again the doubleJumped value turns false

    If you have any more questions feel free to PM me, I'm moderately active. Good Luck
     
  3. KarneeKarnay

    KarneeKarnay

    Joined:
    Sep 3, 2012
    Posts:
    61
    Could you point me in the code where I can see the grounded part? I'm not sure what part relates to the jumping.