Attempting to make an "IsJumping" condition with the Input System

I’m trying to follow along with a lesson from the [Complete C# Unity Game Developer 2D] course. Even though a jumping animation is not created in the lesson, I was hoping to try and figure it out on my own with what we’ve learned from the jump/ climbing portion of the course.

Screenshot above is of my code. From what I’m reading of it, I would think that since when my capsulecollider is touching layermask “ground” it would set “IsJumping” to false?

I’m sure that I’m missing something here though. The line 49code is working, as soon as I press the jump button, my character begins the jump animation, but I can’t seem to make it stop!

Hi,

It’s great to see that you are challenging yourself. :slight_smile:

Have you already tried to add Debug.Logs to your code to see what is going on during runtime?

Given you set up the “Jump” action correctly, OnJump gets called only if you press the “correct” key. This means that the code inside the method code block gets executed only if your key was pressed down.

According to your logic, the “IsJumping” bool gets set to false if the key was pressed down and if the player is not touching the “Ground”. That’s a very specific case.


See also:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms