Skip to content

Instantly share code, notes, and snippets.

Last active November 12, 2016 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/fff2ee26da78db51066bb83bf2ae4f3c to your computer and use it in GitHub Desktop.
Save anonymous/fff2ee26da78db51066bb83bf2ae4f3c to your computer and use it in GitHub Desktop.
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