(Solved) Double jumping

Hi, I’m simply trying to make my player able to double jump. So far I’ve been able to make my player able to jump once until it’s grounded again; then I tried to add a jump counter. However Unity gives me an error message on jumpCount +1;
Does anyone know what I’ve done wrong and how to fix this?

public float moveSpeed = 10f;
public float jumpForce = 50f;
int jumpCount = 1;

bool grounded = false;

void Update () 
{
//Jumping
if(jumpCount > 3 || grounded && Input.GetKeyDown(KeyCode.UpArrow))
	{
rigidbody2D.AddForce(new Vector2(0,jumpForce));
grounded = false;
jumpCount + 1;
	}
}

Usually, when jumping, you would want to zero out vertical velocity before adding force to counter any gravity. Next, you have 2 scenarios you want to watch for. Grounded & jumping, Airborn & jumping & candoublejump. So you want something like

if (jumpkeydown) {
  if (grounded) {
    rigidbody2D.velocity.y = 0;
    rigidbody2D.AddForce(new Vector2(0, jumpForce));
    candobulejump = true;
  } else {
    if (candoublejump) {
      candoublejump = false;
      rigidbody2D.velocity.y = 0;
      rigidbody2D.AddForce(new Vector2(0, jumpForce));
  }
}

values and descriptions may vary.

jumpCount > 3 || grounded

I think you mean less than, every time you jump the counter goes up, once it’s over 3 you can jump continuously. The error is also because you aren’t assigning that calculation to a variable, unlike Python you can’t just write ‘1+1’ and it will print the result. It will have to be ‘jumpCount = jumpCount + 1;’, or just += 1 or better yet jumpCount++.

You should try assigning jump count the +1 value. As you have it right now your variable is not being assigned your +1 value.

jumpCount = jumpCount + 1;