#🖱️┃input-system

1 messages · Page 48 of 1

sacred burrow
#

i'll try this

#

and also what if i want to sprint only when moving forward which is pressing W?

austere grotto
#

same deal - check if you're currently holding W via the same methods

sacred burrow
#

so that means i have to use the "Both" option on the project settings?

deft berry
#

you can do this entirely using the input system. how are you currently handling input?

austere grotto
#

of course not

#

none of what I said above has to do with the old input system

sacred burrow
#

so that means i have to make another input action for holding W separately from the movement input actions?

sacred burrow
#

so what do i do?

deft berry
#

how are you currently handling the input?

deft berry
#

cool, and the behavior on your player input component? (not 100% sure if this matters, but i'm going off of my own experience right now)

austere grotto
deft berry
#

ah you're doing it the less easy way, but like praetor said, just check the y value of your movement every frame, if it is greater than 0 then w is held

sacred burrow
#

ahh yup, so that's it

#

thanks guys

crisp gyro
glass yacht
#

not even monospace RaphWut

austere grotto
#

Monospace is a crutch!

glass yacht
#

Good fonts, a crutch

jade fossil
#

someone can suggest a complete tutorial for input system 1.0.X to create mobile sticks left-right) and character move-animations?

austere grotto
hidden scarab
#

hi guys i got small question i try play around with the unity new input system but it working very odd when start it look like player gose off screen i got this code try understand how work with fixupdate with the unity input system https://pastecode.io/s/gofqrx2z the Game.inputs it to gen script of unity new input system

chilly trench
#

Hopefully a quick question, but I am trying to record inputs on every frame in a session for replays. Is there a simple way I can make it so that the event triggers if a button is being held down? From my initial tests I can only trigger the event when the change in state (pressed/released) occurs, but keeping track on if the button is being held down or how long it's been held down has required me to do some logic an boolean checks for each direction and button. Feels like I'm overengineering it. Hoping I'm just missing some toggle that triggers the event whenever the button has or remains pressed. Any ideas or samples I can look at?

austere grotto
#

is that what you want?

#

if you want to just know "is this currently being held down" each frame - the best approach is to simply read the value of each action you are interested in each frame

#

It should be relatively straightforward to throw all of the InputAction(s) you are interested in checking each frame into a collection (such as List or array) and just do a for loop over that collection each frame to check if each one is currently actuated.

#

another option is to put all those actions into a collection, add a listener for all of their started and canceled events (again in a loop) which adds/removes those actions from a HashSet or Dictionary and you check/record the current residents of that HashSet/Dictionary each frame.

chilly trench
austere grotto
chilly trench
#

What I'm doing atm is I have class-level booleans such as upPressed, downPressed, punchPressed, etc. Total of 7 booleans for each direction and a function. When the event is triggered for example I store the value if the input value isPressed.

#

Then in the Update() I'm calling a void function PollInputs() which basically sets an array of length 7 to record current boolean values of each boolean, then calculates and stores the length of time the button has been held given the previous frame's values.

#

The array is of a custom button class I made which just records the input type, if it's pressed or not, and how long it's held.

#

I feel I might be doing too much by doing it this way.

tame oracle
#

Anybody knows why Release() is executed while I'm holding the OnScreenStick?
It seems like program thinks that I let go of the stick when the stick is centered (0,0). Is this bug?

austere grotto
#

canceled happens when the actuation of the stick reaches 0,0

austere grotto
#

If you did the same thing with an Xbox or Playstation controller it would happen teh same way

#

it doesn't know you're touching the stick just that it's actuated or not

tame oracle
#

It seems like I will have to change this control

keen thorn
#

I have "Jump" as input, but if i push my spacebar which should be connected to "Jump" it doesnt work... what do i need to do to fix it?

west oracle
austere grotto
keen thorn
#

Big brain, but how do i check that, i started like yesterday so i dont know.

austere grotto
keen thorn
#

wut

#

how does that work? xD

austere grotto
#
Debug.Log($"Jump detected: {Input.GetButtonDown("Jump")}");
Debug.Log($"Is grounded: {isGrounded}");```
keen thorn
#

do i need to put that in my code? or can i find it somewhere?

austere grotto
#

put it in your code 🤔

#

wdym "find it somewhere"?

keen thorn
#

im new, idk

austere grotto
#

it will print some information to the console

#

so you can see which one is going wrong

keen thorn
#

k

austere grotto
#

you need both of those to be true on the same frame for the jump to work

keen thorn
#

k, thank u

oak meadow
#

Hey I'm having problems with the Input System not working for me after I build my game. It works just fine for me in the editor.

Things I've Tried:

  • Use "PlayerInput" component with behavior set to "Invoke Unity Events" and "Send Messages" different times
  • Implemented the interface from generated C# file

Project Settings:

  • Player settings are in the image.
  • Input System Pack setting, I've left the Supported Devices empty and another time with them set to Keyboard&Mouse. Keyboard&Mouse input aren't working after the project is built.

Any help I can get would be awesome!

austere grotto
oak meadow
#

I have movement controls with WASD and get mouse position and clicks. My problem is that after I build my game, the input stops working. It is as though my keyboard and mouse aren't even plugged in.

#

The game works well with input as long as I am only playing it in the Unity editor and not a built version.

austere grotto
#

hmm not sure 🤔 I'd just google around

oak meadow
#

Alright, I was hoping there might be something simple that is commonly missed. Haven't found anything on google yet unfortunately but I won't stop looking.

austere grotto
#

Wish I could be of more help.

oak meadow
#

Thanks for taking a look 🙂

boreal thunder
#

Hi all, im not sure how to install the input system 1.1 from github into my project

#

i would like to get the SaveBindingOverridesAsJson(); into my project

austere grotto
boreal thunder
# austere grotto

I am not sure which link to use because when I do this I get an error

deft berry
#

you need to also make sure you have git installed

boreal thunder
#

I have git installed

#

I was able to add another git file

honest spoke
#

Hello, im very new to unity, could someone help me with input controls?

#

im not sure how to change/modify them

late geode
#

genuinely not sure if this is suited to this channel but im using the "new" input system and its a problem with my mouse so meh.

#

im trying to have an inventory slot that knows whether a mous

#

actually hold on ima try somethign

#

yeah ok no

#

im trying to have an inventory slot that knows when a mouse is over it. for optimisation its going to update a bool when the mouse enters and exits it, to determine whether its currently over the slot

#

ive looked up multiple ways to implement this and all seem to dead end at the same problem: it's insanely inconsistent. it appear completely random when the mouse is over it or not. the systems dont seem to rely on any collider so im not sure what its picking up as "over" the game object

#

for reference, ive tried inheriting IPointerEnter as well as mono onto the script, and using the relevanrt methods, and rn im also trying event trigger component with the relative setup

#

both seem viable online but both have the exact same issue. help anyone? :D

#

in case it's relevant, the slots are on an overlay canvas

#

i also heard something something Raycast hwen i was looking it up and i just unticked the canvas' "Raycast Target" box but it still randomly knew my mouse was over it as before, maybe cause im in 2D project setup? idk

#

nvm

#

my crosshair was blotting out the button so it seemed random because it only did it when the croisshair wasnt over

#

well i cant figure out how to disable interactions between my mouse and my cursor image (that's blocking out the button that needs to detect whether the cursor is over it). does anyone have any ideas?

#

they're on the same z axis but i tried moving the crosshair to Z 100 just to put it way behind the slot image, still nothing

austere grotto
austere grotto
#

Also ensure that you have an EventSystem in the scene and that you are using the correct input module (Input System UI Input Module)

late geode
#

that sounds good

#

i just quit for the day i’ll try that first thing tomorrow

boreal thunder
#

Enable preview package

glass yacht
remote umbra
#

Question, I am trying to set up the Input system package. I have it installed from the package manager, and I have regenerated registry package csproj files, but there is no UnityEngine.InputSystem.csproj in my project directory. Am I missing a step to import the system?

austere grotto
#

but it works

glass yacht
#

I'm installing a Unity version rn so I cannot check where it is, but there is a preference you can tick to generate Csproj files for packages

austere grotto
#

Yeah it's in External Tools

#

preferences -> external tools

remote umbra
#

Interesting, VSCode does not recognize the namespace though

austere grotto
#

what namespace are you using

remote umbra
#

using UnityEngine.InputSystem;

austere grotto
#

Pretty sure that's right - opening my project now

#

Is Unity recognizing it?

#

Just VSCode not recognizing?

remote umbra
#

It counts as a compiler error, so the project will not run.

austere grotto
#

If I check this box, it creates csproj files for all the Unity packages

#

including InputSystem

#

try that?

#

(and hit regenerate project files)

austere grotto
#

That shouldn't happen unless the package wasn't installed properly

remote umbra
#

That was the first thing I tried. It makes csproj for everything but InputSystem.

austere grotto
#

Seems like it's not installed properly somehow

#

Can you create InputActions and such?

remote umbra
#

Yep, I can create them and open the editor and add actions to them.

austere grotto
#

That's odd. I'd try uninstalling and reinstalling the package

remote umbra
#

Fair enough. I will see how that goes.

austere grotto
#

(unity may force you to restart a couple times to deactivate/activate the backends unfortunately)

remote umbra
#

Yeah, this is a pretty small project so loading time is inconsequential.

austere grotto
#

I'll just add this as a data point:

  • Using Mac osX
  • No UnityEngine.InputSystem.csproj in my project folder
  • Registry Packages unchecked in preferences
  • Input system works fine
#
  • Visual Studio not VSC
remote umbra
#

Okay, reinstalled the package, I also updated my VSCode integration to the latest as it was out of date. I see now that I have Unity.InputSystem.csproj. But I still cannot import UnityEngine.InputSystem. Or Unity.InputSystem... Wondering if there's something missing in the .sln

#

No, InputSystem is there in the sln, I am very confused why VSCode refuses to acknowledge it as a namespace.

austere grotto
#

I've never tried VSC personally so can't offer more help beyond that

remote umbra
#

That's fair, I remember having trouble with configuring VSCode when I first set it up. I'll restart my computer and give it another crack tomorrow. Maybe the answer is I need to switch to using Visual Studio.

#

Thank you for all your help. I appreciate it.

forest fulcrum
#

hey guys, i nknow the old input system had mousex/mousey framerate independent... does the new input system have framerate dependence for mouse deltas?

#

because if I multiply my input by Time.deltaTime, in the editor it's fine.. but on my build it's fast af

#

my mouse input *

wintry sphinx
sour otter
#

Hey guys! i got a quick question, while trying to make a quick laser-defender style game i used this code in update to instatiate a sprite of a laser, problem is, it spawns it infintely, this is the code : ```c#
{
if (Input.GetButtonDown("Fire1"));
{
Instantiate(laserPrefab, transform.position, Quaternion.identity);
}
}

