#🖱️┃input-system

1 messages · Page 53 of 1

tame oracle
#

I can't just make 4 functions for each button and call there the Event to trigger that?

austere grotto
#
  1. Set up OnScreenControls as per the link above
austere grotto
#

what's stopping you

tame oracle
#

So I guess all the ways lead of converting my Input System to new Input system

tame oracle
#

This is the script that uses this Input Manager and here is my function

#

I want to attach the Left function to the left button and have the same effect like the left key on my PC keyboard

#

How can I do that if possible?

austere grotto
#

You can't really bind UI buttons to generating INput manager input in the old system

#

it's not flexible like that

#

you just have to call the same function from your button and from your input handling code

#

that's the only way

#

If you want something more sophisticated, you can upgrade to the new system

tame oracle
#

Ah... Ok

#

Thank you

kindred sparrow
#

how would I go about using the new input system for movement? since it only fires the events OnPress and OnRelease

#

for movement I need it to fire every frame that it's still pressed obviously

austere grotto
#

You don't have to use events

kindred sparrow
#

yeah, I saw that in one of my other scripts where I did some example project with new input system

#

hoped there was a cleaner/more readable way

austere grotto
#

still you will need Update either way

kindred sparrow
#

but I guess it will be still readable considering single responsibility principle (as in, the component only handles input in the Update())

kindred sparrow
#

would I reset the direction vector upon cancelled fired?

#

I'm not sure if cancelled was still fired if for example performed only fires if I pressed it for like 3 seconds but I released it prematurely after 2 seconds

austere grotto
#

if no interactions, then you'll get started/performed immediately, and cancelled when you release it

#

Assuming this is a regular button control

#

if it's an axis, you'll get performed every time the actuation of the control changes, except when it changes to 0, when you'll get cancelled

kindred sparrow
#

no, I mean, if performed only fires after 3 seconds pressed (I think it was done via processors)

will canceled be fired even if I didnt press it for 3 seconds (as in, I released the key before performed could fire)

kindred sparrow
#

eww

#

brb

#

yeah it does

#

that's not good

#

is there a way to check if it's "valid release of button/input"? 🤔

austere grotto
#

Use your own game logic and the default started/canceled stuff

#

if released/canceled came after whatever your threshold amount of time, do your thing

#

otherwise don't

kindred sparrow
#

you mean, cache Time.time upon performed and check Time.time with the cached timestamp and see if it's beyond threshold?

austere grotto
#

sure that would work

kindred sparrow
#

hold on

#

that would still not give the desired result

#

with the interaction (the 5s delay thingy) performed fires after the 5s

#

oh well

#

I guess I can still work with the interaction, but just need to check specifically (as we said above) on canceled

austere grotto
kindred sparrow
#

but what if you want such an effect

#

an example I could think off would be rolling/sprinting in Dark Souls

austere grotto
#

what effect

kindred sparrow
#

well

#

if you want to do something if button is pressed for longer than 2s

kindred sparrow
#

and if you're below, you do a roll

austere grotto
#

ok then use started to start the timer

#

instead of performed

kindred sparrow
#

and the rest to be checked in Update() it sounds

#
  1. check if key pressed (therefore cache pressed = 1 and pressedTimestamp = Time.time)
  2. check if Time.time >= pressedTimestamp + 3
  3. if yes, do things
kindred sparrow
#

is there a way to get the hold time via code though? as in, access the interaction properties via code

#

seems to be something like this

austere grotto
#

aren't you way overcomplicating this?

#

You get a performed callback

#

you can check whether that has happened yet or not

tame oracle
#

I installed the new input system and when I open my game in Unity Remote I can't press buttons or anything

#

But on my PC they work any ideea why?

hidden laurel
valid dragon
#

Do you know the Event System info that you can see if you select the input system at runtime. It used to show the currently hovered and clicked ui elements.
Switching to the new input system seems to have removed most of that info. Is that an alternative way to debug the ui+input system interaction now?
Here's how it looks with the new input system:

#

Here's what I'd like to see:

austere grotto
valid dragon
austere grotto
#

Not yet

valid dragon
#

Alright. Thanks for the confirmation.

frigid ridge
#

Appears to be pathetic in 2021.2

blissful comet
mighty ivy
#

am i right to assume you cant forcibly make a player leave via script?

mortal ridge
valid basin
#

Is there a way for the player input component to prevent cloning the input actions?

#

if there are more than 2 Player Input, it clones the InputAction

lunar drift
#

?

topaz galleon
#

Is it possible to use input action perform when mouse button is clicked and return the Vector2 of delta from start click position to actual position without adding code?

austere grotto
topaz galleon
#

😦

austere grotto
#

In the first place, a mouse click and the mouse position/delta are going to necessarily be two separate Input Actions.

topaz galleon
#

Yes, but I saw there was already implemented the wasd mapped to Vector2. So... I hoped for the simulation of controller stick with mouse

austere grotto
# topaz galleon Yes, but I saw there was already implemented the wasd mapped to Vector2. So... I...

Today we will use the new input system in Unity to add an on-screen joystick to our game. This works on both desktop and mobile phone devices.

Using an on-screen stick will pipe the values to a different control type, aka Gamepad stick, where we can then use an input action asset to read it's value in our script.

►📥 Video Source Code 📥
https:/...

▶ Play video
topaz galleon
#

yes

mighty ivy
#

like, an external event occurs and i want to take that player out of a game lobby

mortal ridge
mighty ivy
#

thats likely because you have way more skillz than me

#

i was one of the few people on the planet to like HLAPI 🙂

lucid tundra
#

How would you make a held interaction? I made one that sets the context to performed whenever the input is held, but that only sends it once per press. Why doesn't it repeatidly perform the action?

mortal ridge
lucid tundra
mortal ridge
lucid tundra
mortal ridge
lucid tundra
#

It'll only do another once I relase the control and press it again.

mortal ridge
#

For continuous sending you have 2 options

#

Set a bool when performed and check that bool in update and do your logic.

OR write an input interaction

lucid tundra
#

I've been doing the latter. That's where I've been trying this stuff. I assumed that was the only place you'd be using stuff like context.Performed().

lapis plover
# lucid tundra I've been doing the latter. That's where I've been trying this stuff. I assumed ...

I'm not expert on the new input system, but if you have it set up as a 'Button' event with a hold interaction, that interaction is not meant to give you continous input, it's just meant to trigger the event after the user holds the button for a predetermined amount of time, at which point it will trigger that event depending on the phase.

For the hold interaction the perfomed phase happens right after the player holds the button for the predetermined amount of time. So it really isn't meant to work for continous held input.

If you want continous input then what Mindstyler recommended about setting a variable and checking on update can work, you can set the variable to true on "performed" and to false on "canceled" which will give you that kind of behavior.

You could also use a value action type at that point since you can set it to be a ton of different types and you can then use the InputAction.ReadValue<>() function to get the current value of whatever input action you're checking

lucid tundra
lapis plover
#

Got ya, so you're using the context.performed to check and then doing the interaction that way?

hidden laurel
lucid tundra
hidden laurel
#

Hm. Well, there must be some way to send performed multiple times because value interactions do it, but at this point I'd have to dig throguh the code to see exactly how it happens.

lucid tundra
lucid tundra
lapis plover
hidden laurel
#

I don't really see how it could be, since again the Default Interaction on a Value action happily sends multiple performed callbacks even though it seems like there's no external effect that would cause it to reset?

lucid tundra
#

No, but that is a value action, so I have no idea how it treats those differently in this context.

lapis plover
lucid tundra
hidden laurel
#

The docs seem to suggest that even a Button action with a value control bound to it should resend performed when the control value changes? That sounds wrong, though, so the docs might be misleading.

#

If it is a Value/Button thing, making it a Value interaction that you treat exactly like a Button action (i.e. just use performed, ignore the value) might be a workaround.

lapis plover
#

^^^ I agree with tjm yeah, I don't see an issue with using the value if it works

lucid tundra
#

That's something to try. I'd still be sending a garbage value I don't need but I can live with that. I might have a look at it tomorrow. For now I've got a dumb bool that gets toggled of press and release that's checked in update.

hidden laurel
#

Looking through the code I don't immediately see any reason why multiple calls to Performed() wouldn't send multiple callbacks? I guess you'd need to step through and see what it does.

#

The only plausible situation I can see in which it wouldn't is if it thinks the executing interaction is not the active interaction for that action. But that seems unlikely.

#

But I can't actually find where the active interaction is set, so who knows.

hidden laurel
#

@lucid tundra Okay, based on the implementation of ProcessDefaultInteraction it seems like Process will only be called when the control value actually changes? If so then unfortunately you probably can't make an Autofire interaction from a button.

#

...and yeah, actually the docs for IInputInteraction.Process say that explicitly.

hard osprey
#

okay I have got to be missing something obvious cause I'm 99% certain I've done this before

#

I've added in every single binding in the input system for both Mouse and Keyboard and a gamepad and an xbox controller specifically just to be safe, and I double checked the input bindings by assigning them through the listening system and pressing the buttons physically on my gamepad

#

and it still only registers the mouse and keyboard input and not any of the gamepad inputs when I test the game

#

the controller debug even shows that its able to recognize the inputs happening

#

it just doesn't like, pass them into the game

#

does anyone know if there's something obvious I'm missing to add just basic controller support to the new input system

lucid tundra
gilded walrus
#

Hello!

#

Can you help me please?

spark pumice
#

you need to either enable the old system (by following the directions in the error message and changing the Player Settings) or change the way you're reading input to use the new system

gilded walrus
mortal ridge
austere grotto
mortal ridge
#

Might be

hearty flower
#

Hi everyone,
I'm trying to do custom binding, but actually, even when I copy/paste, the original one is working but the copy doesn't work at all, what could I possibly missing ? '-'

unborn lark
#

Why is my "User 0" using Gamepad even when i don't have my Contoller connected?

tidal sedge
#

You need to tell the UI where is going to be getting the actions, from Click or Click 1.

tidal sedge
tidal sedge
hard osprey
# tidal sedge What controller you using to test the game? what are your actions map look like ...

So I've managed to get most of the gamepad inputs working now, I believe there was an issue with it not swapping to the controller's control scheme setup, but now I'm having a completely different issue with the input system.

I'm using Xbox controllers primarily to test and the Player Input Component. The issue now is that my controllers are registering button inputs both on Press and Release, instead of only when pressing. Everything works as expected when using the keyboard for input, it's just that when using the controller for example if I try to pick up an item, I'll pick up one item when I press the button, and another when I release it, despite the input being set to only trigger on presses, and the code also only checking when the input is performed as a failsafe. And I've replicated this on other machines with other Xbox Controllers, despite keyboards working as expected there as well.

#

and the input action setup isn't exactly complex I'm just using the default button, though I've tried double checking by using the Press only interaction on it as well to no change

#

here's what that looks like just to be sure

hidden laurel
#

Just to check, when you say "Xbox controllers" you mean XBox One or XBox 360 controllers, right? Because on the remote chance you actually mean OG XBox controllers, those had analogue face buttons which could make things work differently.

hard osprey
#

lol we aren't using the Dukes

honest current
#

I am trying to change unity Input Manager Horizontal keybindings in script, is it possible? (old input system)

#

I understood that its only possible going manually in Edit > Project Settings > Input Manager

honest current
#

thought so, thank you

wraith root
#

Hi all, I'm attempting to make a custom InputDevice for the Input System. It's throwing an error that I think may be due to some bug in the Input System GUI itself - specifically, the lack of an icon image for a layout... I think

#

When I open Unity, I get the single line of output:

Joy-Con (R) layout registered

If I try to open the Input Debugger, though, I get several errors, but the upper end of the errors/tracebacks are all the same:

ArgumentNullException: Value cannot be null.
Parameter name: layoutName
UnityEngine.InputSystem.Editor.EditorInputControlLayoutCache.GetIconForLayout (System.String layoutName) (at InputSystem/Packages/com.unity.inputsystem/InputSystem/Editor/EditorInputControlLayoutCache.cs:151)
UnityEngine.InputSystem.Editor.EditorInputControlLayoutCache.GetIconForLayout (System.String layoutName) (at InputSystem/Packages/com.unity.inputsystem/InputSystem/Editor/EditorInputControlLayoutCache.cs:176)
UnityEngine.InputSystem.Editor.InputDebuggerWindow+InputSystemTreeView.AddControlLayouts (UnityEditor.IMGUI.Controls.TreeViewItem parent, System.Int32& id) (at InputSystem/Packages/com.unity.inputsystem/InputSystem/Editor/Debugger/InputDebuggerWindow.cs:727)
UnityEngine.InputSystem.Editor.InputDebuggerWindow+InputSystemTreeView.BuildRoot () (at InputSystem/Packages/com.unity.inputsystem/InputSystem/Editor/Debugger/InputDebuggerWindow.cs:586)
UnityEditor.IMGUI.Controls.TreeView+TreeViewControlDataSource.FetchData () (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/TreeView/TreeViewControl/TreeViewControlDataSource.cs:53)
UnityEditor.IMGUI.Controls.TreeViewDataSource.ReloadData () (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/TreeView/TreeViewDataSource.cs:54)
UnityEditor.IMGUI.Controls.TreeView+TreeViewControlDataSource.ReloadData () (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/TreeView/TreeViewControl/TreeViewControlDataSource.cs:25)
UnityEditor.IMGUI.Controls.TreeViewController.ReloadData () (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/TreeView/TreeViewController.cs:298)
UnityEditor.IMGUI.Controls.TreeView.Reload () (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/TreeView/TreeViewControl/TreeViewControl.cs:114)
#

Does anyone know why this would be happening, and how I could fix it?

thin tulip
#

how do i get the value from an axis action?

austere grotto
unborn lark
#

Mouse.current is null. How do i get the mouse position?

unborn lark
thin tulip
#

Ok, I was able to get the input working, but when I put the value in a debug log, it reads zero no matter what.

astral flicker
#

Bruh full stop

#

the new input system doest work with Unity Remote?

hidden laurel
astral flicker
#

That is so sad. thanks for the awnser

swift wagon
#

how do I make it return true if it pressing the jump button?

#

anyone?

timber robin
#

The same way you handled the Fire button?

tame oracle
#

how can I make tap and hold exclusive? so if a hold event is triggered, the tap isn't?

#

for the same action of course, e.g. lmb

austere grotto
tame oracle
#

two actions is fine, but the question is the same

austere grotto
#

You basically have to delay processing your "tap" until you're sure that it wasn't a hold

austere grotto
#

<@&502884371011731486>

wraith root
slow drift
#

Hey all, I'm looking for a solution, just needing a nudge in the right direction. What is the notion/code that allows you to swtich between one Player Object with an Input System to Another?

I have a car that works, and a player that runs, and I know how I'll pair them to place the player-avatar in the car (parented to a null), but... what function is there to let us "change focus" :/

spark pumice
#

that approach makes sense if the controls are pretty different for each one. If the controls are essentially the same, doing something else might make more sense. For example, enabling/disabling the PlayerInput component on each object depending on which one is active.

#

