Edit this script so that on the second jump change the gravity to 5

var speed = 6.0; 
var jumpSpeed = 8.0; 
var gravity = 20.0; 
var jumpCount = 0; 
var maxJump = 2; 

private var moveDirection = Vector3.zero; 
private var grounded : boolean = false; 

    //Reset jumpCount
    function OnCollisionEnter() { 
        jumpCount = 0; 
    } 
    function Update() { 
        if (!grounded) { 
        moveDirection.x = Input.GetAxis("Horizontal")*speed; 
        moveDirection.z = Input.GetAxis("Vertical")*speed; 

       } 

   else { 
      moveDirection = Vector3(Input.GetAxis("Horizontal")*speed, 0.0, Input.GetAxis("Vertical")*speed); 
      //reset jump because we are grounded
       jumpCount = 0; 
   } 
    //jump
        if (jumpCount < maxJump) {
            if (Input.GetButtonDown ("Jump"))  { 
         moveDirection.y = jumpSpeed; 
         jumpCount++;
      } 
}
   moveDirection = transform.TransformDirection(moveDirection); 

   // Apply gravity 
   moveDirection.y -= gravity * Time.deltaTime; 

   // Move the controller 
   grounded = (GetComponent(CharacterController).Move(moveDirection * Time.deltaTime) &         CollisionFlags.CollidedBelow) != 0; 

            //shift toggles run
        if (Input.GetKey (KeyCode.LeftShift)) 
            speed = 13; //run speed

    else //
            speed = 6;
} 

Someone please help

2 Answers

2
jumpCount++;
if (jumpCount == 2)
  gravity = 5;

DaveA's answer didn't work, but I worked it out myself:

var speed = 6.0; 
var jumpSpeed = 8.0; 
var gravity = 20.0; 
var jumpCount = 0; 
var maxJump = 2; 

private var moveDirection = Vector3.zero; 
private var grounded : boolean = false; 

    //Reset jumpCount
    function OnCollisionEnter() { 
        jumpCount = 0; 
    } 
    function Update() { 
        if (!grounded) { 
        moveDirection.x = Input.GetAxis("Horizontal")*speed; 
        moveDirection.z = Input.GetAxis("Vertical")*speed; 

       } 

   else { 
      moveDirection = Vector3(Input.GetAxis("Horizontal")*speed, 0.0, Input.GetAxis("Vertical")*speed); 
      //reset jump because we are grounded
       jumpCount = 0; 
   } 
    //jump
        if (jumpCount < maxJump) {
            if (Input.GetButtonDown ("Jump"))  { 
         moveDirection.y = jumpSpeed; 
         jumpCount++;
      } 
}
   moveDirection = transform.TransformDirection(moveDirection); 

   // Apply gravity 
   if(jumpCount == 1){
   gravity = 15;
   moveDirection.y -= gravity * Time.deltaTime; 

} else
    gravity = 10;
    moveDirection.y -= gravity * Time.deltaTime; 

   // Move the controller 
   grounded = (GetComponent(CharacterController).Move(moveDirection * Time.deltaTime) &         CollisionFlags.CollidedBelow) != 0; 

            //shift toggles run
        if (Input.GetKey (KeyCode.LeftShift)) 
            speed = 13; //run speed

    else //
            speed = 6;
} 

if(jumpCount == 2){

}