#

it just loops infinitely even if im not touching the keyboard

#

for some reason this always comes out as true: ```c#
if (Input.GetButtonDown("Fire1"));

zinc stump
sour otter
#

ill look into it, thanks

#

even if i negate the statement it stills instantiates it :(((

zinc stump
#

That's not the problem with condition then. You should also isolate things and test them individually

sour otter
#

hmm it seems the whole function is working quite weirdly, ill rewrite it again

#

also should i use newer unity versions? or download the recommended

#

my version bugs out a lot, the layers dont stay in their place when i close and reopen unity

zinc stump
sour otter
#

ill look for it, thanks for the help !!

olive loom
#

which one is newer?...it says update but its a lower preview number?!

sinful warren
#

Im trying to add 1 health to my character if i press e but i dont know how to do it

sinful warren
#

ummm which one is new?

#

here ill just send my code

still topaz
austere grotto
#

(package manager)

still topaz
#

^ that

#

i also misspelled asset store

sinful warren
still topaz
#

Why is there a coroutine?

austere grotto
sinful warren
still topaz
#

can't you just do a

if (Input.GetKetDown(KeyCode.E))
currentHealth--;
austere grotto
sinful warren
#

while i was doing screenshot

austere grotto
#

Doesn't make much sense without the W either. What exactly are you going for

solar plover
sinful warren
still topaz
#

Guys, need help with something. I'm trying to do a Double tap to run in the new input system.
I set it up like so that Walk gives me a Axis based on Left or Right Arrow and Run is a Passthrough Button that triggers whenever i Press Left and Right with a Multitap of 2.

And it technically works. My issue here is that the Multitap doesn't work every time. It's as if i was pressing it too fast, or to slow, but i doubt i'm too slow because i'm legit tapping really fast my keys... I'm confused on what might be happening e.e

(ScreenShots Inc)

austere grotto
still topaz
sinful warren
still topaz
#

(PI = PlayerInput reference)

sinful warren
#

I tried that

#

i got this error

still topaz
#

set your current health to a float

#

instead of a int

#

float currentHealth;

solar plover
#

If it's intended to be int remove the fs from the code I posted.

sinful warren
#

ok

still topaz
#

I feel like my issue is gonna get lost :/

solar plover
sinful warren
solar plover
#

So I'm guessing no errors.

sinful warren
#

nope

solar plover
#

But you left Down

#

Meaning only on initial click

#

Remove Down from GetKey

sinful warren
#

ok lemme try

solar plover
#

To detect while button is held.

sinful warren
#

that sets the health to 100 instantly

solar plover
sinful warren
#

ok

indigo finch
#

Hi. I'm using the InputSystemUIInputModule, and now all my mouse pointer/click doesn't work
What's the right way to set this up?
Some forum post says to add Physics raycaster and whatnot but nothing works for me

indigo finch
#

Ok it works, setting it to use Both system and restart...

#

My UI buttons responds to the "enter" keyboard. How can i also make the "spacebar" to also press the button, without setting the spacebar's binding to "submit"?

indigo finch
#

Actually i remember this was the default behaviour. Now, only "enter" works for this. I cant seem to figure out what could have changed this

indigo finch
#

So i'm almost certain the space doesn't work since i moved to input system package

I tried adding this entry in the pic, but upon saving it just gets removed?

indigo finch
#

Listen mode also doesn't seem to work on any keyboard presses..

#

But input debugger detects it

#

Ok nevermind.... apparently i've been using/editing the default input setting which is in the package which is read only...
Created my own input setting and everything works properly

queen wind
#

Hi there,

I have some issue with the input system, let me explain my scenario first:

I have a little mobile game with a OnScreenJoystick (using Unitys OnScreenStick control) that moves the player. Additionally, if the user touches the screen, the player jumps.

The jump is of actiontype button and uses a Primary Touch/Tap Binding.

So, if the user taps somewhere on the screen, the player jumps. to not jump if the user touches the onscreen joystick, I'm using EventSystem.current.IsPointerOverGameObject, that works as expected.

However, due to the nature of recognizing a tap, there is some delay between the actual "finger is on the touchscreen" until the tap-callback is called. For some users that feels like a input is lagging, because touching and the actual jump is a bit delayed.

To mitigate that, I tried using Touchscreen/touch contact. As soon as the finger is on the touchscreen, my jump method gets invoked.

For whatever reason, EventSystem.current.IsPointerOverGameObject does not recognize anymore, that this touch contact is over a UI object. By that, if the user touches the onscreen joystick, the player also jumps.

Maybe I do something wrong with the setup or there's maybe a bug with EventSystem.current.IsPointerOverGameObject because on TouchContact is does not recognize that the contact is over a UI element.

I also tried iterating through Touchscreen.current.touches and use touch.touchId.ReadValue to feed any touch to IsPointerOverGameObject(touchId) however, they all report false, that the pointer is not over an UI object, but it should report true

Unity Version: 2020.3.14f1
Input System version: 1.0.2.

Does anyone have an idea, what could possibly go wrong?

#

Something to note: I feed the OnScreenStick into a Gamepad/Right Stick control and read the movement from there.

still topaz
#

I need some help. I'm gonna simplify my problem. So i have this 2d Platformer movement in a 1D axis. Anyone has any clue how do i setup the movement on the new input system so that he walks arround with a single tap of Left/Right but if i double tap it starts running in that direction?

#

this is what i have so far but isnt really working

#

(ignore the Max Tap Spacing, i was attempting to debug it, assume its default)

olive loom
#

Does Inputs.Player.Get().actions get references to the actions? Because when i try to do InputAction.RemoveBindingOverride it does not seem to actually do it

west oracle
#

BindingOverride's are not serialized to disk unless you save it as JSON or some such yourself

olive loom
#

and thats not even what i was talking about, but whatever

west oracle
#

lol sorry, question wasn't totally clear

#

are you saying RemoveBindingOverride doesn't actually remove it? or just that the old binding doesn't work when you remove it?

#

also 1.0.2 or the newer preview? (1.1-etc)

olive loom
#

1.1 prev 5

#

for the saving, but putting that aside

#

i rebind a key like this

#

and then remove the bindings cs if (inputAction.bindings[bindingIndex].isComposite) { // It's a composite. Remove overrides from part bindings. for (var i = bindingIndex + 1; i < inputAction.bindings.Count && inputAction.bindings[i].isPartOfComposite; ++i) inputAction.RemoveBindingOverride(i); } else { inputAction.RemoveBindingOverride(bindingIndex); }
like this

#

but when i load up a saved binding from a json

#

for example if i changed the running from shift to V

#

in the next run of the game, both V and shift will make the player run

#

even if i do RemoveBindingOverride on it, it will still have both of the keys set as the running ones

#

actually even without restarting the game and loading from json it seem sthat it will still use the set key alongside with the original one thonk

glad yoke
#

Hello
Could you help me to press a button in unity and an image appears

olive loom
#

@west oracle yeah so even without using load or save from json, the override key is still being used alongside the default one after pressing reset

olive loom
#

went on to use RemoveAllBindingOverrides instead and i think it works now, which is extra weird

olive loom
#

still doesnt seem to want to consistently reset bindings though

west oracle
#

have you tried enabling/disabling the affected action after removing the bindinmg?

#

i do remember some quirk about that being necessary if you were only removing a single binding - I don't think it ever became a proper bug report tho

olive loom
#

the action is disabled during the binding change

west oracle
#

enable/disable then

#

basically actions get bound to "Users" and its a hairy process that does it

olive loom
#

u cant actually rebind an action that is active, it yells at u

west oracle
#

yea

#

give the enable/disable a shot for now

#

i'll take a closer look at it w/ the new Preview 1.1 packages a bit later today

olive loom
#

toggle what though

#

the action is already technically being toggled

west oracle
#
        action.Enable();
        action.Disable();
        action.Enable();```