(assuming you're using PlayerInput)

slow drift
#

So, if they are similar, then it's really just switching States, and changing the Camera's parent?

#

Walking to Driving State? And then map new behaviors?

spark pumice
#

yeah

#

I mean, there's a million different ways you could do it, so if that's intuitive for you, go for it

slow drift
#

Thank for this, just realized (as it's a car script I aquired) that on a Tehcnicality both entities are engaged AND letting me move them untill I figure this out. Gotta find the function in VS that'll let me switch cameras.

IF I disable a script on an object before runtime, can I enable it via code if the script is sitting on there, just unchecked?

#

Prolly just change their Priority.

spark pumice
slow drift
#

So, better to start with it On, and then disable it right-away at runtime? (for my car in this example).

spark pumice
drowsy skiff
#

Anyone know how to create an input-based replay system? Or can point me in the right direction?

copper urchin
#

i am trying to control the cinemachine camera with the joystick on my controller but whenever i use joystick input the camera just spins around but it works fine when i use the mouse. its not my controller thats the issue cause the sticks work perfectly fine in every game i play

cobalt isle
#

hy guys

#

someone can help me?

#

I started using PlayerInput yesterday but I've been having some problems like it regarding MissingReferenceException

protected void Awake(){

manager = GetComponent<P_Manager>();

if(playerInput != null && gameObject != null){

medoAction = playerInput.actions["medo"];

}

}

private void OnEnable(){

//works

medoAction.canceled += ctx => SimpleFreeze();

// dont works

medoAction.canceled += ctx => manager.medo.SimpleFreeze();

}

private void SimpleFreeze(){

if(manager.medo != null) manager.medo.SimpleFreeze();

}

In the example above the code that checks if "manager.medo" is null before running works but the other one doesn't, I know that "manager.medo" is never null but if it doesn't check it accuses as null I would have something I can try to avoid so many "ifs" since i know "manager" or "manager.medo" is never null?

Sorry for bad english.

#

i shold verify in all call or have bugs on my code?

austere grotto
cobalt isle
#

I started using PlayerInput yesterday but I've been having some problems like it regarding MissingReferenceException

protected void Awake(){

    manager = GetComponent<P_Manager>();

    if(playerInput != null && gameObject != null){

        medoAction = playerInput.actions["medo"];

    }

}

private void OnEnable(){

//works

    medoAction.canceled += ctx => SimpleFreeze();

// dont works

    medoAction.canceled += ctx => manager.medo.SimpleFreeze();

}

private void SimpleFreeze(){

    if(manager.medo != null) manager.medo.SimpleFreeze();

}

*on  "dont works" (line 21) i get Exception from MissingReferenceException

In the example above the code that checks if "manager.medo" is null before running works but the other one doesn't, I know that "manager.medo" is never null but if it doesn't check it accuses as null I would have something I can try to avoid so many "ifs" since i know "manager" or "manager.medo" is never null?

Sorry for bad english.

#

allright?

fair siren
#
        public void OnAttack(InputValue value)
        {
            OnAttackInput(value.isPressed);
        }

I have this input which works fine, currently following the unity starter assets using a bool. the problem now where I want to get similar to Input.GetKeyUp , how do I achieve this?

mortal ridge
fair siren
# mortal ridge subscribe to .canceled

where would I add that? because the new Input is confusing on the starter assets is different from tutorials I've seen on YT shows a different approach then unity fps starter assets inouts

mortal ridge
#

best way to work with the new input system is to let it generate the c# class, then reference an instance in your script and subscribe to the events e.g. _myControls.Player.Fire.performed .cancelled etc

sudden lagoon
#

In new or old input system is there anyways to reset Keyboard values in webgl?

fair siren
mortal ridge
austere grotto
wraith root
#

Is there anyone here familiar with the inner workings of the Input System? I'd like to do manual processing on data I receive from a HID device before exposing it to the user, but I'm not sure how to go about that. I posted a thread on the Unity Forums here: https://forum.unity.com/threads/manually-processing-iinputstatetypeinfo-data-before-exposing-to-user.1208461/

#

At the moment the biggest issue seems to be moving data from the IInputStateTypeInfo structure to the InputDevice without exposing that data as an InputControl first

dense wraith
#

Hey, is there a way to get a keyboard input, even if the game is Minimized?

coarse path
nova fractal
#

hi everyone, I'm using the old input manager and I was wondering...in the deadzone field, is that supposed to be a number between -1 and 1? Or is something else supposed to go in there?

carmine umbra
#

how dose */{Submit} map to any buttons. On Switch the npad is not producing a valid {Submit} for the EventSystem

tidal sedge
#

What are you trying to do?

tidal sedge
#

How are you approaching the tap?

solemn drift
#

I'm using the generated wrapper class and an Input Reader Scriptable Object to send those signals to various scripts.

However I have one input that doesnt appear to be firing.

its the only input in its Action Map (a button to advance dialogue) but according to Debug Log messages I do have it enabled

#

(The SO is based off the one in the Chop-Chop Open Project, but it works fine for every other action)

#

Ok on checking with a debug button on all input maps, the Dialogue input map just is not responding

solemn drift
#

Anyone have any ideas?

mortal ridge
#

Have you maybe set it as value instead of button?

solemn drift
#

no its set as Button :/

solemn drift
#

i figured it out. I forgot to use SetCallbacks for the action maps i added in

topaz galleon
#

How to assign to InputActionReference an InputAction by code if it is not assigned by inspector?

#
    public InputActionReference input;

    protected override void Awake()
    {
        base.Awake();
        if (input == null)
        {
            CustomInputActionMaps iam = new CustomInputActionMaps();
            input = ;
        }
        input.action.Enable();
    }
hidden laurel
#

I mean, the class only has that one method so it's most likely that or nothing.

topaz galleon
#

it gives me nullref

#

input.Set(iam.Test.Action); like this gives error because input is null

#

InputActionReference.Set doesn't exist

hidden laurel
#

What version are you on?

#

Oh, wait, I see what you mean. If input is null then you can just create a new InputActionReference at runtime and as far as I know it should work fine.

topaz galleon
#

how to create a new InputActionReference?

thorny osprey
#

Hi! How can I read input from a PlayerInput script? Previously I did it creating a new InputActions and reading the actions, but I dont know how to do that with the playerinput

austere grotto
#

There's many tutorials floating around on the subject, and several ways to do it

thorny osprey
#

@austere grotto Well, yeah, but where :/

#

I have the playerinput component, I want to read from it. I dont find how

#

When I created the actions I did this, but i dont know how to replicate it

            movement = InputManager.inputActions.Player.Movement;
            InputManager.inputActions.Player.Jump.performed += DoJump;

            firstPersonCamera.SetActive(true);
        }
        private void OnDisable() {
            InputManager.inputActions.Player.Jump.performed -= DoJump;

            firstPersonCamera.SetActive(false);
        }```
austere grotto
thorny osprey
#

Already took a look to it. Nothing

austere grotto
#

It has code examples

marsh fractal
#

@austere grotto Do you know if InputActionReference needs some kind of special treatment when used in a class inheriting from NetworkBehaviour?

austere grotto
#

no

#

it doesn't

#

other than the fact that you should make sure you're only processing input on appropriate objects, such as those that the local player should have control over

marsh fractal
#

Alright, because I'm not getting any input readings from a Vector2 action for moving.

#

Could it be because the player prefab (containing the script with serialized InputActionReference) is instantiated via NetworkManager?

#

I had to enable the action...

tidal sedge
# thorny osprey Hi! How can I read input from a PlayerInput script? Previously I did it creating...

There's different ways to approach the inputs using the scripts, this is my personal approach:

public class PlayersInputs : MonoBehaviour
    {
        private Players_InputActions _playerInput;
        private InputAction _moveAction;
        private InputAction _lookAction;
        private InputAction _fireAction;

        private void OnEnable()
        {
            _playerInput = new Players_InputActions();
            _playerInput.Enable();

            _moveAction = _playerInput.Player.Move;
            _moveAction.Enable();

            _lookAction = _playerInput.Player.Look;
            _lookAction.Enable();

            _fireAction = _playerInput.Player.Fire;
            _moveAction.Enable();
        }

        public Vector2 OnMove()
        {
            return _moveAction.ReadValue<Vector2>();
        }

        public Vector2 OnLook()
        {
            return _lookAction.ReadValue<Vector2>();
        }

        private void OnDisable()
        {
            _playerInput.Disable();
            _moveAction.Disable();
            _lookAction.Disable();
            _fireAction.Disable();
        }
    }
tidal sedge
# thorny osprey I have the playerinput component, I want to read from it. I dont find how

if your using the Player Input Component this is how I do it:

private PlayerInput _playerInput;
private InputAction _moveAction;
private InputAction _lookAction;

 private void Start()
        {
            _playerInput = GetComponent<PlayerInput>();
            _moveAction = _playerInput.actions["Move"];
            _lookAction = _playerInput.actions["Look"];
        }

Once you have the player Input component attach to your player select the Input Actions Map of your liking.

thorny osprey
#

@tidal sedge With the PlayerInput Component, that actions["name"], do you know how it behaves it the same action its in two different sets? Cannot test it yet

#

For example, if you have a set for moving on foot, another in a vehicle, and have Look in both

tidal sedge
# thorny osprey For example, if you have a set for moving on foot, another in a vehicle, and hav...

If your using the Player Input Component you can only use One Action Map and that is normally the Player one; inside the action you can have a regular "Move" and another one called "MoveOnVehicle" and just called it like actions["MoveOnVehicle"] if there not sharing any similarity on the input actions(gamepad, keyboard,etc).

But if you like to have two sets with different "Move" behavior then I suggest have two different action maps and both of them being have there own generates C# script.

glass yarrow
thorny osprey
#

@tidal sedge Yeah! I have two action maps, like you have one for the player and one for the UI. Currently I'm using the UnityEvents so I can register in each Action Map action what I want, but cannot find how would I do it without using the inspector

#

This is what I currently do. But dont know how to add the event from code

#

And below that player collapsable its the other action map with the same things

tidal sedge
thorny osprey
#

@tidal sedge Sure, thanks!

zinc stump
#

@tidal sedge No reaction gifs, please.

tidal sedge
tidal sedge
thorny osprey
#

Oh, you use the SendMessages option, yeah, I can get a similar behaviour with the events, the problem was more about reading from another external scripts, but dont worry, I can use the event method, or your method to read in a script, and then make everyone else read from it. Thanks!

jagged wyvern
#

when I use the sendmessages behavior on input system how can I check if the action is "started", "performed" or "cancled"

austere grotto
jagged wyvern
#

useless system

tidal sedge
jagged wyvern
#

there's another way

#

with send messages

#

it's stupid that it has to be done this way tho

austere grotto
#

in fact it's basically bypassing the PlayerInput component entirely

jagged wyvern
#

I don't need to change the behavior

#

I can still use send messages

austere grotto
#

if you're gonna do that you may as well just use an InputActionReference directly

#

Or a direct reference to the InputActionAsset

jagged wyvern
#

what's the point of sendmessage then

austere grotto
#

Quick prototyping?

#

PlayerInput is useless in general in my opinion, unless you're specifically making a local multiplayer game

#

I don't use it.

jagged wyvern
#

i hate the new input system

austere grotto
jagged wyvern
#

there's no right way to use this stupid system

austere grotto
#

It's more like

#

there are 10 right ways

#

all with advantages and drawbacks

jagged wyvern
#

i just wish they sent more information to sendmessages

#

then i won't have to do extra work

stable coral
#

uh why doesn't
Keyboard.current.anyKey.wasPressedThisFrame
work in maximaze on play for me?

#

i see no reason for it not to work

#

ah nvm, it doesn't work if i enable maximaze on play during play mode

jagged wyvern
#

why is the description the same for 3 different interactions?

mortal ridge
jagged wyvern
#

pretty much the same

mortal ridge
wraith root
#

I think there should be more of an explanation as to how those differ - they sound very similar

jagged wyvern
#

indeed

mortal ridge
#

it describes perfectly what each one does though

jagged wyvern
#

no

wraith root
#

Sounds like HoldInteraction only requires the button be held, whereas SlowTap requires the button be released afterwards

mortal ridge
#

yes. as is written in the docs

wraith root
#

I'm still having trouble understanding the difference between SlowTap and Tap

#

The docs could do a much better job of describing why these are different

mortal ridge
#

slow tap has a different hold time

#

as it says

wraith root
#

I should not have to squint at the blocks of text for an extended period of time to understand them 😛

jagged wyvern
#

no different than tap

mortal ridge
#

you don't have to

jagged wyvern
#

cause you can just change the numer

mortal ridge
#

correct. but then you won't have the possibility to have 2 seperate actions

jagged wyvern
#

what

mortal ridge
#

slow tap and tap

jagged wyvern
mortal ridge
#

don't complain about features you don't fully understand

jagged wyvern
#

can't understand them if they aren't explained

mortal ridge
#

they are though

jagged wyvern
#

not really

wraith root
#

Not well enough

#

as you can see by the fact that multiple people are having trouble understanding them 😛

jagged wyvern
#

it's the users that are the problem

mortal ridge
#

what you need to know is written in the docs. what general knowledge you need aka what is slow tap and what is tap, is general knowledge which needn't be in the docs

#

slow tap is a slow tap where as a tap is a normal tap

#

which is faster than slow tap

#

i'm pretty sure the 'slow' would make that obvious

wraith root
#

I mean honestly your explanation there makes more sense to me than the one on the Unity site

mortal ridge
#

but that is general knowledge. this doesn't belong in the docs

wraith root
#

I suppose it's general knowledge? the docs should definitely have some kind of reasoning for why there are two identical classes though still

mortal ridge
#

2 identical classes?

jagged wyvern
#

tap and slow tap

mortal ridge
#

those are different though

#

literally

jagged wyvern
#

same functionality

wraith root
#

The descriptions are identical, with the exceptions of "and" (which is a typo), and "defaultSlowTapTime" versus "defaultTapTime"

mortal ridge
#

yes. cause there is no other difference that needs to be taken into account

jagged wyvern
#

hell wouldn't hold work the same way?

mortal ridge
#

no. cause hold doesn't wait for release

jagged wyvern
#

if you add a small timer to hold then it's technically a tap

mortal ridge
jagged wyvern
#

that's called bloat

mortal ridge
# jagged wyvern that's called bloat

and that's what i call not understanding devs. all the built in actions are frequently used by lots of devs. so why would everyone need to build their own solution if it ends up the same as every one elses anyway? that's not bloat

#

bloat is when there are features that are heavy and are only used by a small amount of people

jagged wyvern
#

I mean from what I see no one uses these interactions

#

there's enough info in the callback context to do these functions on your own

mortal ridge
#

slow tap on pc is less often used but super often on mobile

mortal ridge
vivid yew
#

so tell me
am i doing pretty normal for my own custom binding system?

#

oh wait

#

it was supposted to be moveInput.x on the right

#

but ignore that

#

aight, added it to static

#

Okay it works fast

#

O.o

hallow solstice
#

what???

wraith root
#

Is Unity itself complaining about it, or just VS/VS Code?

#

I've found that at any given time there's like a 50% chance of IntelliSense working in VS Code

mortal ridge
wraith root
#

yeah... it always seems to work fine with Python projects and such, it's only ever Unity projects I get this with 😦

hallow solstice
#

ok how do i use this

#

this makes no sense to me except for the triggering things and i don't know if it's even right

hallow solstice
#

the whole input system

#

I can tell how to trigger events but i don't even know if it's right

mortal ridge
#

well....if it's right they should do the things you want them to do

hallow solstice
#

Do I put the player input component on the player?

mortal ridge
#

i don't recommend using the player input component

hallow solstice
#

oh

#

welp there goes all of my knowledge I no longer know how to do anything lmao

hallow solstice
mortal ridge
jagged wyvern
#

player input is good if you aren't doing anything advanced

#

generating a c# class can make your code messy if you're a beginner

#

having to enable every single action

hallow solstice
jagged wyvern
#

haven't tried it but it doesn't seem too hard

hallow solstice
#

So playerinput would be fine for it?

mortal ridge
# jagged wyvern having to enable every single action

you don't need to enable every single action. you should only enable the ones you need.
if you need all from a specific action map, you can and should just enable the action map.
if you need all from all control schemes you can and should just enable the whole controls

mortal ridge
north sluice
#

I have an project with Input System all set up. I also have an object without rigidbody and a free look camera which works just fine. BUT, as long as I try to assign a rigidbody component to my object, I lose the ability to rotate the camera. It feels just a there no input or something like this. What could have been the problem?

#

Setting my Rigidbody to Kinematic fixes this problem, but thats not what I need.

hallow solstice
#

Ok

#

How can I edit an InputActions from script

#

for example get the next keyboard input and set a playerprefs value to it, and have a script that updates the InputActions to have that value for attack

tidal sedge
north sluice
#

@tidal sedge are you still here? If yes, I am going to be on in 5 minutes. Can you take a glance at my screen share, mic is not needed.

#

just realized there is no voice channel over here.

opal pebble
#

Hey guys,

I tried to use the new Input System but every times i push a touch the vector is not update (it stay at 0 0 0) and if i not print the controls i don't know why my var is null

Here is my code:

public int movespeed;
    private Controls controls;
    private Vector2 vec;

    void Awake() {
        Debug.Log("Initialisation Player ...");
        controls = new Controls();
        Debug.Log(controls);
    }
    private void OnEnable() {
        controls.Enable();
    }
    private void OnDisable() {
        controls.Disable();
    }
    public void OnPlayerMove() {
        Debug.Log(controls.Movement.PlayerMove.ReadValue<Vector2>());
        vec = controls.Movement.PlayerMove.ReadValue<Vector2>();
        Debug.Log(vec);
    }
    void FixedUpdate() {
        transform.Translate(movespeed * Time.deltaTime * vec);
    }```
austere grotto
mortal ridge
austere grotto
#

Which is not being called anywhere

mortal ridge
#

maybe external?

austere grotto
#

It's named as if they're expecting it to work how PlayerInput in SendMessages mode works

#

So I'm assuming that's the mistake being made

mortal ridge
#

true......

opal pebble
austere grotto
#

You need to subscribe to the performed event of PlayerMove

mortal ridge
#

or read it in OnUpdate()

opal pebble
#

So OnPlayerMove() is useless ?

austere grotto
#

Where you do .SetCallbacks(this)

#

Currently it is useless yes

mortal ridge
austere grotto
#

There's many ways to approach this

glass forge
#

Anyone know why UI buttons sometimes trigger two OnClick events when using the new input system?

opal pebble
#

Someone can told me what is the value of this input action

opal pebble
mortal ridge
opal pebble
#

i want to make a jump touch so i just need to know if the touch is press

mortal ridge
#

then subscribe to the event

opal pebble
#

But for read the value i need to know the value

#
{
    public int movespeed = 1;
    private InputAction move;
    private InputAction jump;
    public PlayerInput controls;

    private void FixedUpdate()  {
        Vector2 position = move.ReadValue<Vector2>();
        transform.Translate(position * movespeed * Time.deltaTime);

        Debug.Log(jump);
    }
    private void OnEnable() {
        move = controls.actions["PlayerMove"];
        jump = controls.actions["Jump"];
        move.Enable();
    }
    private void OnDisable() {
        move.Disable();
    }
}```
mortal ridge
#

but you don't need the value for jumping

opal pebble
mortal ridge
#

subscribe to the event

hidden laurel
# opal pebble is it possible to set him to 1 or 0 o directly a boolean

The triggered property of the action will do this (with caveats; in particular I believe it doesn't work in FixedUpdate unless you specifically set up the InputSystem to work in FixedUpdate rather than Update), but as Mindstyler says it's better to set up a callback function and subscribe to the events you care about; you're likely to have fewer problems in the long term if you do things that way.

tame oracle
#

After implementing the new InputSystem, buttons have become unclickable, they just won't interact when I put my mouse on them

austere grotto
tame oracle
#

nvm i solved it

#

I didn't have the mouse as a supported device

tidal sedge
opal pebble
neon needle
#

i cant grab the InputSystem class after installing it thru the package manger, am i doing it wrong?

tidal sedge
wraith root
#

Is there a way to map multiple controllers to a single player? I'm trying to use both the left and right Joy-Cons to control a single player via the Player Input component, but it looks like it may only allow the player to correspond to one of them at a time

wraith root
#

...just figured out I can just tell the control scheme it requires two copies of Joy-Con

untold sand
#

Guys, a little quick question. Is the Input System ready to be used in production/serious projects?

austere grotto
#

yes

tulip vessel
#

Hi all, I'm looking to make a 2D game right now and am looking to use the PlayerController.cs script in the InputSystem example project. Does anyone know Unity's take on using code/assets in their example projects?

Edit: This is the relevant repo https://github.com/UnityTechnologies/InputSystem_Warriors

jagged wyvern
#

i dont think they care

zinc stump
lunar flame
#

why i get this error?

#

as soon as i clicked on create actions, i got this error

tidal sedge
lunar flame
#

2020LTS

tidal sedge
lunar flame
#

maybe it's cuz of i didn't install other packages

tidal sedge
lunar flame
#

and also i disable some built-in packages like VR-AR and these kind of un-necessary packges

tidal sedge
cosmic peak
#

hi guys, does anybody know why the playstation controller wont work with the new input system?

#

Xbox controller works fine, but the PS controllers dont work..

jagged wyvern
#

ps3 ,4, or 5?

#

might need drivers installed

#

i know 4 works fine

cosmic peak
#

ps4

#

or ps5

#

both dont work properly

#

Movement with the Vector2 variable dont work

jagged wyvern
#

does your controller work on other programs

cosmic peak
#

yes

sullen badger
#

hi, somebody know what going wrong ? (it doesn't work,it always false)

mortal ridge
sullen badger
#

with the player input component ?

#

playerInputActions.Player.Phone.triggered don't work too

mortal ridge
sullen badger
#

ok i try

#

i put playerInputActions.Player.Phone.started/performed += buttonPhonePerformed; in the start method and the debug.log(context) on the buttonPhonePerformed method and it's not working :/

jagged wyvern
#

your input responses shouldn't have to be in update

sullen badger
#

so i put playerInputActions.Player.Phone.started/performed += buttonPhonePerformed; in update method ? 🤔

jagged wyvern
#

are you using the player input component?

sullen badger
#

on my player gameobject yes but this script is on GameManager gameobject

sullen badger
#

yeah so i need to use the event on player input component

#

i believed i can trigger a simple action on gameManager script 😢

jagged wyvern
#

do you know how unity events work?

sullen badger
#

yes my mouvement and jump are made with the player input component

#

but i think i don't know all i can do with the new input system

jagged wyvern
#

it takes some time to learn how it works

#

keep looking at tutorials

#

you won't be able to master it in one day

sullen badger
#

of course ^^

#

my main knowledge is based to the video of CodeMonkey

jagged wyvern
#

he doesn't cover everything

sullen badger
#

ok thanks

tidal sedge
sullen badger
#

oh thanks you ^^

mortal ridge
tidal sedge
thick ember
#

Hey folks!
Is anybody familiar with how the input system internals work?

#

I'm trying to study it for my own engine and to learn even more about game engines...

#

But I'm having a bit of a hard time figuring out how the event propagation happens

jagged wyvern
#

you could look at the git

thick ember
#

that is what i have been doing 😅

wraith root
#

I've learned a bit about building custom controller input stuff over the past week or so, but that's about it...

hidden laurel
# thick ember But I'm having a bit of a hard time figuring out how the event propagation happe...

I believe the very high level flow is: InputActionState objects register to receive IInputStateChangeMonitor.NotifyControlStateChanged events from the InputManager when their bindings change value; they pass those value changes on to their interactions which call methods on the InputInteractionContext to change action phase and trigger callbacks into user code. But if you want more detail than that, or anything about the InputManager-to-bindings side, you'll have to dig through the code yourself; I don't know much more off the top of my head.

thick ember
#

I'm mainly confused about how the composite works

lethal shadow
#

So im writing a VERY simple line of code, like click the mouse and say "click" kinda stuff, but it isnt detecting any inputs at all. but the default player character controller provided by unity works just fine. Anyone know why this might be?

#

Example

tame oracle
#

Have you tried somerthing like
(Input.GetKey(KeyCode.Mouse0)

lethal shadow
#

yeah still no response unfortunately

#

I am in HDRP but that shouldnt be an issue as far as i know, do other objects like UI maybe cause a disturbance to inputs? I tried looking at the input controller unity provided but they dont reference the mouse button at all so there shouldnt be anything else battling for priority

wraith root
#

Have you imported the new Input System? I remember hearing it disables the old Input System stuff

lethal shadow
#

i havent' imported anything manually but I am on the newest version of unity, is there a new way how the input system works?

wraith root
#

Yes, the new Input System works differently from the old one. It might auto-import the package; can you go to the Package Manager and see if there's a package called "Input System" in there?

lethal shadow
#

or is there a resource I can learn about how to use the new input system in C#

austere grotto
lethal shadow
#

originally it was attached to my character but i tried attaching it to just a general object in the scene and still nothing, and no no errors, but i did remake the scene in a earlier version of unity and it works so it does seem to be the new input system, is there a way to combine the two input systems or choose one over the other?

austere grotto
#

Yes you can choose your input system by selecting a setting for "Active Input Handling" in Project Settings -> Player

austere grotto
#

Also dumb question, but you did run the game right? Hit the play button?

lethal shadow
#

yeah, both of the objects were active at the time, and yes I was in play mode.

austere grotto
#

Can you show a scxreenshot of your console window?

lethal shadow
#

i might just be super unfamilier with the new input system, and yeah one sec

austere grotto
#

And yes this code is old input system code

#

so it's not going to work if you're using the new system, but you should at least get an error in the console

lethal shadow
#

well it does seem there are a new few errors that i didnt see before which is strange

#

although when i changed it to the old input manager it works perfectly with no errors

austere grotto
summer knot
#

hey all, I'm getting this error and I can't really figure out what's going wrong here:

#

can anyone help me out?

#

I'm using UnityEngine.InputSystem.XR

olive loom
#

does swapping to the input system have any performance benefits if i only have a single mouse click in the game?

#

Currently im just using Input.GetMouseButtonDown(0)

mortal ridge
olive loom
#

im guessing it wil even increase in size since the package is more complex than the barebones old input system

#

but im also wondering when they will just end up removing the old one so i can futureproof

mortal ridge
#

hopefully soonish

olive loom
#

eeeh hopefully not if its overall less performant

#

wish there were official stats on how much resources it uses compared to the old one

mortal ridge
olive loom
#

its certainly more flexible, not sure if more performant

vapid yarrow
#

Time.timeScale = 0f; does the input system still work ?

jagged wyvern
#

yes

vapid yarrow
#

not for me i had to update the code.

#
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;

public class Menu : MonoBehaviour
{
    [Tooltip("The menu panel")]
    [SerializeField]
    private GameObject _menuPanel;

    public static Menu Instance { get; private set; }

    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(gameObject);
        }
    }

    public void ToggleMenu()
    {
        _menuPanel.SetActive(!_menuPanel.activeSelf);
        if (InputSystem.settings.updateMode == InputSettings.UpdateMode.ProcessEventsInFixedUpdate)
        {
            InputSystem.settings.updateMode = InputSettings.UpdateMode.ProcessEventsInDynamicUpdate;
        }
        else
        {
            InputSystem.settings.updateMode = InputSettings.UpdateMode.ProcessEventsInFixedUpdate;
        }
        Time.timeScale = Time.timeScale == 1f ? 0f : 1f;
        AudioListener.pause = !AudioListener.pause;
    }

    private void Reset()
    {
        Time.timeScale = 1f;
        AudioListener.pause = false;
    }

    public void LoadGame()
    {
        Reset();
        SceneManager.LoadScene(0);
    }

    public void QuitGame()
    {
        Application.Quit();
    }
}```
olive loom
#

whats the equivalent of Input.GetMouseButtonDown(0) in the new system?

jagged wyvern
#

you aren't supposed to get a reference to the button itself

#

the new system uses "actions"

#

they're like events

#

basically each button triggers a method, and what happens in that method is up to you

olive loom
#

well im literally just using left mouse click and nothing else

jagged wyvern
#

you won't even need an update loop in your player class if you set it up

olive loom
#

im ending up using Mouse.current.leftButton.wasPressedThisFrame

jagged wyvern
#

i guess that works

#

might think it's held tho, im not sure

olive loom
#

seems to have worked

#

but damn, IL2CPP build of the game now adds 9mb with the new input system...

#

how do u have so much more stuff for an input system

jagged wyvern
#

lot of features

#

supports vr, phones, pen tablets

olive loom
#

i mean old input also does the same....just more boilerplate stuff

jagged wyvern
#

it's geared for heafty projects

olive loom
#

so i assume performance would also be worse then?

jagged wyvern
#

no

olive loom
#

🤔

#

u say no because u end up not using the update methods?

jagged wyvern
#

just projects that have complex controls

olive loom
#

hmm

#

well, runs pretty damn nicely

#

still find it hilarious it uses less cpu and gpu than watching a video

#

@jagged wyvern should i use that input actions file to swap out of the Update methods?

jagged wyvern
#

the file that was created from the controller scheme?

#

no, you make a new instance of it, and subscribe to the methods

olive loom
jagged wyvern
#

yeah

olive loom
#

do i need to manually add the input action stuff? i cant just do a new ?

#

never mind 😛

deep ether
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem.LowLevel;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Users;

    [SerializeField] PlayerInput playerInput;
    public Mouse virtualMouse;
    public RectTransform cursor;
    
    void OnEnable()
    {
        if(virtualMouse == null)
        {
            virtualMouse = (Mouse)InputSystem.AddDevice("VirtualMouse");
        }
        else if(!virtualMouse.added)
        {
            InputSystem.AddDevice(virtualMouse);
        }
        
        InputUser.PerformPairingWithDevice(virtualMouse, playerInput.user); // <= doesnt work (not allowing me to put playerInput.user. 
        
        if(cursor != null)
        {
            Vector2 pos = cursor.anchoredPosition;
            InputState.Change(virtualMouse.position, pos);
        }

        InputSystem.onAfterUpdate += UpdateMotion;
    }
    ```
not on unity rn so i dont have the actual error but does anyone know why this isnt working, Thanks.
austere grotto
#

really hard to say without the error message

deep ether
#

ill go and get it now

#

ill be back in 5mins

#

or more

#

idk

#

slow laptop

#

'PlayerInput' does not contain a definition for 'user' and no accessible extension method 'user' accepting a first argument of type 'PlayerInput' could be found

austere grotto
deep ether
#

nope

#

its called Input

austere grotto
#

What version of input system are you using

west oracle
#

Input might do it too 😛

grim prism
#

can anyone help me?

#

ArgumentException: Input Button Interact is not setup.
To change the input settings use: Edit -> Settings -> Input

#

cant figure out what unity wants from me

#

i never changed the settings

deep ether
deep ether
deep ether
austere grotto
#

Or Ctrl

#

Where does it take you?

#

Did you make your own script with that name for example?

deep ether
#

Thanks I figured out

#

I just lack iq

dense oyster
#

I'm using Unity 2020.3.1f1, by default it doen't have the options to create a input actions, when I install the new input system, the program launch this warning, I just press yes? or that will give me errors?

austere grotto
#

Press yes if you want to switch to the new system

#

If you have any code that uses the old system it will not work anymore and you will need to rewrite the input handling using the new system

low cedar
#

So I'm having a issue on android with screen touches get counted as the mouse and I was wondering if it's possible to turn that off on the input menu or if I'm going to have to go thru and change code to ignore Mouse entirely while on Android or IOS

#

I have gui touch control but my guy just spins and shoots consistently when pushing on the gui

austere grotto
#

I don't think it can be turned off in the menu but you can set this from a script

low cedar
#

I can't believe I couldn't find that on my own, thank you

austere grotto
#

It took me a bit

#

because i too was looking for a setting in the project settings

low cedar
#

That's what I was doing too and was starting irritate me as it's the last bug on my android builds

low cedar
#

Well or just disable the mouse in all and recode the controllers to use new input names and continue to allow those to move the guy I guess. I hate to have to recode a lot of my player controller but oh well

snow kelp
#

what Control Type is associated with scrolling the mouse wheel?

spice basin
#

int example = Input.GetAxis("MouseScrollWheel");

#

This will give a value from the range of -1 to 1 depending upon the mouse scroll wheel input while there is no input the value will be 0 and upon up mose scroll the value is 1 and for mouse scroll down it gives a value of -1

snow kelp
#

I think I found my answer. Vector 2 seems to work as the Control Type for a mouse scroll binding

olive loom
#

Why doesnt the method get called?

private InputControls input;

    private void Awake()
    {
        DontDestroyOnLoad(this);

        input = new InputControls();

        input.Default.LMB.performed += LMB_performed;
    }```
#

^ for some reason i had to do input.Enable(); - does it not start enabled?

austere grotto
#

Correct

olive loom
#

weird

sullen badger
#

hi i'm back with a UI problem x)
i have this

#

but it's not really selected (when i hover the button it work)

#

the eventSystem.setSelectedGameobject don't really work

turbid cedar
#

how can i make the inputfield return the text of it?

#

its always returning 0, i want it to return its text as string

austere grotto
turbid cedar
#

that On End Edit thing

#

afaik it shouldnt have that empty text box under it

turbid cedar
#

eh nvm

austere grotto
snow kelp
#

can someone please link me the API documentation for the new input system UnityEngine.InputSystem. I feel like an idiot for not being able to find it

hidden laurel
#

Unity Remote is not currently compatible with the new Input System; you should test on the device itself.

hidden laurel
turbid cedar
tidal sedge
#

For the UI are you using the On-Button Script of the new input system?

austere grotto
tropic sage
#

Does anyone have any sample code for a simple input system? I've been looking online on how to use the input system and every time i press a wasd key with the script and action map present, my sphere never moves

jagged wyvern
#

they got samples in the package manager

zinc stump
#

Input System package has examples in the description which can be imported.

plain rampart
#

Anyone can tell me what i need to do to fix this? I am using the Input system. If i press play and move the mouse then once loaded, my controls go crazy. If i leave the mouse above the play button it does not do it. I assume maybe i need to disable the input up until a certain point?

jagged wyvern
#

i have an input action set as a button but it sets attacking to true even if the button is held

#

how can i set it true only once?

#

use a coroutine?

#

I've tried adding an interaction but it doesn't work

#

nvm cancelling is overiding the perfomed action

#

not sure why

jagged wyvern
#

is there a way to check if started happened this frame?

#

does started and performed happen at the same time?

finite bolt
#

Does Unity natively support phone accelerometer input?

pastel geyser
#

im pretty sure it does

#

dont quote me on that

finite bolt
#

Cool cool, maybe I download a newer version

lapis quarry
#

any suggestions on preventing EnhancedTouch from triggering events when clicking UI elements? I've tried using IsPointerOverGameObject but it doesn't seem to work with OnFingerDown and throws warnings

teal ravine
#

anyone have any clues as to why my input system works fine in editor but when I build no input works at all?

tidal sedge
tidal sedge
tidal sedge
plain rampart
jagged wyvern
tidal sedge
narrow acorn
#

With 2 keybinds attached to a single action, is it possible to reset the action when a second keybind was pressed while the first was still being held?

What currently happens:

ctx.started
press K
Nothing
depress J
Nothing
depress K
ctx.cancelled```
What I want it to do:
```press J
ctx.started
press K
ctx.cancelled
ctx.started
depress J
Nothing
depress K
ctx.cancelled```
austere grotto
#

Simplest thing might be just to use two InputActions and handle the logic yourself

narrow acorn
#

That's what I thought, thank you!

lunar drift
#

hey im working on my little 3D fps game
my problem is that i want to detect when i tap W and the hold it
like in minecaft if u wanna sprint : ```tap W
Hold W

austere grotto
#

You basically need a small state machine:

[start] - tap -> [waiting] - tap within 0.5s -> [sprinting] - release -> [start]
                           - no input within 0.5s -> [start]
#

Actually you might need another state there where you need to release the initial tap within a certain time too to consider it a tap

lunar drift
#

okay i guess i understand thx

lunar drift
#

?

austere grotto
#

You actually need two states there

#

one for ButtonDown

#

then you get to the next state with a ButtonUp within a certian time frame

#

so like:
[start] -- buttonDown --> [waitforrelease] -- buttonUp within .5s --> [waiting] -- buttonDown within 0.5s --> [sprinting]

lunar drift
#

oh sry i was looking at mouse input

austere grotto
#

either way

#

MouseButtonDown/Up

tame oracle
#

so i can look up and down

#

but i cant look sideways

#

anything im missing out on?

#

i cant seem to figure it out

austere grotto
#

if they're the same you're just overwriting the first line with the second line

lunar drift
#

so how do i detect the buttonDown and release and the button down

austere grotto
#

Input.GetMouseButtonDown(0)
Input.GetMouseButtonUp(0)

lunar drift
#
if (Input.GetKey("up"))
        {
            print("up arrow key is held down");
        }

        if (Input.GetKey("down"))
        {
            print("down arrow key is held down");
        }```
tame oracle
#

ill send you my code

lunar drift
#

and just GetKeyUp and down?

tame oracle
#

and maybe you can see whats wrong

austere grotto
austere grotto
lunar drift
#

i know

#

but i just change keycode to w

tame oracle
#

no i mean

tame oracle
austere grotto
#

Doesn't matter

#

Why didn't you answer my question

#

I already told you the problem

austere grotto
#

You should try to get a clue

tame oracle
#

ahah

#

im just following this tutorial

austere grotto
#

Follow it closer

#

Make sure you put the script on the correct object(s) and organized the object hierarchy the same way they did

#

That code would make more sense like this:

transform.localRotation = Quaternion.AngleAxis(-_currentRotation.y, Vector3.right);
transform.parent.localRotation = Quaternion.AngleAxis(-_currentRotation.x, Vector3.up);```
tame oracle
#

ok wait wait

#

i deleted a line

#

and now i can look sideways

#

BUT NOT UP

#

BRAIN HURTS

austere grotto
tame oracle
#

do you know how i can fix that?

austere grotto
lunar drift
#

what does this mean You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings. UnityEngine.Input.GetKeyUp (System.String name) (at <6af207ecd21044628913f7cc589986ae>:0) CharacterController_src.WSprint () (at Assets/Scripts/Character/CharacterController_src.cs:234) CharacterController_src.Update () (at Assets/Scripts/Character/CharacterController_src.cs:89)

#

does that mean that i cant use Input.GetKeyUp("W") in the same script that use defaultInput.Character.Movment.performed += e => input_Movment = e.ReadValue<Vector2>(); (the input manager)

austere grotto
#

If you want to use both (I don't advice it for performance reasons), you can enable both in the project settings

#

I recommend simply writing all your code using the new input system instead

lunar drift
#

i get this You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings. UnityEngine.EventSystems.BaseInput.GetButtonDown (System.String buttonName) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/BaseInput.cs:126) UnityEngine.EventSystems.StandaloneInputModule.ShouldActivateModule () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:229) UnityEngine.EventSystems.EventSystem.Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:358)

austere grotto
#

It's a component on your EventSystem

lunar drift
#

?

austere grotto
#

there will be a button on it to upgrade it

lunar drift
#

i guess done

#

thx

hexed whale
tame wadi
#

Hi, am trying to use the new input system to control a rigidbody and its causing pain

#

i can get it to work with the character controller but id rather use the rigidbody

austere grotto
#

Show what you're trying, what you expect to happen, and what is happening isntead

tame wadi
#

this is the script im using

austere grotto
#

that's old input system

#

you're not using the new system at all really

tame wadi
#

Basically I wrote this before and trying to rework it, I had it working with the new input system for the character controller, but it doesnt exactly work with rigidbody

#

at least from what ive tried

austere grotto
#

Ok but whatever you're showing me right now you're not even using the new system yet

#

You're creating and enabling/disabling a generated C# class from an Input Actions asset, but you're not using it

#

anyway what about this isn't working, other than the fact that it's using the old input system still?

#

what do you expect to happen and what is happening instead

tame wadi
#

ehhh, if im not using the new one properly it makes sense

#

im using the new input system so i can use touch controls

austere grotto
#

You can use touch controls in the old system too, FYI

tame wadi
#

yeah ik its just i spent like 3 hours fucking around to get it to work with the new one lmao

#

and then I realised i needed to change to rigidbody and now im back to square 1

