Last active
November 12, 2016 21:20
-
-
Save anonymous/fff2ee26da78db51066bb83bf2ae4f3c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void FixedUpdate () | |
{ | |
//Horizontal movement code | |
if (knockbackCount <= 0) | |
{ | |
horizontal = Input.GetAxis ("Horizontal" + PlayerNumber.ToString ()); | |
Vector3 movement = new Vector3 (horizontal, 0, 0); | |
// | |
rb.AddForce (movement * maxSpeed); | |
//Code to make the player jump | |
if (Input.GetButtonDown ("Jump" + PlayerNumber.ToString ())) | |
{ //This is line 117 | |
if (!jumpKey && onGround || !jumpKey && !onGround && jumpCount >= 1) | |
{ | |
jmpDuration += Time.deltaTime; | |
jmpForce += Time.deltaTime; | |
jumpCountUp (); | |
if (jmpDuration < JumpDuration) | |
{ | |
rb.velocity = new Vector2 (rb.velocity.x, jmpForce); | |
onGround = false; | |
canDoubleJump = true; | |
} | |
} | |
} | |
} | |
else | |
{ | |
if(knockFromRight) | |
{ | |
rb.velocity = new Vector2 (-knockbackX * knockbackDamage, knockbackY * knockbackDamage); | |
canDoubleJump = true; | |
} | |
if(!knockFromRight) | |
{ | |
rb.velocity = new Vector2 (knockbackX * knockbackDamage, knockbackY * knockbackDamage); | |
canDoubleJump = true; | |
} | |
knockbackCount -= Time.deltaTime; | |
} | |
// | |
//Code for falling, not used. | |
/*if(!onGround && vertical < 0.1f) | |
{ | |
falling = true; | |
}*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment