#Input System Issue

1 messages · Page 1 of 1 (latest)

midnight hornet
#

I am currently creating my first project and working on the input system to get crouching and sliding working. Here is the code so far.

https://gdl.space/ifugihidum.md

When I hit Left Control I can see the Crouch bool check off in the Starter Assets Inputs section of the inspector window but when I release it does not uncheck so it thinks its still sliding.

PS please dont laugh at my code for sliding or crouching im new and learning lol.

manic atlas
#

i'm pretty sure that Send Messages only calls the function when the action occurs

#

i'd just check the isPressed status every update

midnight hornet
#

Sorry do you mind rewording that? I copied the Jump since it should work the same way. Which part is using "Send Message"?

manic atlas
#

you're using a Player Input component, right?

midnight hornet
#

Thats correct yeah

manic atlas
#

it defaults to the "Send Messages" mode

#

actually, was that bit of code here provided with the starter assets?

#
#if ENABLE_INPUT_SYSTEM && STARTER_ASSETS_PACKAGES_CHECKED
...
        public void OnCrouch(InputValue value)
        {
            CrouchInput(value.isPressed);
        }
...
#endif
midnight hornet
#

Ah okay I see yeah

midnight hornet
manic atlas
#

ah, okay, I was second-guessing myself because I thought it might've been provided code

#

which would make me less confident that I'm right :p

midnight hornet
#

I wish haha

manic atlas
#

I mostly use the Unity Events mode, which calls the function when the action is performed and cancelled

midnight hornet
#

If I just switch it and change nothing else my character loses all functionality

manic atlas
#

Crouch needs to be held

midnight hornet
#

Ohhhhhhh

manic atlas
midnight hornet
#

Isnt that what putting the CrouchAndSlide(); is doing inside the Update()?

manic atlas
#

CrouchAndSlide looks at _input.crouch

#

that only gets set to true by CrouchInput

#
            else
            {
                _input.crouch = false;
            }
#

this part is weird

#

you'd only get here if _input.crouch was false

#

so it's redundant

midnight hornet
#

Ah true yeah

midnight hornet
manic atlas
#

show me the script

midnight hornet
#

For Sprint

#

?

#

Or the entire thing?

manic atlas
#

The whole thing is fine.

#

I want to see the sprint code, but I might as well see all of the context.

midnight hornet
#

Oh okay Ill get the whole thing also then

manic atlas
#

hmm, it does feel like crouching should be fine if sprinting works

midnight hornet
#

Yeah im not sure. When I hit the crouch button it crouchs fine but then doesnt release when its supposed to

manic atlas
#

whilst holding sprint makes you run, and then letting go makes you go back to walking?

midnight hornet
#

Yeah that works okay

manic atlas
#

ah, I see what it is

#

in the input action asset (the thing with all of the actions and bindings)

#

look at the Jump action's interaction section

#

it should say "Press", and then have a foldout menu with a "Trigger Behavior" field

#

the jump action will be on "Press and Release"

midnight hornet
manic atlas
#

so it triggers on both pressing and releasing the button

midnight hornet
manic atlas
#

oh wait, sprint, not jump

#

click on Sprint itself

#

those are bindings: specific ways to make the action happen

midnight hornet
#

Oh Brotherrrrrrr

manic atlas
#

Sprint is the action; Left Shift and Left Stick Press are the bindings

midnight hornet
#

I knew it was something simple I cant believe this

manic atlas
#

i never knew that until now :p

midnight hornet
#

Yep now its working like a charm. I completely forgot about that part there. Thank you lol

manic atlas
#

no prob