austere grotto
#

But you didn't really 🤔 because this is still using the old one

#

anyway 3 hours is nothing

tame wadi
#

No I had it working using the character controller

#

so it works, i just dont know how to make it work with rigidbody

austere grotto
#

Again

#

what are you expecting to happen

#

and what is happening instead?

tame wadi
#

nothin is happening, Im basically trying to get it to move corresponding to an onscreen analogue stick

austere grotto
#

Well this isn't going to read any onscreen analogue sticks

tame wadi
#

Yeah im realising that now lmao

austere grotto
#

You're using Input.GetAxisRaw which reads from axes defined in the input manager - it's old system stuff

#

You need to actually read data from your PlayerInput thing

tame wadi
#

sweet, ima just go back to scouring the internet lmao

austere grotto
#

Should be something like:
PlayerInput.<action map name>.<action name>.ReadValue<Vector2>()

#

to get a Vector2 for movement

tame wadi
#

hm

austere grotto
#

Assuming your action is set up as a 2D composite

#

but it's gonna depend how you set up your input actions asset

tame wadi
#

Okay, cheers

hexed whale
#

Hey guys. Is there any reason some layouts are not loaded on a specific build? i.e for Standalone I can't find AndroidJoystick or any of the sensors. Can I force them to be loaded? I can't see why it would be bad for them to be loaded, aren't they just JSON strings?

