Hollow knight style jumping

so i made a third person controller and wanted a jump mechanic kinda like hallow knights. it didn’t work and said i had some compiler errors. i couldn’t figure out why and saw no compiler errors. can someone fix my code or post their own hallow knight jumping for me to use?
heres my code:

 if (Input.GetButtonDown("Jump"))
        {
           JumpButtonDown = True;
        }
        if(JumpButtonDown == True)
        {
           if(Input.GetButtonDown("Jump"))
           {
              Velocity.y = Mathf.Sqrt(JumpHeight * -2f * Gravity);
           }
           else
           {
               Velocity.y = Mathf.Sqrt(JumpHeight * -1f * Gravity);
               JumpButtonDown = False;
           }
        }

id be really grateful if someone could help

Let me offer you this riddle:

It is true that you must pay attention to capitalization.

It is false that capitalization does not matter. :slight_smile:

Also, check the radio buttons in the upper right corner of your console window. There are three… make sure they are all enabled.

Also if(JumpButtonDown = True) is definitely a bug. You want == for checking equality. A single = is an assigment.

1 Like

Also, line 5 probably should be two equals signs…

Also… why are you checking jump… the checking jump?!

checking jump automatically means the space bar

Follow the logic:

Line 1 checks the Jump Input, then sets a boolean.

Later on, AFTER you check the boolean, you check the Jjump input again.

ALSO: the test on line 5 will NEVER fail: you used one equal sign instead of 2 equal signs. See posts above.

its not a boolean its a float. i wrote at the top where you assign the variables and stuff

float JumpButtonDown = False;

This makes no sense to me so I will bow out now.

im sorry. im brand new to coding and didnt know it was supposed to be a boolean. im only 13 and started about a month ago

You really saw no compilation error after this… ?

float JumpButtonDown = False;

OK you might be telling the truth, but it was there ?

You cannot implicitly convert boolean to float in c#.

1 Like

i didnt check. im new to coding. but i fixed the problem and the code was waaay simpler than ithought.