#make a inventory select feature (press 1'2'3'4'5'6...) like minecraft with new Inputsystem

1 messages ยท Page 1 of 1 (latest)

celest widget
#

my question is how do i know which keycode i press mood

errant ravine
#

I don't know what u doing there, but the easiest way to check which key you pressed is:

    //Do something. You can change the Keycode to anything else, like num buttons
}```

Hope this helps. As always **GL and HF**! ![CrabRave_Red](https://cdn.discordapp.com/emojis/849403383660019793.webp?size=128 "CrabRave_Red")
sudden vortex
errant ravine
fallow wagon
# celest widget my question is how do i know which keycode i press <:mood:818440436271808522>

I think this should give you an error in case you're creating a C# class from those input actions since their name is a number, kind of like when naning variables they cannot start with a number. Try changung your naming rules (for example: instead of 1, name it Tool1).

However, if unity is smart and handles these situations your input action in code should be calles @1, which is a C# solution for when people use invalid words for variable namings, such as callins a variable new for example.

sudden vortex
# errant ravine Oh, i see, but this "new" input system isn't availble on my version of unity, th...

If you are using 2018.3+ it should be something you can install from the Package Manager, albeit, different versions of the Input System will be available in newer versions of the editor though, and it is something that takes time to get familiar with so not everyone is aware of it or even needs all of what it offers, till a project deals with controllers or multi-input, binding or other forms of input thats harder to do with the Input class alone

celest widget
fallow wagon
#

Oh right, my bad. I think you can access the pressedKey from the fired event. Gotta check it real quick.

celest widget
fallow wagon
#

I've found here you can cast the control property into a KeyControl, which allows you to access the KeyCode.

celest widget
#

oh

fallow wagon
#

Assuming you generated a C# class from your input actions asset, of course.

fallow wagon
# celest widget oh

Yeah I didn't know you could do that eithee ๐Ÿ˜…, really cool to know. Haven't tested it tho but hopefully it works if you end up trying it out.

celest widget
fallow wagon
#

Yeah, basically I mean that if you make a C# class, each input action fires performed, canceled and started events. I assume that loop behaviour you've done is already implemented, maybe more optimized in some way.

fallow wagon
celest widget
fallow wagon
#

I mean that works fine aswell and it wont impact performance at all, so you shouldn't worry.

celest widget
#

oh ok thx : D