lyric mountain
#
  private void Awake()
    {
        inputManager.InputActions.Primary.Movement.performed += Movement;
    }

    private void Movement(InputAction.CallbackContext ctx)
    {
        ray = cameraComponent.ScreenPointToRay(Mouse.current.position.ReadValue());

        if (Physics.Raycast(ray, out target))
        {
            motor.MoveToPoint(target.point);
        }
    }```
So, I'm trying to get my controls working with the new input system, but I'm having trouble getting my left mouse and right mouse to function correctly. Well, they seem to fire off once correctly, but even after fooling around with all the binding properties, I've had no luck.
#

And after reading around, it seems the "hold" property isn't what I'm looking for.

#

Well, some threads have ways to make it work by forcing it to trigger through update, but that kinda defeats the purpose of this whole new input system, no?

austere grotto
lyric mountain
#

I've got an isometric game using left click for the primary movement. Clicking and moving is working, but when it comes to holding down the mouse buttons, I can't seem to keep getting the input working.

austere grotto
lyric mountain
austere grotto
#

Or just check in update if it's currently depressed

lyric mountain
#

Yeah, I see some code for doing that, but like I was saying. It seems odd this isn't implemented fully into the subscription system that seems to be the ideal of this thing.

austere grotto
#

Who said events were the "ideal"

lyric mountain
#

So technically I'm just doing a hacky way to implement how I had it in the old way.

austere grotto
#

Some things are suited for events, some are not

lyric mountain
#

True, even then some more control on how much I want to check for the position for these controls.

#

Overall, I guess I'm not checking 30 if statements anymore just for singular input so that's nice.

jagged wyvern
#

would using custom interactions in the input system work for making combo attacks?
like having to press a -> b -> y in succession

austere grotto
#

The best way to make something like that is using a state machine

jagged wyvern
#

ah alright

austere grotto
#

e.g.:
[start] - press a -> [waiting for b] - press b -> [waiting for y] - press y -> [perform attack]
Where you go back to [start] if the wrong button is pressed at any point.

jagged wyvern
#

makes sense thanks

lyric mountain
#

https://puu.sh/IwXfD.png
Am I not able to use the old event system with the new input system or is there something I'm not understanding here? Apparently there's quite a lot of work that needs to be done to get drag/drop and other pointer features working with the new input system, so for now I think I'd like to leave it for later.

spark pumice
lyric mountain
#

I've reverted back to old and back to both and it's still there. It's updated in the project settings so there's that.

wet kayak
#

The Unity Input System Guide for Installation is outdated. How do I get the newer versions of the Input System package installed? I have the project with proper .NET and a newer version of Unity, but it always just shows the older version of the Input System package.

#

Finally found it in some random post on the 1.2.0 version where someone else had a similar issue, so nevermind.

real bone
#

So, same question as in #💻┃code-beginner...
My button inputs appear to be triggered twice per frame, causing boolean flips (ex: running, crouching) not to trigger correctly.
How do I prevent this?

wet kayak
#

I'd double-check that Action Type is button, because other types process multiple times for...reasons. And then verify you didn't setup an event response along with the action response. I'm still learning about the new Input System a bit, but ran into that earlier and fixed it by checking those.

real bone
#

Well, as you can see in the screenshot, yes I have set the action type set to button. I'm not sure how I'd end up with multiple responses other than a duplicate Player Input component, but I don't.
So, I don't think that's it.

wet kayak
#

Probably because of the Behavior being set to events, then, perhaps. It processes the different stages of events instead of a single action response, I believe. If you changed it to "Send Messages" it may adjust that to a single button event. That seems only difference between mine and yours at the moment.

lunar drift
#

i have this function when i press tab defaultInput = new DefaultInput(); defaultInput.UI.Escape.performed += e => OpenSettings();

#

but it doesnt work

#

i even put a debug log there

#

this is the input map

lunar drift
#

in awake?

austere grotto
#

Sure

lunar drift
#

k

#

thx

vapid hearth
#

is there a limit to how many action can be in an action map cause after the fifth it stopped they stopped working

austere grotto
#

Not that I know of

marsh fractal
#

Does anyone have an idea why onDeviceChange doesn't fire at runtime but when I stop playing? And at seemingly random order.

#

Probably because it only fires at added or removed, right?

#

Or how would I go about recognising which device was used latest when not using PlayerInput?

marsh fractal
#

OnActionChange works, I can get the device from activeControl

late stump
#

How do I read a value by Invoke Unity Events?

public void Move(InputAction.CallbackContext context)
    {
        Debug.Log(context);
        
    }

marsh fractal
#

context.action.ReadValue<T>()

late stump
#

Is there any difference regarding performance in any of them?

marsh fractal
#

Probably, there's a lot of info provided by Unity, manual and such

#

You'll find it there

frigid ridge
#

Send messages require certain amount of magic under the hood to do what they do, especially for the first run. Unity Events are C# events with the editor support, so C# events are likely the fastest option, but also probably the least convenient one.

lyric mountain
#

Is there a way to receive what binding was pressed, or should I be making them separate actions instead? I've a lot more hotkeys coming so I'd prefer if I could do it this way somehow.

austere grotto
#

You can get the Control from a callback context but it's not pretty

lyric mountain
#

Ah, that's unfortunate. That's like 40 extra lines of code I've got to stuff somewhere now.

lyric mountain
#

Ok, so passing in the context menu I can use the control method which gives me a new inputControl of just the key itself which then you can use displayName to get the string value

#

fantastic

#

Actually the keyboard type remark there is concerning, eh

austere grotto
#

It's honestly going to be simpler just making separate actions tbh

lyric mountain
#

Yeah, I guess I'll just subscribe them all to one event method

lyric mountain
#

Not the prettiest but hey it works

quaint reef
#

anyone with an experience in making a decent input manager, using the input system?

hidden laurel
idle meadow
#

Hey, I would like to know your opinion about the solution they used in the open project to address player inputs, or maybe there's a better one ?

slim onyx
#

I'm trying to write some code to move my character and use animation, the animation is set and the character can move in a top-down movement way, but the animation isn't working, here's an image of the code, my animator variables are vertical, horizontal and speed, is there anyone that can explain or just show me what's wrong with the code, and really new to all of this?

idle meadow
#

Well, I don't know how you set up your animator, but if, as you said, you have a "speed" variable, you don't update its value in your code.

slim onyx
#

What code would I need to add for this?

idle meadow
#

first do you really need this variable in your animator ? could you show me a pic of it

slim onyx
#

yeah i think so, the other two variables are for movement, so the speed would be for the animation, so I think the speed variable would be good for making the animation go, I just don't know what code I need to add this in.

#

Heres the animator

#

When the speed goes up the animation should start, but it doesn't

#

like the speed doesn't go up, but I don't know how to add it to the code

idle meadow
#

ok so to update the speed variable you need to do like you did for Horizontal and Vertical:
animator.SetFloat("Speed",value)
you have to replace "value" with the variable that keeps track of your speed (but you don't really have one)
you could get the magnitude of your movement vector so something like that:

Vector2 movement = new Vector2(horizontal*moveSpeed, vertical*moveSpeed);
float speed = Vector2.ClampMagnitude(movement,1f).sqrMagnitude;
rg.velocity = movement

just note that clamping it is not really mandatory, depends on what you want

#

and then animator.SetFloat("Speed",speed)

slim onyx
#

Where would I place the code or doesn't it matter?

idle meadow
#

just replace the line 35 with what I said

slim onyx
#

The RB.velocity = part

idle meadow
#

yep

#

and replace it with

Vector2 movement = new Vector2(horizontal*moveSpeed, vertical*moveSpeed);
float speed = Vector2.ClampMagnitude(movement,1f).sqrMagnitude;
rg.velocity = movement;
animator.SetFloat("Speed",speed);
slim onyx
#

Like this?

idle meadow
#

almost, watch out for duplicated lines, you wrote twice animator.SetFloat(....

#

but not really a big deal

slim onyx
#

I don't know if I did it wrong but the game won't play and it says there is a compilor error, even after I'd erased that part

idle meadow
#

how my bad, I miss wrote .sqrmagnitude, replace it with .sqrMagnitude

slim onyx
#

Still doesn't seem to work, the part before is it supposed to be lf or if

idle meadow
#

oh no you mean between the brackets

#

it's 1f

#

just show me the error

slim onyx
#

Still says there is a compiler error?

idle meadow
#

show me it

slim onyx
#

The code or unity

idle meadow
#

the compile error

slim onyx
#

Theres another in movement

#

I don't think there's any others

idle meadow
#

no I mean the message explaining what is the error, you can see it in the console or at the bottom of the screen

#

you can open the console via the window tab / general

#

or by pressing ctrl + shift + c

slim onyx
#

I have it open although it doesn't seem to be saying anything

idle meadow
#

show me

glass yacht
#

Make sure errors are not hidden

#

if they are not, you should probably restart Unity and check again

slim onyx
#

I found them now, thanks

idle meadow
#

oh yep just missing a ";" at the end of a line

slim onyx
#

Can you tell which one?

glass yacht
# slim onyx Like this?

It should be highlighted in red here. If you're not getting errors underlined in red, or proper autocomplete you need to configure your IDE using the instructions in #854851968446365696

slim onyx
glass yacht
slim onyx
#

Doesn't matter, it says to modify with the installation, just didn't see it

slim onyx
#

What was the rg supposed to represent variable wise?

idle meadow
#

rb

#

yours is called rb, I'm used to call rigidbodies rg but in your case you called it rb so juste replace it

slim onyx
# idle meadow rb

Thank you, it works now, been going at it for like half a day, so thank you so much

idle meadow
#

no problem

floral echo
#

so what do i need to do with this

lavish bluff
#

The input system really should have something that registers input press/release/etc. on a FixedUpdate interval

floral echo
#

can i click yes

lavish bluff
#

If you want to use the new input system, yes

floral echo
#

whats the diffrence between the old and the new one

#

input is input right

mortal ridge
mortal ridge
lavish bluff
#

The solutions I've seen rely on creating a new bool called WasPressed or something and set it false every FixedUpdate, but that doesn't seem like it should be necessary

glass yacht
#

It is necessary to set a bool in update, and reset it on use in FixedUpdate

mortal ridge
lavish bluff
#

I see

mortal ridge
#

there are multiple solutions vertx

hidden laurel
glass yacht
#

You can do that, but that will also have knock-on effects if you want to process input in Update

hidden laurel
#

Right, if you want to mix and match then things will go badly.

lavish bluff
#

Really, I just wonder what's the cleanest way to incorporate the input system into a player state machine

#

Something like, hooking up an input action inside of a state and only run the code if it's the currently active state

#

Or hooking it up in the state machine and only feed the action into the state if the state uses the action for anything

lyric mountain
#

You'll have different action maps and enable/disable them where they apply

#

good system for what you want

hidden laurel
#

Yeah, that's how I've done it in the past. If the code to manage the enable/disable on entry/exit feels bloated or awkward I'd say that's on the state machine architecture, not the input system.

lavish bluff
#

Wouldn't that lead to having to repeat a lot of stuff?

#

Say you have a dash move that works both on the air and the ground

#

Then wouldn't you need to make a separate dash InputAction for the idle state, the running state, and the jumping state

lyric mountain
#

Well, say you have basic controls that work in any scenario, but you then jump so you enable with the basic controls with your air controls.

#

Lot of mix and match potential if you want to do it that way

#

I have action maps for a Main Menu, UI, Player. I've usually have both UI and Player active together, but they are disabled with the Main Menu are active.

hidden laurel
west oracle
#

I personally use InputSystem almost exclusively in the FixedUpdate mode, and selectively change it back to Update (or manually) as needed. Mostly just because most of my projects involve Time.timeScale and PhysX sims. varies from use case to use case.

lavish bluff
#

If the game doesn't use a lot of buttons, maybe it's okay to just give the base State class a method for each of them

#

Then each specific state overrides one of them if it uses the button

tropic sage
#

when i try using wasd, my cube can only go in four directions and never diagonally, how should i fix my code to allow this?

#

i've been researching online and this is what i have so far

austere grotto
tropic sage
austere grotto
#

No I mean the Move action

tropic sage
#

oh okay

#

so I have this in the enable function

austere grotto
#

No

#

The Move action

#

How did you configure it

#

In your input actions asset

#

Not the code

tropic sage
#

oh like this?

austere grotto
#

Yes that

#

Honestly the issue here might be a bug with having double bindings for that composite

#

And/or having so many bindings in general

tropic sage
#

should i take the arrow keys out do you think?

austere grotto
#

Try making an action that only has wasd composite binding

#

And none of the others

#

See if that works

#

Then you'll know if that's the issue or not

tropic sage
#

nah it didn't fix it

austere grotto
#

Unfortunately I've seen a lot of bugs around multiple bindings on an action in the new input system

tropic sage
#

I'm still wondering what the benefit of the new input system is besides events

#

because with these multiple key presses, it feels like it's impossible

#

do you think I should get rid of the move event subscription and just do the input.getkeydowns?

austere grotto
#

You can just poll the action in update

#

You don't have to use events

#

The main benefits of the new system are a better, more flexible API (note I didn't say simpler), runtime rebinding support, and strong local multiplayer features.

tropic sage
#

ah i see

#

time to strip my wasd controls ig

sudden lagoon
#

#💻┃unity-talk message
I have problem with input systems. Both Legacy and New input systems behave the same. If WebGL loses focus, it locks last button as pressed down. And when webgl get the focus back, it never resets. Only pressing button again it comes back, as button up logic is triggered. I tried Unity 2019, 2020, 2021, legacy and new input systems. Multiple different controllers, one of them is Unity provided example. Different background behaviors, from ignore focus to reset and disable all devices. I would be really happy if someone could end my suffering 😦

shrewd vapor
#

In the new input system, for the binding XRController.triggerPressed, I'm observing that action.cancelled is invoked not when the trigger is released but when the trigger is fully pressed immediately after action.performed. What am I doing wrong?

pearl dove
#

hey, anyone else had a issue where the new input system does not recognize the mouse? it's a collaborator project where the same mouse worked fine on another device - simulated touchscreen is working for any reason?

feral latch
#

Hey !
Is it good to stay that way with the new input system where it is better to stay on the old one? Personally, I am having difficulties with the new one, but I can't really decide what to do with it...

normal cliff
#

Anyone know why my UI button isn't responding to mouse clicks? I can click on things in the world by checking Mouse.current.leftButton.wasPressedThisFrame and doing a raycast, but my Unity GUI button does nothing when I mouseover or click it.
I have an EventSystem in the scene and an Input System UI Input Module as well, but they don't appear to be doing anything.

timber robin
west oracle
normal cliff
#

My buttons are interactable, they have 'raycast target' set... the input just never makes it to them. Is there something I need to do beyond just having an instance of the Input System UI Input Module in the scene?

austere grotto
normal cliff
#

"GraphicRaycaster on the canvas" - boom, that's the one. Thank you

olive loom
#

Why does the WebGL build doesnt detect input system multi-tap but it works for single clicks when it has no interaction modifiers?

tame wadi
#

Hi, having some trouble getting a reset button to work anyone have any idea how to make this work?

    public void Awake()
    {
        controls.Playermain.Touch.performed += SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 0);
    }
austere grotto
tame wadi
#

like uh

#
    void OnEnable()
    {
        controls.Playermain.Enable();
    }
    void OnDisable()
    {
        controls.Playermain.Disable();
    }
#

It says it cant convert type void to system action but idk how to work with that lol

austere grotto
#

Where does it say that

#

Oh in the awake thing

#

Because that event has a delegate type that takes a CallbackContext parameter and your lambda doesn't

tame wadi
#

Yeah

austere grotto
#

Best to lead off mentioning any errors you're getting in the future

crimson frost
#

So somehow the performed callback is triggering twice. Which I could work around, except that it's acting as if it's threaded?

private void Move(InputAction.CallbackContext callbackContext)
    {
        if (performed == false)
        {
            performed = true;
        }
        else
        {
            Debug.Log("NO");
            return;
        }
        Debug.Log("DO THING");
    }

So this should prevent it from triggering twice. But in console I get DO THING showing up twice.

#

performed is only being set to true in this one method, just for testing purposes.

austere grotto
#

Also what script is this attached to, and are you sure you don't have another instance in your scene?

crimson frost
#

Checking now for other instances, but the project is pretty bare bones so far

#

@austere grotto Just the one instance

austere grotto