olive loom
#

what i still dont understand very well is composites

west oracle
#

i know it sounds dumb

#

anyway, i have no idea what they did w/ that system in previews

olive loom
#

yeah that doesnt work

west oracle
#

but in 1.0.2 it was just borked thoroughly

olive loom
#

im doing a similar thing already

west oracle
#

i ended up writing my own override/binding system

olive loom
west oracle
#

yep

olive loom
#

i wished they put a bit more thought on this input system

west oracle
#

Rene-Damm straight admitted on forums my way of dealing with the "Generate C#" thing was something they'd actually consider adopting

olive loom
#

it certainly has potential

west oracle
#

yea - its so close in many places

olive loom
#

especially since the old input was bare-bones as hell even for early 2000s games

#

i just dont like that most of the properties and fields it uses are strings

#

i feel like that would hinder performance

west oracle
#

99% of them get converted to objects

olive loom
#

the profiler also had some extremely derpy looking call for the mouse

#

where it goes extremely deep into callbacks

west oracle
#

yea - i'm neck deep in a project right now involving high end haptic response devices

olive loom
west oracle
#

so i'm struggling on whether to use Unity InputSystem at all or just put it in a background service

#

that can have reliable polling

olive loom
#

heheh

#

what i like though

#

is the events the new one has

west oracle
#

TL;DR the thing is strong enough to break your wrists and I don't trust Unity lol

olive loom
#

like a triggered event

west oracle
#

Actions are very nice - yea

olive loom
#

so you can just straight up remove update methods in a lot of code

west oracle
olive loom
#

what i need

west oracle
#

^ being able to override inputs like this is a huge plus too

olive loom
#

is a competent video explaining composites, how they work, and how to use them

west oracle
#

lol, i should make one

olive loom
#

heheh

west oracle
#

have you gone thru my inputsystem vids yet?

olive loom
#

not sure?
i went through a few samyam videos

#

like look at this

west oracle
olive loom
#

which one is marked "isComposite" and which "isPartofComposite"

olive loom
#

i apparently cut my index finger somehow on the keyboard today

west oracle
#

fo sho 😛 i made them in context of "I'm a coder that knows how to use old inputsystem"

olive loom
#

i barely used the old input

west oracle
#

#hazardpay

olive loom
#

haha

west oracle
#

i just finished assembling most of a flightsim chair

olive loom
#

but yeah, old system ,most of the functions i just ended up making my own

olive loom
#

tell you whats most dangerous though: assembling a cabinet alone

#

those "one hour to assemble" notes in the manual are an absolute lie

west oracle
#

anyway, c heck this out too

#

there's a more updated one if you want to poke at it, but it approaches rebinding very differently

olive loom
#

ah too many stuff HoloNotLikeThis

west oracle
#

but...in a sane way that supports local multiplayer with strongly typed classes

olive loom
#

what i need mine to do is FPS games

#

so any local multi-control scheme is not needed

west oracle
#

have funt rying to get the mouse to behave 😛

olive loom
#

oh u mean the random spazzing out it does?

west oracle
#

nah

#

old input system didn't do anything intelligent

#

new input system does too much

olive loom
#

how come thonk

west oracle
#

so you have weeeirrrddd deltas

olive loom
#

yeah

#

where it jumps randomly

#

or is that just my dumb code kek

west oracle
#

TL;DR though I suggest you handle input inside FixedUpdate

#

instead of Update with new inputsystem

#

(you can force it to poll only inside of FixedUpdate with a pref/setting or poll it manually)

olive loom
#

ive actually handled mouse input inside fixed update always

#

but some people here told me to do it differently in the new input

west oracle
#

Praetor? 😛

olive loom
#

let me check how i actually ended up

#

haha, maybe EyesShake

west oracle
#

i gotta go for a bit

#

Goodluck w/ stuff!

olive loom
#

have fun

