When my player is on the ground (isGrounded), and I press the up key, for some reason my player doesn’t jump. I have code that says when “canJump = true” the player will jump.
The weird thing is, this worked before I changed the location of the ground colliders. Beforem they were slightly under the ground.
EDIT: I figured out what was wrong. The ground had a box collider too so the player would detect the Ground not the GroundCollider. I simply removed the Colliders from the Ground objects.
Input.GetKeyDown will only register the frame that it detects your keydown, after that it’ll reset, you can use Input.GetKey and it will get called every frame you have the key pressed but this can be inefficient. I recommend you try something like:
if(Input.GetKeyDown("up")){
if (isGrounded) {
canJump = true;
}
}
if(Input.GetKeyUp("up")){
if (canjump) {
canJump = false;
}
}