Search Unity

CharacterController isGrounded: grounded and not grounded at the same time

Discussion in 'Scripting' started by whoisninja, Nov 10, 2017.

  1. whoisninja

    whoisninja

    Joined:
    Nov 10, 2017
    Posts:
    2
    I'm hoping this is the right place to post this, if not, I apologize in advance.

    I'm super newb in unity so please bear with me. The title says it all, I'm having issues with Character Controller isGrounded. I'm trying to make double jump for my player but upon testing it, It felt really off and not that responsive. So I put debug logs on where the 1st jump and when the 2nd jump happens.
    code.jpg

    the 1st jump happens when the player isGrounded and the 2nd jump if not (meaning if he's on air and my bool secondJump is set to true). Upon testing that, this is what happened...
    editor.jpg

    it says it's grounded and not grounded at the same time. I tried searching the forums for related stuff but there's no apparent solution. Why is this happening? Is this a unity bug? Or do I have a problem in my code? I'm using Unity 2017.1 by the way.

    Thank you for helping me out or giving me advise in advance!
     
  2. whoisninja

    whoisninja

    Joined:
    Nov 10, 2017
    Posts:
    2
    Hello again guys. I've solved the problem. Here's how I did it...

    I commented out this line of code...
    code - solved.jpg

    I'm not sure but it seems like the that code sets the player to not hit the ground but at the same time the isGrounded of Character Controller detects that's it already on the ground.
    editor - solved.jpg

    :)