#
private void OnUpdate()
    {
        Vector2 look;
        if(rawInput)
            look = GameManager.Instance.Inputs.Player.Look.ReadValue<Vector2>();```
#

yup, just in Update

olive loom
#

oh wow the whole action's binding including part of composites counts into the bindings count Disgust

#

@west oracle well, i found out why its getting the part of composite and not the composite, and how to compensate; for some dumb reason they ended up having the action.bindings include literally everything ,including the bindings inside a composite, and the composite itself; and since i grab the first binding part inside of a composite, i just return the index by once to get it's actual composite

#
bindingIndex = inputAction.GetBindingIndex(InputBinding.MaskByGroup("M&K"));
while(inputAction.bindings[bindingIndex].isPartOfComposite && bindingIndex > 0)
        {
            bindingIndex--;
        }
        isComposite = inputAction.bindings[bindingIndex].isComposite;```
#

honestly a very dumb way its done, but i can see the reasons

peak heath
#

Hello !
I have an issue concerning action map switching : I have 2 actions map that both have a move action that are connected to the same method, a simple context.ReadValue.
However, if I switch my action map while pressing the move input, sometimes my character will keep moving, sometimes he will stops. It's because canceled is called on the previous action map and started on the new action map. Do you know a way that could solve this ?
Thx for reading !

PS : I use PlayerInput.SwitchCurrentActionMap to do the swaping, in case it helps.

rose forge
#

Hi everyone, is there any "out of the box" way to implement button combos for a fighting style game? I understand how interactions work (tap/multitap/etc) but I dont see how to implement such a system using those.

olive loom
#

What do I need to use to detect when a player is trying to use touch controls? I need some kind of event call that switches touch UI on or off

frigid ridge
#

@olive loom I would probably start by checking the input debugger to see how it reacts to touches. I would guess it would show up as a input device, which you can most likely check the status of through input system.

olive loom
#

InputSystem.onDeviceChange seems to just default to Gamepad and thats about it

frigid ridge
#

Maybe touchscreen is detected very early?

#

Is it in devices?

olive loom
#

Do i need to use this one instead?

#

it doesnt stop using either of them though

#

when i go back to keyboard

olive loom
#

I cannot figure out how the heck to enable my touch input UI only when attempting to use touch...

wintry maple
#

Hi, I was wondering whether it is possible use a variable in unity as an input into steam games (so emulate a controller which steam can recognise). I would really appreciate if someone could point me in the right direction for how to do it. Its for an arduino project, although im using unity to process my data. Many thanks!

weary orchid
#

hey all, im a newer developer trying to design a fighting game style input, wherein each direction is mapped to a number, then on a button press the attack checks to see what the last three numbers in the list were, for example, a stick starting down and rolling forward is a quarter circle forward or a 236.

#

This all works perfectly on keyboard because each direction can only be called once because WASD are buttons

#

but upon switching to controller i run into the issue that ever tiny micro angle of the controllers left stick, starts a new input action, resulting in the action of pressing down, filling my list with 2's where it should only input one

#

until the stick returns to neutral and then pushes down again

#

any ideas or fixes?

#

thanks in advance

#

ideally i dont want to seperate out code for inputs based one one method or the other as everything is based around input actions

crisp gyro
#

@weary orchid dead zone

#

and a system that waits for a certain direction to stop registering before it can be registered again

weary orchid
#

the issue im finding is that each tiny little slightly different angle of "down" or (0,-1) can start and stop an entirely new input action even though its the same action and under a normalized vector 2

crisp gyro
#

oh boy

weary orchid
#

my apologies, i dont understand

crisp gyro
weary orchid
#

what i need is to declare that any angle within a certain realm can only be called once before the stick must reach a new, different angle, or neutral

#

but with my controller it seems to have say, 30 different spots in each angle each decimally different, even under a normalized vector2 they still cause a call and cancel

crisp gyro
#

yes

weary orchid
#

could i do that with deadzones?

crisp gyro
#

so

#

@weary orchid only 4 directions, right?

#

also

weary orchid
#

correct, combination angles are covered in my script, not that im opposed to reformatting

crisp gyro
#

would bottom left be (-1,-1)

weary orchid
#

yes

crisp gyro
#

so you already have it so that any value where, say, the x is greater than the abs of y is right, etc?

blissful comet
#

With the PlayerInputManager to spawn in players, is there a way to send a message to the player that gets spawned? I want the player to know which player number it is so it can show the right color

austere grotto
#

the PlayerInput component has a playerIndex or something like that

weary orchid
#

@crisp gyro i used a vector 2 for my movement, but the command inputs are handled by the input of say "LeftStick - Right"

crisp gyro
#

ok, so just to be clear

crisp gyro
#

your ploblem is that LeftStick-right is being fired multiple times in a row even if the player isn't moving the stick?

#

ploblem

weary orchid
#

pretty much, when they push down, the controller has, for example, 10 angles that send the input of, down, this means that when pushing the stick down, tiny micro adjustments in the "down" area of the input, causes multiple fires

blissful comet
austere grotto
crisp gyro
#

I would say make it so that the event fire doesn't directly get inputted to the list

#

only put it in the list if the previous event called was a different direction or (0,0)

#

right?

blissful comet
#

Is there a way to change where the PlayerInputManager spawns players or do I have to do that after they're instantiated?

crisp gyro
#

hopefully that wouldnt even affect buttons

weary orchid
#

yes, but, what if they return to neutral, and then do it again? which i cant seem to get to be its own action

austere grotto
crisp gyro
#

say

#

right neutral right?

weary orchid
#

yup

crisp gyro
#

uhhh

weary orchid
#

needs to input, 6,6

#

or

weary orchid
#

6,5,6

crisp gyro
#

as long as you can detect the neutral

weary orchid
#

which i cant figure out how to do

crisp gyro
#

dear god

#

new input system make head hurty

weary orchid
#

same

crisp gyro
#

cam't you do the poopy way and read inputs every frame or something

austere grotto
blissful comet
crisp gyro
weary orchid
crisp gyro
#

this is a bad idea

#

but can you call a method upon cancellation

austere grotto
weary orchid
crisp gyro
#

that detects the new current vector2?

#

so say you let go of the stick

#

on the way back to neutral, it fires and cancels the microangles or whatever

#

eventually when one is cancelled, the vector will be 0,0?

#

sounds suuuper messy

weary orchid
#

i may have to just check the vector 2 read and then only allow a given direction to fire once, until a new direction or lacktherof has been done

crisp gyro
#

basically yes

weary orchid
#

messy, but potentially the only way with the hole ive dug myself in

#

i will try tomorrow and check back in

crisp gyro
#

I cant think of a better way rn

#

seems like gamepad is just plain hard to work with in NIS

weary orchid
#

thanks @austere grotto and @crisp gyro

#

ill try that

crisp gyro
#

hope it works dude

#

get some sleep

weary orchid
#

will do

loud prism
#

Input.location doesn't have all the info available in iOS' CLLocation - in particular, CLLocation.speed. Is there any recommended way to get the speed from Input.location in a way that's more stable than finite differences between samples?

fallow dragon
#

I know that there are multiple ways to handle input with the new system. (Input Action Assets, adding input action variables, and directly coding the actions.)

#

What is the best way to do this. (The one that would fit most projects.)

austere grotto
#

There's no best way!

#

The best way is the one you're most comfortable with and works with your project

#

If you ask 5 different people they will tell you 5 different "best ways"

#

for example the best way in my opinion is to use InputActionReference directly in scripts that need input

frigid ridge
#

If you feel like you are limited by that setup for some reason, you can always peel the PlayerInput/PlayerInputManager layer back and do it yourself. Both of these rely on the public API.

leaden coyote
#

Is there any easy way to check for a key/button/click with the new inputsystem? Kind of how you do the PerformInteractiveRebinding()?
I have a textbox and would like for it to listen if a specific "next" key/button was pressed to continue.

random geode
#

Been watching a bunch of tutorials on the input system

#

Gotta be honest I just cannot wrap my brain around what is going on

#

If only I knew what questions to ask

leaden coyote
zinc stump
#

@random geode There are examples bundled in the Input System package, they can be installed from there in the Package Manager.

random geode
#

Yeah I gotta be honest I'm lost

#

I can't really understand how it is able to differentiate between different controllers

#

The input system manager that just spawns in player prefabs is okay until you want to have a second player take control of a character that already exists

#

Had a bunch of great momentum in development but it all just ground to a halt

#

Now you can't even control one player

zinc stump
#

There seems to be a lot of hits explaining the problem on "unity input system multiple controllers" search.

random geode
#

Multiple controller support versus multiple controller simultaneously support

#

Like it's one thing to be able to support multiple controllers, but another to support multiple controllers at the same time

#

For local multiplayer

zinc stump
#

That seems to be the key to separating controllers.

cerulean shoal
#

So, I am trying to make a rebindable key system. I followed a video and now am starting to redue my code to use that new input system (not unity's system). here is the code form my car input handler (https://pastebin.com/qv8T5zc2) (I slipt my scripts up so I don't have like one super long script. Problem is that now I get this error (CS0029 C# Cannot implicitly convert type 'bool' to 'float') how do I fix it?

random geode
#

I'm getting weird errors too

#

Unrelated thing entirely

#

But also getting weird errors

#

If I press WASD on keyboard I get these errors, yet the input still goes through

#

But if I execute the same command on controller, no errors

#

@cerulean shoal Does it reference a line in your code?

random geode
#

Yeah, guys I have no idea what the issue is

#

I have a Player Input Manager spawning in player prefabs

#

But for some reason the first player prefab I spawn in throws up two errors for every context phase

#

But it still executes the code just fine

#

The second player prefab doesn't throw up any errors

#

And also executes the code just fine

#

The line of code it is referencing as an error isn't looking like an error to me

#

Basically this is just "tell the player you're attached to tell us what input you got"

#

And it does that

#

But not before throwing two errors

#

The actual AnnounceInput method is even simpler

#

So I have no clue what's actually the issue

feral quartz
#

Hey there, could anyone help me with this FPS camera? I've checked many different tutorials but for some reason the camera is always snappy like this.

#

Here's the code:

    private void Awake()
    {
        if (!camera)
            camera = GetComponentInChildren<CinemachineVirtualCamera>();

        Cursor.visible = false;
        Cursor.lockState = CursorLockMode.Locked;
        cameraPov = (camera.GetCinemachineComponent(CinemachineCore.Stage.Aim) as CinemachinePOV);
        
        input = new PlayerControllerInput();
        input.Gameplay.CameraRotation.performed += RotateCamera;
        input.Gameplay.CameraRotation.canceled += RotateCamera;
    }

    private void RotateCamera(InputAction.CallbackContext obj)
    {
        cameraRotation = obj.ReadValue<Vector2>();
        cameraPov.m_VerticalAxis.Value -= obj.ReadValue<Vector2>().y * cameraSens * Time.deltaTime;
        transform.Rotate(0f, obj.ReadValue<Vector2>().x * cameraSens * Time.deltaTime, 0f);
    }
#

If I remove the delta time multiplication, it (sorta) works, but then the camera rotation would become frame-rate dependant. Is that expected?

random geode
#

The player is getting defined but Unity is still reading it as null somehow

#

Fixed by just doing an if(player != null)

random geode
#

Oooookie doke

#

Input system is driving me nuts

#

Any ideas why the Player Input Manager is indicating that a controller is active RIGHT after I press play?

#

It only happens in this project

#

I tested in another project and that does not happen

#

It's set to "join players when button is pressed"

#

But I can't get keyboard to join because (and I'm only guessing here:) the keyboard controls are already being taken by something

#

Never mind

#

Turns out I had another Player Input on something I should not have

#

My posts here are seriously a crash course in what not to do

#

Haha

fiery sky
#

i cant figure out how to use input system cause the controls they change in tutorials look different in my menus

chrome walrus
fiery sky
#

2 weeks old ;-;

#

i got the new input yesterday but i wouldnt assume they update that fast

chrome walrus
#

what part is not fitting your setup?

fiery sky
#

this is tutorial controls

#

this is the one unity show me

chrome walrus
#

And what are you missing? like whats the tutorial refering to?

fiery sky
#

the "player" thingy doesnt have it

barren monolith
#

How do I run my script in unity? I have created a script but nothing pops up in the console

fiery sky
#

i dunno where this would be

fiery sky
chrome walrus
barren monolith
fiery sky
chrome walrus
fiery sky
#

the player thing has the thing i need to write the code
i think ill just mess around tomorrow cause its too late for me lol

chrome walrus
fiery sky
#

yea its kinda annoying that literally every tutorial or guide or anything is different but ill figure it out eventually

#

i cant use terms if i dont know them as well btw

chrome walrus
fiery sky
#

it is the thing i needed to write the code, all i have to do is get it from somewhere else instead now

chrome walrus
#

thats what I mean with terms, i needed to write the code, that is not even a sentence. No offense, but we cant help, if you dont give more information. What is the player doing in the tutorial, what is the tutorial doing with it, do they open it and show whats inside, is it a script, is it an array?

fiery sky
#

they take the words that appear when they click player, and use it in some lines of code. how else the hell do i describe this

chrome walrus
#

what does player look like if the click it?

fiery sky
#

bro whatever i already said im done

chrome walrus
#

alrighty, see ya

misty locust
#

I went through the same bug, I had to restart Unity to get my control maps on that component (also re-added the component) I am confused about action events though.. seeing that for first time (most likely this is because you switched from normal inspector to debug inspector)

fiery sky
#

tysm it was me being in debug

#

i completely forgot i was in debug :D

molten hill
#

is there a way i can allow players to bind the mouse wheels to jump

#

like you can do in quake where you bind mwheeldown to +jump

ruby patio
#

Any recommendation tutorials for the new input system using c# and not the player input component? im quite new to unity. thank you in advance.

west oracle
misty locust
golden hatch
#

Could really use some help with creating an Input system, at the point my codes at I should be able to move my character around when I hit play, the issue is they remain frozen in place and nothing happens, I do have a rigid body and a collider setup, I am getting an error on the Unity console, a NullReference exception, images of it, the code, and my Input Actions have all been included in the below link, if anyone can help it'd be amazing because this is driving me crazy.

https://docs.google.com/document/d/1z0knZhNd_EsyE-zcTacNzVPR5JNJNIoQFaQ2k_QrVPA/edit?usp=sharing

austere grotto
austere grotto
#

you simply don't have a camera with the tag "MainCamera" in your scene

golden hatch
#

Adding the camera got rid of the errors, but the movement still doesn't work, sorry about pasting the code into the word document as well

golden hatch
#

So checking the Input Handler script during play, my Keyboard Inputs are being detected, it's just not moving my character

austere grotto
#

(not kinematic)

golden hatch
#

Holy shit you are amazing

#

Thank you

#

that did the trick

fiery sky
#

i dont see the Delta [Mouse] that are in most tutorials anyone help?

#

nevermind i found it

remote umbra
#

Hey, I have been having some trouble installing the input system package. My IDE marks "using UnityEngine.InputSystem" as an unrecognized namespace and my project won't compile

I have tried:

  • Regenerating project files
  • Reinstalling package
  • Committing to repo then regenerating files
  • Updating IDE interface package
  • Switching from VSCode to VSCommunity
  • Updating .net framework/SDK

Does anyone know any other things that would prevent the InputSystem from being recognized?

austere grotto
remote umbra
#

I am! I have some for linking to test files.

austere grotto
#

You need to add input system as a dependency

#

Same as any package

remote umbra
#

Thank you, I will try that.

#

Perfect, all set now. Thank you very much!

narrow acorn
#

What am I doing wrong? The method never invokes

public void Click(InputAction.CallbackContext ctx)
    {
        Debug.Log("aaaa");
    }
#

It works in update like that:

private void Update()
    {
        if (Mouse.current.leftButton.wasPressedThisFrame)
        {
            Debug.Log("update");
        }
    }
#

But not from the player input

#

Figured it out :P
You have to add the devices to the control scheme otherwise they won't get seen

marsh relic
#

Would I ask about this here?

blissful comet
marsh relic
#

searching the web for it now.

ocean granite
marsh relic
#

I see.. The inputs are still not working though.

ocean granite
#

In what way are they not working?

marsh relic
#

Its supposed to be connected to a script that applies force to a playerobject.

#

This script in the tutorial I'm following seems correct.. but the player input is not doing anything

ocean granite
#

Can you show the relevant code?

marsh relic
#

Ahh I figured it out

ocean granite
#

Isn't that causing a compiler error since movementValue isn't defined?

marsh relic
#

I didn't know to use this little circle dot thing to apply the actual input @blissful comet

honest spoke
#

Would someone be able to get in a VC with me and help me with something? im trying to port this mobile unity game to a different platform and ive never worked with unity before

full sparrow
#

aight that'll be my next read thanks. Wow that was a phenomenal link, t hanks.

open mantle
#

How do I override the methods of the new UI Virtual Joystick?

#

I get this error:
cannot override inherited member 'UIVirtualJoystick.OnPointerDown(PointerEventData)' because it is not marked virtual, abstract, or override [Assembly-CSharp]

austere grotto
#

Since that method is not either, presumably Unity did not intend for it to be overridden.

open mantle
#

I… don’t know if that will cause problems in the future but we’ll see

leaden echo
#

Hey y'all, I am seeing something strange in the Input Debugger trying to get a Super Famicom pad working through a USB adapter.

#

All of the buttons appear to be accounted for, and when I press the X & Y buttons I see event happening, however...

#

Value on all buttons stay 0 in the middle pane

#

Other buttons toggle 2 different button values to become 1

#

That's with just the B button held down

#

It's a real problem because I seem to be unable to create bindings using certain buttons.

#

In the test tab of the Windows Game Controllers properties window the inputs are all coming through properly (1 to 1)

#

Any ideas? Feels like Unity has its wires crossed on a few buttons somehow... 🙃

full sparrow
#

Okie doke, I searched and couldn't find an answer. The dang Input Action thing will only register one keypress at a time. Example: Holding A, hold F, release A, A action still hapening. The F doesn't even register. I'm following an in depth tutorial exactly so I know I've not done anything wrong.

keen lion
#

whats your code

full sparrow
keen lion
#

and before that?

full sparrow
#

sorry didn't know you'd want that

#

It's a value / vector 2 action mapped to 2D Vector / Digital Normalized WASD

deft berry
# full sparrow

you don't have to set each value of the vector like that, just do moveVector = context.ReadValue<Vector2>()
(this won't fix your issue, just simplify the code a bit)

i just noticed you are setting the z value to y so never mind, my bad

full sparrow
#

@deft berry It'll automatically translate XY to XZ?

deft berry
#

ignore me, i misread it lol

#

but you should show all of the code, not just snippets like that. Use a paste site like one of the ones in #854851968446365696

full sparrow
#

I would have if it were more than like 10 lines lol.

deft berry
#

is there nothing else in that class besides the two methods you've shown and the class variables?

full sparrow
#

It's commented out at this part of tutorial

#

the person is going through 'Player Input' Behaviours

deft berry
#

well you're not providing all of the context so how are we supposed to help you?

keen lion
#

yeah, we need to see your inputsystem mappings, check how are you debugging, check the context of your actions, etc

#

~~for the record, unity inputhandling is still atrocious and I would heavily suggest getting some alternative like Rewired lol ~~

full sparrow
deft berry
#

you don't need that "Press" interaction

full sparrow
deft berry
#

at least not for movement

full sparrow
#

I understand.

deft berry
#

You're also only using two values of the moveVector, so why not make it a vector2 and just set velocity.z = moveVector.y.

#

I'm pretty sure the issue is the Press interaction actually because it does not use the canceled callback. (someone can correct me if i'm wrong on this)

full sparrow
#

I'll check into that idk

full sparrow
#

:/

#

well this is beyond insanely stupid.

full sparrow
#

After wasting most of today I reverted to old input system. What an awful experience.

potent plinth
#

can anybody tell me how to make a keybinding system?

nimble nexus
# potent plinth can anybody tell me how to make a keybinding system?

As it happens, I wrote up a doc on how I implemented mine several years ago. Note that this is not necessarily the best way to do it, and you may find better success using a plugin, or just using more up-to-date Unity input methods, but it works (so far) for my purposes (Which is a 2D sidescroller).

If you're interested you can take a look

https://docs.google.com/document/d/1NPWXnFNbLgoJf_fx_4Qbu_QRpF76n3QqCjXy9xVfj6g/edit?usp=sharing

#

Also it might be a bit out of date in relation to UI, as I wrote it six years ago 😂

#

Still works in my 2021 project though

potent plinth
#

ill have a look tnx

exotic solar
#

I'm developing for XR and for some reason all the buttons except "menuButton" are functional. Ideas how could I debug what's going on? I wonder if some asset I'm using (like auto hand) is overriding something crazy, but have no idea how investigate it. Tips?

#

I remember seeing some sort of button mapper dialog but of course can't find it anymore...

#

Ah, XRI Defaut Input actions was the dialog. But unfortunately adding a menu button does nothing.

#

Humm, I may have the new input system and old direct XR code conflicted.

exotic solar
#

Solved. Misleading tutorials/forums got me side-tracked. Rewrote the entire script with the new input system and it's now working.

rocky loom
#

How do i use the Input System? (My Unity version is 2020.3.16f1)

timber robin
#

Unity has an extensive tutorial on it on their YouTube channel.

tame oracle
#

i'm trying to make it so when my stick is over 40% of maximum distance pushed it counts as a sprint instead of a walk, i set the deadzones to Unity Minimum to 0.401, and 4.02 to Unity Maximum so the deadzones dont overlap, but my character just walks no matter how much my stick is pushed...

#

Anyone have any clues?

The code receives it via:

// set target speed based on move speed, sprint speed and if sprint is pressed
float targetSpeed = _input.sprint ? SprintSpeed : MoveSpeed;    
#
public bool sprint;

public void OnSprint(InputValue value)
{
  SprintInput(value.isPressed);
}

public void SprintInput(bool newSprintState)
{
  sprint = newSprintState;
}
timber robin
#

You don't need to do anything fancy like that, just take the movement input as normal (Vector2 data), and check the magnitude of that vector. If it's greater than 0.4f, then you're sprinting.

tame oracle
#

This is from the Unity Starter Assets 3rd person Character Controller (asset store), so was trying to keep it true to it's own setup, but i could give that a shot (still pretty noob at coding)

visual solstice
#

Hey, anyone know how to detected whether a keyboard or a controller is being used using the new unity input system?
like if the player is using a mouse, I want to do one thing with the mouse's position vector, and if the player is using a controller, I wanna do another thing with the controller joystick vector

visual solstice
#

solved

dapper sinew
#

Hi all, I'm using the new input system and I'm trying to implement the example shown under "Polling Actions" here: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Actions.html#creating-actions

    //public PlayerInput input;
    public InputAction moveAction;
    public float moveSpeed = 10.0f;
    public Vector2 position;

    void Start()
    {
        //input.Enable();
        moveAction.Enable();
    }

    void Update()
    {
        //var moveDirection = input.OverworldActions.Movement.ReadValue<Vector2>();
        var moveDirection = moveAction.ReadValue<Vector2>();
        position += moveDirection * moveSpeed * Time.deltaTime;
    }

The thing is that I already have an InputAction setup that's being used by my Cinemachine camera and I want to use that. I generated a C# script for that InputAction but I get an null reference exception (Object reference not set to an instance of an object) when I try to use it to assign a value to moveDirection in Update(). The commented lines were my attempts to refactor the code for my usage. Is it better to have multiple Input Actions all handling separate things?

TLDR; How to poll using existing InputAction?

fossil walrus
elfin mason
#

are people doing more than something like this in their input system functions?

public void Move(InputAction.CallbackContext ctx)
{
    moveInput = ctx.ReadValue<Vector2>();
}

I feel like the heavy lifting needs to be done in update functions. maybe this applies more to physics related stuff

fossil walrus
#

Do you guys know if it's possible to get a UnityEngine.EventSystems.PointerEventData from the InputAction.CallbackContext ?

dapper sinew
dapper sinew
austere grotto
fossil walrus
#

If it's mean to be done in code

austere grotto
#

You can but it would be kind of silly because then you're just using the PlayerInput component as a proxy to reference the InputActionAsset, which you can do directly by having an InputActionAsset field or an InputActionReference field in the script.

dapper sinew
#

I'm looking into your suggestions, thank you!

amber wraith
austere grotto
#

I'm presuming you have a Rigidbody or some other code pushing the object down

amber wraith
#

I do yeah

austere grotto
#

so naturally on the way down your jump code is teleporting you up... fighting against that other stuff

#

and it looks like that

#

Are you using Rigidbody?

amber wraith
#

yup

austere grotto
#

The way to jump with Rigidbody is typically to use

rb.AddForce(jumpForce, ForceMode.Impulse);```
#

you want to work with the physics engine, not fight against it

amber wraith
#

Ok thanks, I kinda just used what i used for movement and thought it would work the same

austere grotto
#

if you're using translate for movement with a Rigidbody you're also... doing that wrong, hate to say it

amber wraith
#

oh, should I be using addforce for that as well?

#

I'm only recently getting into programming and the tutorial i found said to do it that way

austere grotto
crimson crater
#

How do i access the value of Movement? i tried controls.Game.Movement.ReadValue<Vector2>(); but i get a "Object reference not set to an instance of an object" error

austere grotto
#

seems like you're probably using the generated C# class file

#

you need to use the new keyword to create an instance.

crimson crater
#

Oh ok

#

thanks

#

i was wondering if it was that or not XD

#

it outputs nothing

austere grotto
crimson crater
#

how?

austere grotto
#

.Enable();

crimson crater
#

Thanks, it works now

#

Still don't understand why my azerty keyboard is working as a qwerty one

warped nexus
#

Looing through EventSystem, PointerInputModule, GraphicRaycaster, PhysicsRayCaster. I keep thinking this can't possibly be the right way to separate these. Why is the camera attached to the canvas/raycaster? What if the same canvas can be seen by multiple cameras?

#

Trying to figure out if I can make UI canvas elements work inside a VR app, with a laser pointer attached to the player's hand

austere grotto
#

GraphicRaycaster goes on canvases.
PhysicsRaycaster goes on cameras

#

GraphicRaycaster has an event camera field iirc

warped nexus
#

Canvas has an Event Camera field.

austere grotto
#

Ah canvas then

sharp knoll
#

pls help

warped nexus
#

The strange part is that the events that I would want to send to the UI (e.g. OnDrag) send events with coordinates in screen coordinates, rather than world (or relative to the canvas), so I'd have to fake this somehow.

sharp knoll
#

idk what happened

warped nexus
sharp knoll
#

idk

sharp knoll
#

how

dapper sinew
# sharp knoll how

Under the "Location" field there are three dots to the right. Click them and select a different folder.

I don't think there should be permissions issues but it's easy enough to check. Try pointing it to your Documents folder or something

sharp knoll
#

k

#

thx

glossy mesa
#

How do I get the instantiated prefab from the PlayerInputManager.playerJoinedEvent callback?

glossy mesa
#

Yep, but I want the prefab.

#

That's just a config object right?

#

Basically I want to control the instantiation myself.

#

And set up the colors etc.

#

(Whoever just had their message deleted it was because there is a bot that deletes anything with repeated characters)

glossy mesa
#

That's the prefab

austere grotto
#

right

glossy mesa
#

Sorry, I mean a reference to the instantiated object.

austere grotto
#

I'm confused

glossy mesa
#

I mean, what I really want is a player joined event

#

That doesn't create anything

#

Or... instantiates the prefab and tells me about it

austere grotto
#

YOu get a reference to the instantiated prefab in the event

glossy mesa
#

Really?

#

I'm pretty sure you don't

austere grotto
#

yeah - it gives you the PlayerInput component of the newly instantiated object, no?

glossy mesa
#

oh... oh whoops!

austere grotto
#

Ok so

glossy mesa
#

I thought it was a reference to the SO

austere grotto
#

the one you linked

glossy mesa
#

Okay, cool. I'm silly.

austere grotto
#

is a UnityEvent

glossy mesa
#

Beautiful.

austere grotto
#

and I linked the C# event version

#

they both give the component you want though

glossy mesa
#

Yep, you're right. Silly me!

#

Thanks

austere grotto
#

np

austere grotto
glossy mesa
#

No haha, just new to this

austere grotto
#

👍

glossy mesa
#

First day on new project

#

That someone else started

austere grotto
#

I've actually never used PlayerInputManager yet

#

You're doing local multiplayer?

glossy mesa
#

yep

austere grotto
#

cool let me play it when it's playable

glossy mesa
#

Client work

austere grotto
#

ah damn

glossy mesa
#

Unfortunately.

#

But I will let you know anyways... might just be a while

sharp knoll
#

idk how to do this pls help

bright aurora
stark fiber
eternal vigil
#
if (Input.anyKey)
{
    Debug.Log(Input.anyKey.ToString());
}

Hello, i want to detect what key i am pressing, but now it debugs true. Does someone know how?

frigid ridge
#

It can return multiple keys on the same frame though

ocean jacinth
#

https://issuetracker.unity3d.com/product/unity/issues/guid/1353866 Don’t know if there’s rules against posting links to issue tracker but in case anyone is having issues with the input system and has no idea why… I went through the pain of being absolutely certain it was an issue with the input system, it’s active now

bright aurora
harsh narwhal
#

Anyone have issue with touch and SLIDER?
If using the mouse the slider behave normally.
However if I use touch, the handle get selected but only move a little, not following the touch

sharp knoll
dapper sinew
# sharp knoll code

Are there any tutorials you're following? There are a tonne of great intro resources

#

But you can create new scripts by right clicking in the project window and then under "Create" there is an option for a new script

sharp knoll
#

yes

crimson crater
#

Can I rebind keys during runtime using the C# generated class? if yes how? if not, how can I rebind things like 2D vectors for movement?

harsh narwhal
#

Ok I found the issue with Slider...
Now... anyone have issue when using touch with data being sent to mouse also?

crystal veldt
#

Can't seem to get unity input system to work

#

literaly nothing happens

#

I can't even print to console

#

ive tried about every single setting

#

invoke unity events, send message

#

restart unity

#

button, passthrough mode

#

Vector2, etcetc

#

making player a prefab instead of a object

austere grotto
#

There are many ways to use the new input system, and all of them work a bit differently.

#

Hard to say what you did wrong

crystal veldt
#

I'm following a tutorial that's telling me to use the "player input" component with the input action

austere grotto
#

Yep that's definitely one approach

#

What else does it say

glossy mesa
#

It seems that PlayerInputManager is immediately deleting one of the player prefabs after creating it. Is this a thing?

glossy mesa
#

oh worked it out. What a dumb thing. It calls DestroyImmediate if there's no input device

#

What a pain in the arse

#

DestroyImmediate too, which is against Unity guidelines

chilly trench
#

So I have a game manager object that needs to know of the inputs when a new player joins the game. From what i've seen, I have to have the Player Input component on the Player Character prefab, and can't like programmatically control the events from the Game Manager, so it's aware of Player 1 and Player 2's inputs? or am I thinking wrong, and it would be easily possible?

crimson crater
peak hearth
#

i'm trying to use unity's new input system and i did similar to their official video but when moving the callback is only called once, it doesn't hold ?

austere grotto
peak hearth
# austere grotto you're being very vague, but generally the `performed` callback for an InputActi...

In this video, we are showing you how to create a cross-platform character controller using Unity's Input System!

Download this project here:
https://on.unity.com/39WT0iv

For more information about the Input System - click here!
https://on.unity.com/2MJnzj2

Chapters:
00:00 Intro
00:29 Input Manager
01:10 Installing the package
01:34 Using th...

▶ Play video
#

sorry

#

i have the same function and set up

#

as him

#

except his works fine

austere grotto
#

what's not working about yours

peak hearth
#

he shows an example of him moving it around

#

when i try to move, or even log the function call

#

if i hold it

#

you'd expect multiple logs right

#

i get like 2

austere grotto
#

His doesn't get called multiple times when he holds it either

#

there's no expectation of multiple logs

peak hearth
#

oh how is his moving then

austere grotto
#

he's writing to this rawInputMovement variable

#

and using that variable to move the character

#

so if there's no further calls it continues to use the previous value.

peak hearth
#

okay i seeee, is there a way to have it act the way i want to or do you recommend just writing the code to make it work like this

austere grotto
#

the latter

austere grotto
#

sort of the same style as reading Input.GetAxis in Update() in the old input system

#

which, by the way, is a perfectly valid way of using the new input system.

peak hearth
#

i assume the new style of doing it would be a bit more efficient though right?

austere grotto
#

It's not really about efficiency

#

The main benefits of the new input system are:

  • Better support for input bindings and different controllers
  • Better support for rebinding controls at runtime
  • Better support for local multiplayer
  • More options for input including polling, event-based, generated C# file, PlayerInput component, InputActionReference and so on.
crystal veldt
#

why do I have 2 users with keyboard 2?

#

I have one player with keyboard 1

#

and another with keyboard 2

#

only the keyboard 2 controls work

#

and they only control one player

west oracle
glossy mesa
# austere grotto The main benefits of the new input system are: - Better support for input bindin...

Hey, you mentioned "polling" here... So we just burned like 6 deveoper hours trying to work out how to poll a button (resulted in not being able to implement jump). After a deep dive in to the docs I have come up with this idea... Does this look right to you?

PlayerInput _playerInput;
InputAction _jumpAction;
InputAction _fireAction;

void Start() {
  var map = _playerInput.currentActionMap;
  _jumpAction = map.FindAction("Jump", true);
  _fireAction = map.FindAction("Fire", true);  
}

static bool IsDown(InputAction action) => action.phase == InputActionPhase.Performed;
static bool IsUp(InputAction action) => action.phase == InputActionPhase.Canceled;

void FixedUpdate() {
  if (IsDown(_jumpAction)) {
    // Start jump
  } else if (IsUp(_jumpAction)) {
    // Release jump
  }
austere grotto
austere grotto
glossy mesa
#

hm.

#

Yeah

austere grotto
#

and any frame that it changes value while being not 0

glossy mesa
#

But we want button down button up

#

Like Input.GetKeyDown and GetKeyUp

austere grotto
#

that's correct

glossy mesa
#

thank god

#

Why do they not include this in the docs

#

I also saw some of them doing FindAction("*/ActionName") or similar

austere grotto
#

the thing is - it's only correct if you're using a control type: button value type: float input action with the default interaction (no interactions)

glossy mesa
#

Too many colons hahah

austere grotto
#

the way performed and canceled work depend on the interactions you're using

glossy mesa
#

oh, right

#

Sorry, these are field: value

#

So there's something wrong with the abstraction layer?

glossy mesa
#

not sure, it's not my task. my colleague just got flustered and went home

austere grotto
#

ah

glossy mesa
#

so I'm trying to give him some help so he doesn't spit the dummy when he gets back to it

#

But like... there must be a way to get values out right?

#

what is the point of the thing

austere grotto
#

spit the dummy?

glossy mesa
#

hahah, sorry.

austere grotto
#

heh

glossy mesa
#

Didn't realise that was an australianism

austere grotto
#

Anyway usually for GetKeyDown/KeyUp situations I would just go event-based

austere grotto
glossy mesa
#

The problem is that that's like 10x more code

#

okay, we can do it in Update

glossy mesa
austere grotto
glossy mesa
#

ah, that's okay.

austere grotto
#

You set an actuation point

glossy mesa
#

Yeah, that seems sensible

#

Basically we just need to do this:

var input = new InputFrame {
  isJumpDown = // ...
  isJumpUp = // ...
  horizontal = // ... float thing here
  vertical = // ... float thing here
}
#

So doing that with events is not trivial at all

#

Also... the order of execution of events is not clearly explained... what if it happens after our script for example?

#

We'd have a one frame delay

#

Using events for input seems like a terrible idea to me, maybe I'm missing something?

magic dust
#

Hi, Here is my problem can someone help?

west cove
#

When people use Unity's new input system do they still use the update method for movement?
or do they use the event functions?

austere grotto
austere grotto
west cove
#

Does it make sense for a 2d platformer to have character movement be implemented under .performed?

#

For my little game I have the .performed starting a coroutine for movement and while the movement key is held down a loop in the couroutine keeps going.

austere grotto
#

so if you're just holding the D key for example, you will only get one performed event

#

You could certainly generate an input vector in performed

#

and then use that vector in Update() for movement

#

you'd have to also listen to canceled to detect when the button/joystick is released and reset to 0 though

west cove
#

Right now performed starts a coroutine that has a loop while keeps going while a bool movementIsHeldDown is true

#

then canceled sets that bool to false

austere grotto
#

why not just use Update

#

that sounds unecessarily complex

#

to avoid the overhead?

west cove
#

haha probably is. Came back to Unity after awhile of not using it and watched a video of the new input system. The video showed the use of the Event methods.

#

and I was trying to figure out how I could get my character to move while holding down the key rather than once

#

but I sometimes get a bug where my player gets stuck. It works 99% of the time but certain movement cause the object to stay still.

#

so I was thinking doing an implementation with update may fix that.

#

jw what people usually do and how the new input system is usually utilized.

austere grotto
#
Vector2 input;

void OnEnable() {
  movementAction.performed += HandleMovementInput;
  movementAction.canceled += HandleMovementInput;
}

void HandleMovementInput(InputAction.CallbackContext context) {
  input = context.ReadValue<Vector2>();
}

void Update() {
  transform.Translate(Time.deltaTime * input * speed);
}
#

Sometimes I do something like this^

#

but it might be simpleer to just do this:

#
void Update() {
  Vector2 input = moveAction.ReadValue<Vector2>();
  transform.Translate(Time.deltaTime * input * speed);
}```
#

Honestly I think event-based handling is much better for something like buttons

#

rather than a continuous thing like movement

west cove
#

Gotcha, yea I think im getting weird bugs just because of the nature of performed and cancel lol

austere grotto
#

e.g.:

void OnEnable() {
  jumpAction.performed += Jump;
}

void OnDisable() {
  jumpAction.performed -= Jump;
} 

void Jump() {
  rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
}```
#

that works fine

west cove
#

only thing with movement is when I hold the key down I used a coroutine.

#

Jump would work fine since its typically only pressed once.

chilly trench
sweet palm
#

Hello!

I'll try to be as succinct as possible.

•Pressing an action key will trigger my code on press and upon release.
•This happens when no interactions are set (default == press only)
•This happens when explicitly configured to Press Only
•I am using the Player Input component and OnAction(InputAction.CallbackContext context) functions (see example below).

So, if triggering this function would print "Attack" twice - once on press, and once on release.

public void OnLightAttack(InputAction.CallbackContext context) { print("Attack"); HandleLightAttack(); }

Any help would be appreciated!

austere grotto
#
if (context.performed) {
  print("Attack");
  HandleLightAttack();
}```
#

you will also generally get a callback for started and cancelled

#

but it depends on the interactions you're using

#

to make what's happening a bit more clear I suggest doing this and playing with it a bit first:

    public void OnLightAttack(InputAction.CallbackContext context)
    {
        print($"LightAttack phase: {context.phase.ToString()}");
    }```
sweet palm
#

Thank you for the help! It sucks to suck (referring to me of course). I might need a little time to digest that.

austere grotto
#

the new input system is pretty complicated - it will take time to learn the ins and outs of it

sweet palm
#

It seems that way - starting to question if I made the right choice instead of using the old system.

chilly trench
#

Sadly, I can't seem to add the following method as an event to the Player Input component 😦 . Most likely because when it's set to Invoke Unity Events it's looking for methods that use an InputAction.CallbackContext as a parameter. Was something updated with that type to support being able to tell if the context has been updated (i.e., if the event was triggered because button was pressed down or the button was released, instead of either)?

austere grotto
chilly trench
#

Also tried using Invoke C Sharp Events but doesn't seem to be any editor options when that is set

austere grotto
#

you should use CallbackContext if you want to use Invoke Unity Events

chilly trench
#

What I want is to be able to tell when a button is being pressed and when it has been released 😦

#

so that i know how long that it's been held down.

austere grotto
#

read the conversation we just had above

chilly trench
#

ok

austere grotto
#

Doing that and checking for performed and canceled will tell you pressed/released

chilly trench
#

Sorry, didn't notice the new posts lul apologies and will check it out

#

Hm, so I guess I can use that for the buttons. But Directions get kind of weird. For example, if I press and hold Left (A key) it registers Direction Started and Performed, then press and hold Up (W key) while still holding Left triggers a Direction state of Performed. Releasing either will trigger a Performed state, and then finally a Cancelled state once both have been released. Which feels awkward if I want to know if Left is being pressed and Up is being pressed.

austere grotto
#

So you can either use the events to populate a Vector2 variable (or bool variables or whatever you want), or simply poll the InputAction in Update to get the current value

chilly trench
#

Something like this?

        //Debug.Log("Direction");
        Vector2 inputVec = input.Get<Vector2>();
        upPressed = (inputVec.x == 0 && inputVec.y == 1) || (inputVec.x != 0 && inputVec.y > 0);
        downPressed = (inputVec.x == 0 && inputVec.y == -1) || (inputVec.x != 0 && inputVec.y < 0);
        leftPressed = (inputVec.x == -1 && inputVec.y == 0) || (inputVec.x < 0 && inputVec.y != 0);
        rightPressed = (inputVec.x == 1 && inputVec.y == 0) || (inputVec.x > 0 && inputVec.y != 0);
    }```
austere grotto
chilly trench
#

I want to know if the button is on/off

#

Also, unsure how to tell the Player Input component to call the OnDirection(InputValue input) method atm...

austere grotto
#
Vector2 inputVec;
public void OnDirection(InputValue input) {
    inputVec = input.Get<Vector2>();
}

bool leftPressed => inputVec.x < 0;
bool rightPressed => inputVec.x > 0;
bool upPressed => inputVec.y > 0;
bool downPressed => inputVec.y < 0;
#

wouldn't that work?

austere grotto
#

and it's set to:
action type: value
control type: Vector2

chilly trench
#

ok, sorry, i know you said that before, i just glossed over it.

#

and yeah i hadn't refactored the bools at the time.

#

the Send Messages is what I had on a previous attempt that worked, but forgot 100% how I set it up before

#

so at time of questioning I had it set to Unity Events as all tutorials I went back to watch said to do so

sweet palm
#

@austere grotto The subsequent question you are helping with actually found my solution by switching to SendMessage (at least for the time being). Thank you in general for being so helpful and patient, my dude.

unkempt oak
#

Hi, I'm using unity input system and I'm trying to use touch delta to rotate my player(look around) but the problem is that when i use my on-screen stick which is supposed to move the player around, it also rotates the player because touch is being registered even when I'm using on-screen joystick. Is there any way i can limit the touch screen delta to read touch delta from only the left side of the screen Or avoid reading the touch when I'm touching Ui components such as on screen stick or buttons?
I'm aware of the method where we put an invisible on-screen stick on the right side of the screen. But I don't want to use it because it doesn't feel natural and smooth to me

dusk snow
#

Hi people. How can i guarantee that AxisControl always returns between 0...1?

ornate lynx
dusk snow
#

It seems they are fixed. (For the gamepad class at least)

#

I can't seem to find anything related to min/max values

sweet palm
narrow cove
#

How do I get input from a pair of XR (left/right thumbstick) as vars for this: "private void Control(Vector3 move, float turn, float[] actions) "?

#

it needs: "moving vector (3D direction and length), an optional turning flag, and a one-hot action vector"

celest parrot
#

.

#

Don't think this is the right channel, gonna move it somewhere else

viscid wing
#

Hey all, I'm just trying out Bolt.. any recommendations for tutorials/videos on how to use the new input system with this?

#

I managed to work out keyboard input, trying to get xbox controller working now 🙂

glad perch
#

Hi, I have a problem with setting up my input bindings becose I have there only usages and Listen button dont works. -_-

upbeat coral
#

So im using the input system for a VR based project, but every time I try to read an input action, the main camera stops being able to look around the scene / detaches from the vr headset.

The end result is that when I move my head with the headset on, the scene moves with the headset.

The script is pretty lightweight and the camera issue does not occur if I remove the script as a component of the hand controller it is added to

using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;

public class VRActionBasedControllerHandler : MonoBehaviour
{
    private ActionBasedController controller;
    // Start is called before the first frame update
    void Start()
    {
    }

    // Update is called once per frame
    void Update()
    {
        controller = GetComponent<ActionBasedController>();

        float selectActionPressed = controller.selectAction.action.ReadValue<float>();
        float activateActionPressed = controller.activateAction.action.ReadValue<float>();

        if (selectActionPressed > 0.0)
        {
            Debug.Log("SelectAction pressed");
        }
        if (activateActionPressed > 0.0)
        {
            Debug.Log("ActivateAction pressed");
        }
    }
}
#

Does anyone have any ideas as to why this might be happening? The object that this script is added to does have an XR Controller (Action-based) component

#

nvm

#

it was because I didnt have the main project window as the active window

#

I had console log window active

glad perch
tame oracle
#

Hi all.

I have the New Input System set up, and i'm reading the Mouse Delta so I can activate a bool to say "Is Looking Around"

The problem is...mouse delta's don't register anything at all if you move them slowly, so if i orbit around my character slowly, it still registers as x0 y0 with a magnitude of 0.

Does anyone know a way around this? unless theres some sort of other way I can tell if the mouse is being used, otherwise ill probably have to ditch reading the input altogether...

vapid yarrow
#

This new system have different settings

#

What if the best for input system

#

Starter pack used send message

austere grotto
#

there is no "best"

#

there are many different and equally valid approaches

weary orchid
#

any ideas as to how one would pass in a context value such as .performed, when calling the method? for example my dash method only dashes if context is performed, but for a fighting game i need to have other ways of dashing other than the dash button, so how would i say "if (conditional here){Jump(performed)}

#

as unity requires a value for context but doesnt seem to accept anything ive given it

austere grotto
#

you don't need to create one

weary orchid
#

yes, but what if i want to call it, without them pressing the button

austere grotto
#
void OnDash(InputAction.CallbackContext context) {
  if (context.performed) {
    Dash();
  }
}

void Dash() {
  // Do a dash
}```
#

Just call Dash() when you want to dash from somewhere else

weary orchid
#

does that automatically act as performed for the context?

austere grotto
#

wdym?

#
void Dash() {
  // Do a dash
}```
#

there's no context

#

just a method that makes your player dash when you run it

weary orchid
#

i see what you are doing

#

nvm im dumb

#

Thanks for the answer!

glossy mesa
#

How is it that the PlayerInputManager can instantiate a prefab and return it to you before its Awake is run?

#

That should be impossible by my understanding.

austere grotto
austere grotto
#

So in PlayerInput's OnEnable() it triggers the notification from onPlayerJoined in PlayerInputManager

#

And I think the way Awake() and OnEnable() work is that for each component in the newly created object it runs both of those in a row:

#

So say your prefab has components:
A
B
PlayerInput

glossy mesa
#

Right, I need to move the component higher up

austere grotto
#

Then it might run things in this order:
PlayerInput.Awake()
PlayerInput.OnEnable()
A.Awake()
A.OnEnable()
B.Awake()
B.OnEnable()

#

that could be what's happening

glossy mesa
#

Well, they're already in the correct order

#

God I'm so unimpressed by this system.