Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to put those two condition together but as you see I can't.
Are there anyway to do that?
Help me pls.

What I have tried:

void Jump()
  {

      if (Input.GetButtonDown("Jump") && isGrounded )
      {
          gameObject.GetComponent<Rigidbody2D>().AddForce(new Vector2(0f, 5f),
          ForceMode2D.Impulse);
      }

  }
Posted
Updated 23-May-21 1:42am

1 solution

Since Unity - Scripting API: Input.GetButtonDown[^] returns a bool, I'd look at the definition of isGrounded - the error says it's a method, not a bool property or field. If so, it needs "()" to call it.
 
Share this answer
 
Comments
Blank Channel 23-May-21 7:44am    
Thank man it work.
OriginalGriff 23-May-21 8:09am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900