#🖱️┃input-system

1 messages · Page 22 of 1

round vessel
#

How idfk

#

I got it

supple crow
#

I have some code that depends on being able to get InputUser.all[0] so that it can check your current control scheme. I discovered that this fails if I haven't yet created a PlayerInput.

#

Does this mean that there are zero users by default, and that each instance of a PlayerInput you create makes a new user?

#

(that you create at the same time, at least)

#

I am moving this PlayerInput into a DDOL'd object that I created as the game starts, so that'll fix my issue

#

but I am curious about how this is working

supple crow
#

ah, the user goes away when the PlayerInput component is destroyed!

supple crow
#

I am a little surprised now, though -- the input system worked fine in my main menu (including when I was subscribing to and unsubscribing from InputActions directly

#

I guess actions can be performed even if there are no players?

placid gazelle
#

there's gotta be a cleaner way to do this, right?

spare frigate
round vessel
#

How do I have more than one "north button" for mobile?

#

For me if I add two, they both will have the same function

austere grotto
round vessel
#

Image > On-Screen Button

#

This frustrates me and I had to like bind some buttons to east and south and stuff

#

Now I have 3 buttons that dont work

austere grotto
round vessel
#

I take up the button north south east and west

#

Right and left joystick

austere grotto
#

even Keyboard keys

#

mouse buttons

#

whatever

round vessel
#

No

#

How does that work

#

Tf

austere grotto
#

Just set the control path

round vessel
#

Aren't you suppose to link the control path with the method in input manager

austere grotto
#

What is "input manager"?

round vessel
#

Where u make the inputs

#

And add binding

austere grotto
austere grotto
#

you can bind keyboard keys to things there

round vessel
#

Not keyboard

#

Its mobile

austere grotto
#

these are just virtual anyway

#

it doesn't matter at all

round vessel
#

Will they work on mobile?

austere grotto
#

of course

round vessel
#

Ok so if I want a new button

#

Wait

#

What do I set

#

Do I set the on screen button to random

#

Or the asset menu

austere grotto
#

wdym random

ancient helm
#

hello everyone, I am facing a bit of a challenge here. I am using Unity WebGL to create a webgame and i wanted to copy some text to the user's clipboard, how can I do that?

ancient helm
#

Do i have to add this?

austere grotto
dull echo
#

I need some guidance. I am using the new input system and have a Reload function. How can I add a delay when reloading so it reloads after like 3 secs.

#

I have made a Coroutine but dont know how to start it.

tulip tartan
#

Make the reload method start the coroutine

tulip tartan
oblique jackal
#

Hey guys, im working in an inventory system and i'd like to be able to shift-click on some items and do things. I've tried this:

 button.RegisterCallback<ClickEvent>(e =>
            {
                if (e.button == (int)MouseButton.LeftMouse && e.modifiers == EventModifiers.Shift)
                {
                    OnShiftClicked();
                }
                if (e.button == (int)MouseButton.RightMouse)
                {
                    OnRightClicked();
                }
                else
                {
                    OnNormalClick();
                }
            });
    }

using the UIElements, but it doesnt really work. Any way i could get this working using the new input system?

austere grotto
#

Otherwise it's going to do both the shift click and the normal click

oblique jackal
#

the thing is that it doesnt even enter the functions

#

i have some debug logs on them but they dont really print

plucky path
#

Should I have a separate Action Map for different status conditions? (Example: Running, Swimming Underwater, Transformed, and First Person / Third Person controls)

spare frigate
# plucky path Should I have a separate Action Map for different status conditions? (*Example*:...

That may be up to your games needs, though I would say different maps make sense when input could override actions that should only be allowed in specific conditions (like having a "driving" or "flying" map different from a "running/on-foot" map since yaw/pitch/roll can be controlled with movement keys for example) - or when you want to split input in a way that lets you toggle parts (such as having a map for weapons/shooting, and a different one for movement, this means you can disable the weapon map when in a car, or disable the movement map when in a cutscene, etc) - in general though, I usually have a main "player", "menu" and feature specific like weapons, driving, etc, I wouldnt have a different one for something like swimming and running, but maybe underwater works differently

crystal dock
#

Bug. Any help? If I touch on my samsung s23 ultra and untouch the touch still remains like invisibile cursor. In this test you can see. I used two finger and lifted up and it remeans like I would still touch it and buttons get hover states (twice because 2 fingers). Remember when they get red my fingers arebnot on the screen.
Any idea or fix?
EDIT: Tested with the old input system.. there it works. Not with the new one. I guess its a bug

lucid pilot
#

I have a script that is using Mouse.current.position.ReadValue()

The script is working perfectly fine on my desktop, but when I switch to my laptop, it starts throwing a NullReferenceEception because there is no mouse plugged in.

Any clue how to fix this?

hasty quartz
lucid pilot
#

That is the new input system

austere grotto
#

so Mouse.current is null

#

you will want to check if you actually have a mouse before using it

lucid pilot
lucid pilot
#

Ok, I’ll let you know

lucid pilot
frozen mauve
#

Hi guys, pretty confused about the new input system's rebinding feature here, the action to rebind is referenced by an InputActionReference, but the rebinds does not apply to the instance I created...

#

Was I meant to be using a specific instance somewhere? One that likely all InputActionReferences points to at default?

austere grotto
#

the rebinding only applies to the specific actions you rebind in your code.

frozen mauve
#

Which means that it had no way to know the instance I created at runtime

austere grotto
austere grotto
#

You wouldn't use IAR if you want to reference something you created at runtime

frozen mauve
#

So the only logic is that either I fetch the runtime one and rebind that one, or there must be some sort of singleton somewhere that the InputActionReference references

austere grotto
#

it's not a singleton

#

you chose to reference something

#

that's what it references

#

I fetch the runtime one and rebind that one,
If that's the one you're actually using for controls in your game, yes you would do this

frozen mauve
#

Basically, was I meant to do this?

public static MainInput input;

    void Awake()
    {
        input = new MainInput();
    }
austere grotto
#

wdym by "was I meant to"?

frozen mauve
#

It makes a new instance

#

The rebind had no way of knowing that instance's existance

austere grotto
#

Ok but what do you mean by "meant to"? There are many ways to use the input system. This is one of them

austere grotto
frozen mauve
#

And the InputActionReference's reference can be run normally, so it must be an instance in of itself

austere grotto
#

and yes, every copy of the actions asset is an instance, of course.

#

by definition

frozen mauve
#

So I'm questioning whether this way of creating new instances was meant for splitscreen type stuff, while there's actually a main somewhere

austere grotto
#

but you could do this for splitscreen if you want to

#

again the system is flexible, and you can use it however you wish

frozen mauve
#

So... In a nutshell, this is normal, right?

public InputActionReference inputAction;
InputAction action = GlobalPlayer.input.Player.Get().actions.Single((InputAction action) => action.name == inputAction.action.name);
InputActionRebindingExtensions.RebindingOperation rebindOperation = action.PerformInteractiveRebinding(bindingIndex).Start();
#

Essentially I'm fetching the action with the same name as the one assigned

austere grotto
#

There isn't really a "normal". If GlobalPlayer.input.Player.Get().actions is how you fetch your instance of the actions asset that your code is using, then sure this is the way to do it.

I would guess it's more likely that GlobalPlayer.input.actionsAsset or whatevert is a simpler way to get at it though

#

Don't remmember exactly if that's what it's called on the generated C# asset or not

frozen mauve
#

What is that one meant to do?

#

The actionsAssets

austere grotto
#

get a reference to the InputActionsAsset

#

But I don't really know what all the pieces of GlobalPlayer.input.Player are because this is your specific project code that I'm not familiar with

#

so I'm making educated guesses here

frozen mauve
#

GlobalPlayer = PersistentPlayer, a singleton
.input = A new instance of MainInput created on Awake
.Player = The name of one of the actionMaps

#

Uh, now that I think about it, I shouldn't assume the action map used

austere grotto
#

OI assume MainInput is the name of your INput Actions asset and the generated C# class created from it

austere grotto
#

if you want a specific action from a string it's basically myInputActionAsset["MapName/ActionName"]

frozen mauve
austere grotto
#

no

#

It's an InputActionAsset

#

but it has an indexer

frozen mauve
#

ight, looked like dictionary logic

austere grotto
#

so they both use indexer syntax

frozen mauve
#

Whelp, I'll go research again ig, thanks Praetor, see yah

#

Quick test, this asset is accessible by MainInput.asset (MainInput => instance of whatever the generated class is called)

#

Just correction cus it's not called actionsAsset

austere grotto
#

Ok thank you

#

I don't have a Unity project in front of my so I couldn't check, and that doesn't happen to be documented 😓

willow scarab
#

I've got an odd issue where the InputSystem isn't correctly observing gamepad or keyboard inputs (Not allowing any input through unless it is a joystick Vector2 movement) until InputDebugger is open. Does anyone know why this is?

#

it only seems to happen when in unity editor, not in-game on build versions.

cunning basin
#

Hey guys

#

How do I make my unity game accessible for mobile so you can move touch buttons and other things

austere grotto
slow flax
#

do anyone know how to add crafting into my vr survival game?

austere grotto
#

With a large amount of effort and planning

visual tapir
#

Is this even close to what I'd need to create a controller to tell apart between a tap, a hold and a drag? Basically I want three separate abilities to activate depending on the input type (on tap turn on the light, on hold a focused ability, on drag a conical AoE - I also want to be able to tap a different area for a different ability). My question is can I tell this behaviour apart in the input system or should I just listen for "touch" and "hold" separately and then figure things out from there?

austere grotto
#

with this setup, both tap and hold will happen when you hold

#

You'll want to handle the disambiguation in code

visual tapir
#

Makes sense - so when I have two separate actions (tap/hold and drag) there's no way for both to fire at once?

austere grotto
#

what do you mean by "at once"?

#

They can all independently fire

#

they don't care or know about each other

visual tapir
#

As in will everytime I "Drag" automatically trigger the "tap or hold" since the latter is a pre-requisite for the former?

austere grotto
#

the drag one will trigger when you move the mouse

#

they're independent

visual tapir
#

So dragging is moving with the mouse held down? Which is the same as the "hold"? I'm probably completely misunderstanding something 😅

austere grotto
#

drag is just the name you gave your action

#

The action is bound to the mouse position

#

so it cares only about mouse position

visual tapir
#

Ah, yeah makes sense, I set that wrong for sure then, I thought that defining "hold" in interaction also means it's held down, not just moving the mouse around

austere grotto
#

you definitely don't want a hold interaction there

#

it makes no sense

#

no it's not that clever. That would make it trigger only if you continually move the mouse for .5 seconds

#

it really just doesn't make sense outside of button style controls

visual tapir
#

Ah! Welp, I completely misunderstood it then - time to re-read the docs - thanks! 🙌

deft vortex
#

Hello,
I have more than one action map and trying to switching between maps by A.Enable() B.Disable() and vice versa.
But then pressing the key that disables current map and enables the other one actually fires another action in the second map that uses the same keybind. (seems like it is not consumed by the first action map & seems like it is intended)
Can anybody help me out with this issue? What is the proper way of handling this?

austere grotto
deft vortex
sterile walrus
#

MY INSPECTOR TAB IS BLANK I DONT KNOW WHAT TO DOOO

tulip tartan
tulip tartan
sterile walrus
tulip tartan
cursive oxide
#

Can someone help me figure out why my gamepad isn't registering as connected for my project? I haven't opened this project on this computer before and when I did I had some errors, resolved them, but now I can't use my gamepad/ controller as input.

ornate forge
#

can I "inject" inputs to the input system?
Say, my game uses actions and the input system and it's all happy.
I want to add touch controls.
Can I "inject" the virtual touchscreen joystick into the input system so the rest of the game remains all happy?

austere grotto
cursive oxide
#

I have SCUF envision pro. Why isn't it being detected by Unity as a connected Gamepad?

austere grotto
cursive oxide
cursive oxide
austere grotto
#

well there's your answer

#

It is being detected

#

it's not supported

cursive oxide
austere grotto
#

you can see what events it fires as you press buttons etc

cursive oxide
cursive oxide
austere grotto
# cursive oxide I read the documentation page and don't understand how that helps

The Events section lists all input events generated by the Device. You can double-click any event in the list to inspect the full Device state at the time the event occurred. To get a side-by-side difference between the state of the Device at different points in time, select multiple events, right-click them, and click Compare from the context menu.

#

Did you read this part

cursive oxide
# austere grotto Did you read this part

Yes. 2 problems with that section. 1 when I double click on the controller nothing happens. No event modal pops up. 2. Its not registering the controller as a valid device in some sections and in other sections it is. For example the console log shows it as an xbox 360 controller when i unplug and plug it in:

austere grotto
#

Alright well you've reached the limit of what I know about device handling

cursive oxide
next crown
#

I have this line

context.action.bindings[1].effectivePath This works, but as an example, for gamepads, it shows the "general" binding i.e Gamepad/buttonEast. If i wanted to get the exact binding (i.e Xbox/B or DS4/O) would i need to create a different control scheme for each device?

tulip tartan
# sterile walrus It wasn’t

It wasn't a simple issue? You had simply not selected something. You of course have to select something to inspect it.

Either way, there is no need to continue this. Please just respect the community and others, don't be rude, and follow the rules

https://learn.unity.com/ has the essentials pathway which will get you going quickly. It will teach you all about the editor.
All the other pathways are great too

sterile walrus
winter bolt
#

I have a UnityEngine.InputSystem.InputBinding object. when i call "ToDisplayString()" on a button south input on it my xbox controller returns "A" which is great, I'm then using that string to convert it to the corresponding character in promptfont. I don't own a PlayStation controller so I don't know what would be returned on that controller. does anyone know how ToDisplayString would be translated for each of the 4 main buttons (north button, south button, east button, and west button)? I cant seem to find it the docs.

fringe kite
#

How can you have these two inputs for the same action? I tried using Any for the control type, but no luck getting it to work. I can just make two separate actions, but was hoping to figure this out.

Left stick (up)
Keyboard W

I want both to move the character forward, but I wan the left stick up to function like a button since I have grid movement in my game where the player moves one unit forward.
**
NVM I'm an idiot I thought I had selected left stick UP as the input, but I only selected left stick. **

next crown
#

I can't for the life of me figure out how to get the current used device from an input action asset, without using playerInput. Is there an easy clean way?

austere grotto
next crown
#

should i have only one instance of my actionAsset? Cause since now i've been just insanciating a new one in each script where i need em but maybe that's bad practice?

austere grotto
molten bay
#

Hi, I am working with unity 6.
I was wondering what the best approach for making an asset is.
What I mean is, I have my utils asset which shouldn't be tied to a project, and therefore should have it's own actions asset.
Having a single actions asset doesn't seem like a good approach because that would mean I(or anyone else using my utils) would have to create a new action map for each project to add all the needed actions.
The issue is, when I created a new actions asset, it didn't work(I assume because it's not a project wide input system asset) and I don't know what I am supposed to do now.
Thanks in advance!

austere grotto
# molten bay Hi, I am working with unity 6. I was wondering what the best approach for making...

What I mean is, I have my utils asset which shouldn't be tied to a project, and therefore should have it's own actions asset.
Make a UPM package containing your stuff.

The issue is, when I created a new actions asset, it didn't work(I assume because it's not a project wide input system asset) and I don't know what I am supposed to do now.
What do you mean by this? what did you expect it to do? What steps did you take to try to make it work?

molten bay
# austere grotto > What I mean is, I have my utils asset which shouldn't be tied to a project, an...
  1. I am using git, much easier than having to constantly package and upload it, I can just push changes from the latest project I am working on.
  2. I don't know how input systems work behind the scenes, I was hoping that doing something like if (_backAction.action.WasReleasedThisFrame()) would check if one of the back action inputs was released that frame.
    What I did was:
  • Create a new input system actions asset
  • Get a reference to an action from it [SerializeField] private InputActionReference _backAction;
  • Tried and failed to use it
austere grotto
molten bay
austere grotto
#

If you didn't enable it that's why it's not working

#

is there a way to have it enabled by default?
Not really

leaden cloud
#

I'm running into an issue I think is an input system issue, but I'm not 100% sure what the deal is. I have it set up where I walk up to an item and hit the button I've labeled for interact, and it pulls up a menu with 4 buttons i can select from. If I use the keyboard, hitting E pulls up the menu, but using a controller, it pulls up the menu and selects the first option immediately and I can't for the life of me figure out what the deal is and why it's acting this way.

#

Anybody have any insights? For the input system I have it set to trigger on context started, that should only fire once, shouldn't it?

#

I have the first button set up in the script to use SetSelectedGameObject so that's why it's choosing the first one, but again it's only doing it using a controller

austere grotto
#

That seems likely

leaden cloud
austere grotto
#

wdym by that

leaden cloud
#

I opened up the input actions I made, went to UI and removed the gamepad option from submit so the only remaining thing is just the keyboard

austere grotto
leaden cloud
#

I'm not quite following what you mean honestly, I downloaded the package, made a new input module in my assets and set the bindings in there, one for player, and one for UI

austere grotto
#

THe UI Input Module

#

it's a component on your Event System

#

it's the thing that hooks up your input to the UI system (aka pressing buttons)

#

If you didn't do anything with that, it's using the default asset

#

which has probably "Button South" as the submit button

#

which is likely what you're pressing

leaden cloud
#

Oooooooh, I wasn't aware there was another one

#

gaaaah

#

thank you!

fringe kite
#

For vector2D movement, how can I compensate for when a diagonal direction is released (say UP and Right keys pressed) since you cant release them at the same time. I need to save the last direction the character is facing, but need to compensate for this delay and count it as a diagonal vs one or the other input direction.

supple crow
#

Perhaps you can separate horizontal and vertical inputs

#

so you track them separately

#

each one gets reset to 0 if there's no input in that direction and there is input in the other direction

#

and then give that reset a slight delay

austere grotto
orchid hull
#

not sure where to ask this, but is there a way to tell when the mouse is over a UIToolkit ui so I know to ignore it as a mousepress in the game?

austere grotto
orchid hull
#

hmmmm ok thanks!

#

where can i find info on the event system?

austere grotto
#

You'll also need a PhysicsRaycaster (or the 2D version) on the camera

worthy osprey
#

what is a good way to troubleshoot slowdowns of the input system?

austere grotto
tulip tartan
leaden cloud
#

Hi it's me again with the same issue as last night: I've replaced the actions asset in the EventSystem with my own action map, however I'm still running into the issue where the button to interact with something is the same button that is submit for the UI that pops up and chooses the first button immediately. Is there a way to make it so when you change to another action map it doesn't recognize a button that's already pressed down?

austere grotto
leaden cloud
#

I'll give that a try, thanks for the help!

leaden cloud
#

That didn't work, it seems like Submit is triggering when the button is held down no matter what, but I could probably just do a WaitForSeconds(.1f) or something

#

Otherwise I suppose I can do a check if the button is pressed and if it is just have it wait until it's released and then swap the map

supple dust
#

Hey there
I got probably a rather trivial problem rn which I cant get my head around.
How do I get a continuous call to methods from the performed ?
Or do I need to get back to Update/Fixedupdate

austere grotto
#

if you want sometjing to happen every frame or every physics frame, that's what Update/FixedUpdate are for

supple dust
#

Alright, I changed the call towards the Update now.
Thanks for the advice :)

halcyon mountain
#

I have a problem, when I place 2 player inputs, it only recognizes 1, what happens is the following, I downloaded the Unity character controller and it uses the new input system with the behavior of send messages and I have another player input that I use to that recognizes the Xbox buttons, so I don't know how to combine them since the Unity one is a labyrinth how send messages uses it, is there any way to make the 2 player inputs work at the same time?

austere grotto
#

If you use more it will expect to connect to more input devices

gray garden
#

hello i have a ps3 controller and i want to add controller support to my game will it work the same for other controllers even if i test with a ps3 controller

wind dirge
#

Use new input system

supple dust
#

You can find the new Input System under "Package Manager > Unity Registry > Input System"

gray garden
#

thanks so if i choose gamepad it will work the same on all controllers

austere grotto
#

Most

valid arch
#

Hey guys, any idea why on the gamepad im getting 2 calls with context performed? On a keyboard its called only 1 time (as i'd like it to), it's normal button (in the action map) + method call in the unity event in player input. Also it's normal button (A xbox) not trigger

#

Pass through seems to work the same way

austere grotto
#

Especially how you hooked up your listener

valid arch
austere grotto
#

Have you tried Debug.Log?

#

Looks like two separate listeners are hooked up

valid arch
#

instance id looks the same with both calls, and in events i have only called it once

#

gameObject.GetInstanceID()
-2864592

gameObject.GetInstanceID()
-2864592

#

what could i log in Debug.log that'd be helpful for us?

austere grotto
#

Maybe something with "initial state check"?

#

Not sure

valid arch
#

also not sure what could i look here for

#

i think ill just do float lastTimeCalled, and check if its called second time the same frame, cuz i dont know what to do with it rn 🤷‍♂️

austere grotto
#

I was referring to the initial state check setting on the input action

valid arch
#

this one?

valid arch
#

Ok, i change a map later on in the CurrentSelect?.Cancel(); and it call all events second time (started, performed, canceled). But i wasn't aware that it calls all of them even if you change to the same map for example ui into ui.

#

@austere grotto thanks for your help 🙂

#

Although, i'm still curious why my keyboard was called only once 😄

magic drum
#

Does anyone know why Unity made the Control Scheme device selection list view use right clicks for interaction instead of left clicks, which they use everywhere else in Unity?

mighty spade
#

Is there a way to utilize the new input system in Unity without having to implement OnEnable and OnDisable in the scripts?

tulip tartan
hazy coral
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;

public class PauseMenu : MonoBehaviour {

    private MainManager mainManager;
    private PlayerInputActions inputActions;
    public bool isPaused = false;
    private const string MAINMENUSCENE_NAME = "MainMenu";

    private void Start() {
        mainManager = FindObjectOfType<MainManager>().mainManager;
        inputActions = new PlayerInputActions();
        inputActions.PlayerBasicMovement.Pause.performed += Pause;

        GetComponent<Canvas>().enabled = false;
    }

    public void Pause(InputAction.CallbackContext context) {
        Debug.Log("Triggered outer");
        if (context.performed) {
            Debug.Log("Triggered inner");
            if (isPaused) {
                Time.timeScale = 1.0f;
                GetComponent<Canvas>().enabled = true;
            }
            else if (!isPaused) {
                Time.timeScale = 0f;
                GetComponent<Canvas>().enabled = false;
                FindObjectOfType<SettingsMenu>().gameObject.SetActive(false);
            }
            isPaused = !isPaused;
        }
    }
}```
what is missing in my script that I cannot trigger the Pause() function? Can anyone help?
supple crow
#

you have not enabled any input actions

#

you can do inputActions.PlayerBasicMovement.Enable(); to turn on the entire map

hazy coral
#

So in PlayerInput enable is not required but outside of the player controller it is?

#

when using input actions

supple crow
#

I don't know what you mean by the "PlayerInput enable"

hazy coral
#
public PlayerInput playerInput;
    public InputAction moveAction;
    private CharacterController controller;

    public bool playerLookable = false;
    public bool playerMoveable = false;

    private void Awake() {
        
        controller = GetComponent<CharacterController>();

        playerInput = GetComponent<PlayerInput>();
        moveAction = playerInput.actions.FindAction("Move");

        currentSpeed = baseSpeed;
    }```
#

this is my code on the upper map "move"

#

used on the player with a PlayerInput component

#

I didn't write a line to explicitly Enable the map but it worked

supple crow
#

the PlayerInput component will, by default, pick a single input action map and enable it

hazy coral
#

oh, It worked

#

appreciated for the tip

#

oh I see there is a default map dropdown in the PlayerInput component

#

that's why it worked without me enable the map

hazy coral
#
public void Pause(InputAction.CallbackContext context) {
        if (context.performed) {
            isPaused = !isPaused;
            if (isPaused) {
                Time.timeScale = 1.0f;
                GetComponent<Canvas>().enabled = true;
            }
            else if (!isPaused) {
                Time.timeScale = 0f;
                GetComponent<Canvas>().enabled = false;
                FindObjectOfType<SettingsMenu>().gameObject.SetActive(false);
            }
        }
    }

    public void PauseButtonDown() {
        var context = new InputAction.CallbackContext();
        Pause(context);
    }
#

how can I do to make the pause function work through the PauseButtonDown() which attached to a button onclick event

#

for now I guess my new context does not passes a performed message and I cannot edit it like context.performed = true since performed is readonly

#

Is using a private event that links both ways of pausing to the function a better way?

supple crow
#

you do not create your own callback context

#

I'd rearrange this so that it's:

#
void PauseAction(InputAction.CallbackContext ctx) { Pause(); }
public void PauseButton() { Pause(); }
void Pause() { /* pause code in here */ }
hazy coral
#

oh, I found that making a event for this is excessive, just call another method

#

thanks for the help

sinful grotto
#

hello, Im tryin to broaden my knowledge of the new input system, and im trying to get an action to have 2 interactions on it, hold and tap, hold will drain water, and tap will pickup or drop the item.
This may be wrong, but it works for the hold interaction atm

    public void OnInteract(InputAction.CallbackContext context)
    {
        if (context.performed)
        InteractAct = context.ReadValueAsButton();

        if (context.canceled)
            InteractAct = false;
    }

How would I implement a tap feature without stepping over the hold feature?

austere grotto
sinful grotto
#

oh boy tell me about em

austere grotto
#

Basically you have these states:

WaitingForInitialTap
WaitingForReleaseOrHold -> if release before time threshold, do the Tap action
v
if time threshold gets reached ebfore release - do the hold action

#

I wouldn't formalize it with multiple classes or anything

sinful grotto
#

im gonna mark this for later use XD

#

okay, Im trying to go about making this game slowly, and methodically, but the problem you get with keeping it clean and modular is the confusion, and complexity

austere grotto
# sinful grotto okay, Im trying to go about making this game slowly, and methodically, but the p...

You could actually model this as one action with the Hold interaction maybe and do this:

    bool wasPerformed;

    public void OnInteract(InputAction.CallbackContext context)
    {
        if (context.performed) {
          // Hold timer was reached 
          wasPerformed = true
          DoHoldAction();
        }

        if (context.canceled) {
          if (!wasPerformed) {
            // This means we released the key before hold timer was reached.
            DoTapAction();
          }

          wasPerformed = false;
        }
    }```
#

then just set the hold time as desired in the Hold interaction

sinful grotto
#

Im worried about turning my input class into a class that does something and calls its own methods. Im scared of the speget

austere grotto
#

have it fire events

#

other things can handle the events

#
    bool wasPerformed;

    public void OnInteract(InputAction.CallbackContext context)
    {
        if (context.performed) {
          // Hold timer was reached 
          wasPerformed = true
          OnInteractHeld?.Invoke();
        }

        if (context.canceled) {
          if (!wasPerformed) {
            // This means we released the key before hold timer was reached.
            OnInteractTapped?.Invoke();
          }

          wasPerformed = false;
        }
    }```
sinful grotto
#

i DIDDD i diddd DXX and that started to not workkk lolll using events was great but the idea of it for me was to make code more independent. In reality i still needed those scripts to connect, and did away with events after that

austere grotto
#

events reverse the dependency that's all

#

Instead of A knowing about B to call B.Something, now B knows about A to listen to A.OnSomeEvent

#

you still need the scripts to connect in any case

#

YOu can make the events static if you want.

sinful grotto
#

I think i dont know enough about events to use them properly. I had it used correctly but then didnt know what i was really doing with it

austere grotto
#

Regardless this is an unrelated discussion

#

However you want to communicate this stuff to another script is different from how to handle the logic

sinful grotto
#

yea u right, and i didnt think about it that way :o, thanku good sir

acoustic shard
#

So I'm using the new input system and have 'held' for a button, however, when I try this code (I'm sure this is a logic error?) the moveDelay doesn't do anything even if I set it to a ridiculously high number. However, if I remove the moveDelay movement is instant.

    private void Update()
    {
        BasicMove();
    }

    private void AttemptMove(Vector2 moveInput)
    {
        // Movement stuff
        
        isMoving = true;
        StartCoroutine(MoveCooldown());
    }

    private void BasicMove()
    {
        Vector2 move = playerControls.Gameplay.Move.ReadValue<Vector2>();

        if (!isMoving && move.magnitude > 0.5f)
        {
            // Prevent diagonal movement
            if (!(Mathf.Abs(move.x) > 0.5f && Mathf.Abs(move.y) > 0.5f))
            {
                AttemptMove(new Vector2(move.x, move.y));
            }
        }
    }
    
    private IEnumerator MoveCooldown()
    {
        yield return new WaitForSeconds(moveDelay);
        isMoving = false; // Reset moving flag after moveDelay
    }

Any ideas?

acoustic shard
#

I figured it out, I am a HUGE DUM DUM and moveDelay was a public float that was being overridden by the gameobject.

shut ingot
#

How come the new input system doesn't need to be put in update?
controls.Main.Movement.performed += ctx => Move(ctx.ReadValue<Vector2>());

tulip tartan
#

Not polling based

#

Although you CAN do polling (Keyboard.current.AKey.isPressed or whatever the syntax is for that. Maybe IsPressed() can't remember off the top of my head)

shut ingot
#

Interesting... thank you for the info

austere grotto
#

it can also be event based

#

it's very flexible

final heart
#

So I install the Simple Demo from the Unity Input System samples and play the SimpleDemo_UsingPlayerInput scene: work as normal and can control the Player. Now I remove the SimpleController_UsingPlayerInput component from the Player and add it again then play the scene: can't control the player, why?

austere grotto
final heart
#

yes

austere grotto
#

Kinda like " I took the engine out of my car, why did it stop driving?"

final heart
#

when I remove it then add it again as a component it doesnt work

#

you misread

austere grotto
#

It probably needs to be configured in the inspector somehow

#

And other things might have referenced it as well

#

So you broke all that stuff by removing it

final heart
#

I put in the same values of the variables

austere grotto
#

Most likely the PlayerInput component itself

#

But impossible to say for sure without seeing it

final heart
#

if I compare it to the unmodified scene it has the same parameters

austere grotto
#

What does

final heart
#

PlayerInput

austere grotto
#

Show it

#

I need screenshots etc to know more

final heart
#

ok I found the problem

#

removing the controller script removed these entries

#

thanks

austere grotto
#

Yes indeed

topaz sapphire
#

Can someone help me out here? When I use context.performed to read this input, it always fires instantly, no matter what I set the "Hold time" to.

austere grotto
#

so it basically ignores any interactions iirc

topaz sapphire
#

it also happens on Button and Value type too.

austere grotto
#

show how you hooked this up to the code

topaz sapphire
austere grotto
topaz sapphire
austere grotto
topaz sapphire
# austere grotto where are you logging? I didn't see it in the code you shared.

https://hastebin.com/share/boketekefe.csharp

Here, added a second check to the input manager itself, re-tested it, and confirmed that it's still firing every frame that the mouse is held down (Ignoring any delay put into the Hold Interaction)

And here's a screencap, showing without a doubt that the Input Manager is correctly hooked up to the ClickHeld input.

austere grotto
#

I only see one in ClickDownPressed

austere grotto
#

to tell you exactly when performed is happening

#

that's what we care about

#

Update is confusing things

topaz sapphire
#

https://hastebin.com/share/biyuvoweta.csharp

Edited, tested, spamclicked, and this was the result and here is the edited version with Debug Logs for each

austere grotto
topaz sapphire
#

With 50000 as the hold time, all bindings set to no function except for ClickHeld, and screenshots/gifs of everything including spam clicking

austere grotto
austere grotto
#

you need to remove the "Press Only" interaction from the mouse

topaz sapphire
austere grotto
#

that's prob ably overriding the Hold interaction on the action

topaz sapphire
#

That finally fixed it

#

Thank you very much, and I apologize for using up so much of your time!

waxen token
#

How can the script detect if the mouse has been clicked?

#

Through new input system

austere grotto
#

Bind an action to the mouse click

waxen token
tulip tartan
waxen token
tulip tartan
#

Ok, yeah if you want to poll it, you can do that

waxen token
#

Mouse.current.leftButton.wasPressedThisFrame

austere grotto
#

It's ok if you know you'll never rebind it or anything

tulip tartan
waxen token
austere grotto
#

Or support touch etc

waxen token
waxen token
waxen token
austere grotto
#

I don't know your case

warm ore
#

I wonder if the "new input system" ever going to not be new.

austere grotto
#

It's only new relative to the old system

#

It's officially just the Input System

magic drum
#

Has anyone had any success having two different keyboard schemes? I want wasd and arrows to be different schemes so they can be used for player 1 and player 2. but with auto join, when I hit the arrow keys, it joins with the wasd scheme.

#

it kind of seems like hitting any key causes the player to join with the first keyboard scheme.

#

is it possible to set which keys cause which schemes to join?

austere grotto
magic drum
#

Thanks!

vivid tiger
#

I can't seem to find any information about this but is it possible to target the steam deck control opportunities specifically?

magic drum
#

Is it possible to prevent a specific action (like mouse position) from causing auto join or auto switch?

thick pilot
#

how to make something like jump when holding jump higher with new input system?

obsidian gazelle
#

I've been having a problem that I can't solve for a while...

I've tried many different things but they don't work, the result is always the same error when this case occurs: in a 2d mobile game, having created a new input system action that is simply left click, when it is pressed many times in a row (many clicks in a very short time) the value of that action remains stuck at 1 (ReadValue<float> = 1) even though the button is not being pressed. Also printed IsPressed, and it is true while not holding the button.

I've tried almost everything, different types of Coldown systems using Time.time, coroutines that disable the button and activate it every time it is pressed, different types of FSM, restrictive bools of various types, setting the action to Button or Passthrough with or without Initial State Check checked, I tried to use the instruction Reset() of the action after using it...

The only "solution" is to set a Hold Processor on the action with a value of at least 0.5, but it is useless as it breaks the experience. I don't know what else to try to prevent the button from getting stuck with value 1 when pressed very quickly. Any solution? Thanks

obsidian gazelle
chrome walrus
digital narwhal
#

Testing out Unity 6. During dev, no errors when playing. But when I build, the errors come up the moment player loads and these are the only ones. Everything in the player works proper, no issues with actual input.

austere grotto
digital narwhal
#

here is a snippet or the first one. The rest follow the same pattern:

#

any thoughts?

cursive oxide
#

How do I add WASD support for my player movement? currently since its a vector 2 for stick support, keyboard is not listed as an option since its a different kind of input

white torrent
#

Is there a way to make the input event trigger each frame when a button is held? Seems like the event only triggers when the control state changes, but I'd like to do some repeat logic as long as the button is held

supple crow
#

you can use InputActionReference to assign a reference to an input action from an asset

#

or, if you're using the "generate C# class" feature, you've got all of the actions right there

white torrent
#

ah ok, I was hoping there was a way to get the event to trigger each frame like in unreal, but looks like not. Thanks for the info!

quiet tusk
white torrent
amber wigeon
#

i have a problem that the Listen button is hidden behind other ui elements. it's still possible to click it, but it's hard. another problem is that when i press binding, it makes my cursor behave as if i was typing something, while i'm not typing anything. it makes it hard to press the bindings and i need to press the binding on a specific spot for it to work. there's also this warning upon installing the new input system: Unable to find style 'ToolbarSeachTextField' in skin 'DarkSkin' Used UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

tame oracle
#

Whats the best way to handle the input system across multiple scenes?

austere grotto
#

depends on your needs

obsidian gazelle
twin sundial
#

is there a way to get what generic type of controller the user is using? I want to get if they're using an Xbox Controller, a PS Controller, or a Switch Controller

spare frigate
amber wigeon
#

thank you

frozen mauve
#

I'm using an on-screen joystick to make the player aim and attack on release

#

But for some reason despite the player turning when I tap shortly, it doesn't actually attack whatsoever

#

Which I believe to be cus of WasReleasedThisFrame... However I have no idea about why this is happening

austere grotto
frozen mauve
#

I figured another detail out, I was mistaken

#

It seems to work when you press the outer parts of the joystick

#

But won't work if you tap close to the center

frozen mauve
#

I have a build of my game on my mobile, that's all I can test on rn

austere grotto
#

WasReleasedThisFrame is really intended for button actions

frozen mauve
#

Ah...

austere grotto
#

it will work for a joystick but only when you go from the default actuation point (maybe 50%) to 0

frozen mauve
#

That explains the outer rim working ig

#

What is normally used for joysticks though?

austere grotto
#

code

#
ReadValue<Vector2>()```
frozen mauve
#

So uh... Caching whether it's not zero last frame and comparing to this frame every frame?

#

Cus I see no other way if I try to do it by the vector value

rotund sleet
#

I'm currently using the code below for mobile input, and by using the mobile simulator, using the Left mouse button click it works fine, however, let's say I want to use the Right mouse button click, how could I make it work for the simulator?

        if (Touchscreen.current.primaryTouch.press.isPressed && Touchscreen.current != null)
quiet tusk
rotund sleet
rotund sleet
#

I'm using Unity newest version, and I have a mobile simulator system. And the setup at the image only works for the mobile simulator window, why doesn't it work for the game window mode? I also think that in the game window it only works codes using the old input system, while the mobile simulator window only works the new input system. Anyone knows why that is?

#

Do I need to change anything here?

ripe bobcat
#

Hey,
Im gonna work on a 2D topdown game in Unity.
Im experienced with coding, just not all to much with C# yet. (about a year)
Is it recommended to use the old or new input system?

(PC Steam Game)

austere grotto
#

If you want to have local multiplayer or rebindable keys, the new system is worth learning

#

But the learning curve is steeper

ripe bobcat
#

but also, for local multiplayer, will the old input system cause issues ?

austere grotto
austere grotto
red prairie
arctic elm
#

Hey all, is there a way to "remove" selectables from the Event System so they're not valid for selection (e.g. with a gamepad nav)

#

I don't want to disable them or them to appear deselected, so canvas group interactable won't work

#

maybe disabling their Navigation is the only way?

austere grotto
turbid dagger
#

I'm using the input system rebinding extension, is there a way to discretely detect scroll wheel up and scroll wheel down as independent inputs when using PerformInteractiveRebinding()

#

regardless of which direction i scroll, it gives me the same input action, "Scroll Up/Down"

#

i need both inputs to be discrete from eachother so that the player can bind swapping weapons forward and backward to two discrete buttons or to the scroll wheel

#

otherwise id either be forcing the player to bind swapping weapons to an axis, like the scroll wheel, or making the scroll wheel swap weapons forward/backward regardless of which direction you scroll

#
if (m_Operation != null)
{
    m_Operation.Dispose();
    m_Operation = null;
}

m_RealAction.Disable();
m_Operation = m_RealAction.PerformInteractiveRebinding();
if (!string.IsNullOrEmpty(CompositeActionPart))
{
    var bindingIdx = m_RealAction.bindings.IndexOf(x => x.isPartOfComposite && x.name == CompositeActionPart);
    m_Operation.WithTargetBinding(bindingIdx);
}
m_Operation.WithCancelingThrough("<Keyboard>/escape");
m_Operation.OnComplete((x) =>
{
    m_RealAction.Enable();
    ButtonContent.SetText($"{x.selectedControl.displayName}");
    x.Dispose();
    m_Operation = null;
}).Start();```
#

if i debug on OnComplete, the selectedControl is Axis/Mouse/ScrollY. Is there a way i can detect the value (positive or negative) of that scroll and then set the selectedControl to the appropriate discrete ScrollUp or ScrollDown InputControl?

exotic spear
#

is there any way to get the context using the inputValue using Send Messages?

tulip tartan
exotic spear
#

I was afraid that would be the answer, thank you

quick plume
#

Hey is there a way to hide an input control object on a class that inherits from gamepad

#

specifically I’m trying to hide the left and right stick buttons since my controller I’m added dosent have them

austere grotto
#

Both are viable. PlayerInput and PlayerInputManager give a really convenient start if you're trying to do local multiplayer

#

You'll have to do less work with device and user management that way

digital narwhal
#

Anyone ever had these errors in standalone player log?

Action count in old and new state must be the same
Map count in old and new state must be the same
Binding count in old and new state must be the same

This occurs immediately after splash screen.
I confirmed via debugger that the UI InputAction is indeed enabled. I also confirmed that any overlays are not raycast targets. But nothing happens with the buttons when I click them. On editor it works and I get no errors. But on standalone I get these errors.

supple crow
#

What's in your callstack?

#

Something is causing a full re-resolve of bindings

digital narwhal
supple crow
#

Do you create your own actions or action maps through code at any point?

digital narwhal
#

No. But I got the error to go away when I removed the part in my code that instantiates the event system from addressable when the app loads.

#

So it seems to be something with that. I'm gonna add it to the title scene hierarchy and build and see if it happens again.

#

It worked. So it's and issue with me loading it from addressable.

#

Here is how I load it:

private static GameObject _LoadAndInstantiateResource(string resourceKey)
        {
            var assetHandle = Addressables.LoadAssetAsync<GameObject>(resourceKey);
            var gameObject = Object.Instantiate(assetHandle.WaitForCompletion());
            gameObject.name = resourceKey;
            Object.DontDestroyOnLoad(gameObject);
            Addressables.Release(assetHandle);
            return gameObject;
        }
supple crow
#

Interesting -- I also instantiate my event system very early on

#

when exactly do you do it?

digital narwhal
#

At first I did it Before splash screen load. But then I tried after scene load. Same issue.

supple crow
#

mine gets created in a [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] method

digital narwhal
#

Is it because I Addressables.Release(assetHandle);?

supple crow
#

I should check that this isn't showing up in my built game logs

supple crow
digital narwhal
#

🤦‍♂️

#

I didn't confirm it worked AfterSceneLoad because it was AfterAssembliesLoaded. I changed it to BeforeSceneLoad and now it all works.

supple crow
#

interesting!

digital narwhal
#

Thank you for engaging, this helped me figure out this problem.

supple crow
#

glad to hear it worked out (:

#

and that's also useful information

supple crow
digital narwhal
#

lol

dreamy swift
#

I'm using the old input system, and I'm having an issue with getting input from the e key consistently. It isn't a problem with the keyboard, since it works regularly). I've tested using Input.GetKeyDown and Input.GetButtonDown with a button set up in the input manager, and both ways only work about one in 5 times.

#

Never mind, it was because I had it in FixedUpdate instead of Update.

sonic patrol
#

I want to know that how can I use the tilt or change in rotation of a mobile device to accelerate and turn my player using new Input system. Can someone help me know which option should I use?

austere grotto
fresh vault
#

Is there a means to serialize a reference to an action map?

I'd like to expose a property on a MonoBehaviour to specify a map, but the best I have come up with is just punching the map's name into a string field and looking it up from the asset within the code. It's perfectly functional, but... eww... strings.

fresh vault
#

I guess I could also derive it from a random action assigned to an InputActionReference property

dusk quartz
#

how can I detect when a button is pressed using an InputActionReference?

remote bough
#

For some reason whenever im testing controller input, i have to restart my unity, then the controller works on the first time i run the game, then if I stop and re run the game the input is just nonexistent again and I have to restart my editor again to get it back. Is this a hardware issue?

chrome walrus
austere grotto
remote bough
#

Ps4 controller

fringe kite
#

So for additive scene loading do all the scenes you may want to load/unload need to be in the main scene when the game starts or can they be added in at runtime like instantiation?

austere grotto
#

that's the point of loading a scene

#

they do need to be in build settings though

tawny talon
#

can i use an external button in my game ?
we are team and we want to make IOT button and we want our game read a signal from our button can we do it ?
and How?

austere grotto
#

Not an input system related question TBH

turbid dagger
#

Im trying to write a rebinding menu for my game, using unity's new input system and the input rebinding extension. How can i filter the individual directions of an axis input within PerformInteractiveRebinding() so that i can assign them to the positive and negative part of a composite input?

#

for instance, movement left and right is a composite input with a positive and negative direction

#

if i input the left analog stick into one of these, the binding is set to "Left Stick X", which just triggers that direction of the composite input regardless of which horizontal direction i move the analog stick

#

what i would need is to filter it to something like Left Stick/Left or Left Stick/Right instead of just Left Stick X, depending on the direction the player inputs

#

the same applies to scroll wheel inputs, any direction on the scroll wheel will set the binding to Scroll Up/Down, instead of the actual direction the scroll wheel was rotated

remote bough
# remote bough For some reason whenever im testing controller input, i have to restart my unity...

anybody have any ideas for this? I could not get it working with my ps4 controller (more than 1 run) so i thought maybe it was the chord since my chord was a bit finnicky, i tried a new chord, same thing. Then i tried using one of my xbox controllers. wont even get the input. Even though it works completely fine in joy.cpl / online gamepad testers and is clearly connected, for some reason the editor is not detecting it. All ideas are appreciated I have scowered the internet

remote bough
#

sigh... it was the unity version

#

all is well now sorry for spam

supple crow
#

so here's a bit of a long shot

#

Valve has an input system called Steam Input

#

I'm wondering if anyone has ever looked at using it as a device

#

Steam Input lets you declare actions like "Shoot" or "Dodge" and have those appear directly in the input configuration in Steam

#

So in theory, you could create an input device that responds to these actions

#

so if I had an input action called Dodge, it might have bindings of:

  • Shift (Keyboard)
  • Button South (Gamepad)
  • Dodge (Steam)
remote bough
#

Any reason why my controller input works perfectly fine in the editor, then in the build it does not get detected at all? I have no errors in the build, just nothing happens when I start inputting stuff on the controller, keyboard/mouse still works fine. I have been researching this for a while and none of the known fixes (the few that exist) even apply to me. If anyone has any suspicions on why this could be happening I would appreciate it, thanks!

austere grotto
remote bough
#

looks as if its getting picked up its just not reading the inputs

remote bough
austere grotto
remote bough
austere grotto
# remote bough yes

Is there a good reason for using control schemes? Mostly those are useful mainly for local multiplayer

#

They end up causing people issues like this a lot

remote bough
#

I have them for different devices like I thought you were supposed to?

#

all of those were there when i hit create actions though

austere grotto
#

It's only needed for local multiplayer where you need the system to be able to identify different people by different devices

#

what may be happening is your input is getting bound to the first device it sees - which is maybe not the one you're actually using

remote bough
#

so does onControlsChanged not change the control scheme?

#

wow i was under the assumption that they are for different devices schemes not different PHYSICAL device schemes

#

so I should just remove them all and have one called main or something?

remote bough
#

also dont think that approach will work, considering im displaying control hints so I kind of need to know which control scheme is active

supple crow
supple crow
#

just slap that in an OnGUI method or something

#

I don't know if there's a nicer way to do that in a build

unique geyser
#

I've set a newly created Input Manager, but I can't swap back.. why is that? ^^'

tulip tartan
#

And what do you mean swap?

#

Is this about the new input system, or the old input manager class?

unique geyser
#

I pressed "Assign as the Project-wide Input Actions

and swap meaning, I wanna go back to what I had before

tulip tartan
#

Ah, in player settings you can switch the active input system

#

Project settings > player
If I remember correctly

#

Hopefully I am understanding correctly

#

In that top image, open "other settings"

unique geyser
#

nothin

tulip tartan
#

It is right there in the top image

#

"Active input handling"

#

It is currently set to "Both", so you can use the old input as well as new currently

unique geyser
#

Eh yeah but thats fine no?

tulip tartan
#

Yeah, totally fine

unique geyser
#

I wanna replace this Input Action Asset:

#

with this:

#

Maybe thats the proper wording

tulip tartan
#

Oh, that is a completely different issue

#

Generate the c# object for that asset

#

You could delete the other asset if you want too

unique geyser
unique geyser
unique geyser
#

omg.. nvm..

I got it.. it was because Ive been in play-mode, yikes my bad! 😄

#

Tyvm all notlikethis

lament whale
#

I have an InputAction with 10 keys, which I'm using for accessing the hotbar items. Works fine.
But I just finished a feature to change keybinds and I want to support control/alt/shift modifiers as well. Changing the keybinds works fine. I also have composite paths such as "/Keyboard/leftAlt + /Keyboard/q" as bindings.

However, now I noticed I can't actually use these bindings at all for my action...
I have UseHotbar(InputAction.CallbackContext context) that gets the event, but context seems to know nothing about composite keybinds. context.action is just straight out missing these bindings.

Any tips on how I could make this work?

austere grotto
#

It greatly simplifies rebinding etc

lament whale
#

but I think I just figured it out as well, context doesn't have binding directly, but it does exist in context.action.bindings

austere grotto
lament whale
#

yeah, thanks
spent way longer on it than expected yesterday 😄

remote bough
# supple crow I'd suggest adding some debug code that shows you which control scheme is active...

Okay I just did this, I basically just did a LogError every frame and printed the control scheme, in the editor it is correct, when I switch to my gamepad it prints Gamepad, and when i switch to my keyboard/mouse it prints Keyboard&Mouse like it should. Then on the build it just continuously prints Keyboard&Mouse even if I am using the controller

as for the devices: it shows all the correct devices in the editor, and then in the build the controller is not listed in the connected devices. so for some reason it just is not even seeing the controller as connected

remote bough
#

This is in build

#

this is in editor

remote bough
#

Update: I think it has something to do with steamworks.net...

for some reason whenever I close steam and get this error (which happens because steam isnt open) THEN and ONLY THEN my controller gets picked up. It is so weird that my input doesnt get picked up when the SteamAPI_Init() succeeds but it does when it fails. Does anyone have information on this?

#

I found this:

https://github.com/rlabrecque/Steamworks.NET/issues/380

this definitely seems to be my issue, however I am not quite sure how I can fix this yet

EDIT: like it says in that issue forum, I can fix this by opening the steam overlay (in the build) and going to controller settings and when I apply the template for just "gamepad" and close the overlay THEN my input gets picked up. Very VERY weird bug with steamworks, I have read that when you upload to steam and play through steam it should all be working so I am going to ignore the bug for now (as I don't have a steam page / appid just yet) just putting this here in case anyone has a similar issue

EDIT 2: a temporary fix for this is changing the appid in the build folder to anything else besides 480 (i used 12345). What this does is it doesn't load the spacewar controller configuration which is whats rebinding inputs and what-not. However you can't test any spacewar related stuff obviously like achievements (in the build) if you do this

sorry for spam again UnityChanSorry

hollow hull
#

Hey all - I'm trying to have functionality so that when holding right click, the cursor disappears (easy enough to do), but then if you move the mouse while holding right click and release right click, the cursor appears in the same location as where it was when you held right click before moving the mouse. This is similar to games like WoW. I am able to show/ hide cursor, and I have tried a couple of methods where it does place the cursor back to where it was first held, however there is a noticable lag when it reappears and I'm wondering how people handle this - what is the fastest most efficient way to do this so that there is no lag?

Thanks in advance for any pointers

scenic vapor
#

I'm implementing a HID wheel whose layout starts with a float for the steering angle.

struct HIDData
 {
     float fSteeringWheelAngle =  NAN;//返回角度
     int16_t       steeringWheelAxle = 0x8001;
...

I am replicating this HID as part of an InputDevice:

[StructLayout(LayoutKind.Sequential)]
public struct GudsenMozaR9BaseInputReport : IInputStateTypeInfo
{
    public FourCC format => new FourCC('H', 'I', 'D');

    [InputControl(name = "fSteeringWheelAngle", layout = "Axis")]
    public float fSteeringWheelAngle;

    [InputControl(name = "steeringWheelAxle", layout = "Axis")]
    public short steeringWheelAxle;
...

The value shows up correctly in https://hardwaretester.com/gamepad on axis 0: -1 when at the left limit, and 1 at the right limit. In the Input Debugger, I can see there is a value that changes as I turn the wheel. However, as the wheel passes the centre position the value jumps. It's awkward to explain so I've made a diagram showing the behaviour. On the left is the behaviour on the linked gamepad tester page, and the behaviour I want. On the right is the behaviour I am seeing in the Input Debugger. What could cause this wrapping behaviour?

austere grotto
scenic vapor
#

Where can I modify the input value like that?

austere grotto
#

not sure why that's happening though

scenic vapor
#

I would rather solve this problem at the InputDevice level because I have a number of other devices to consider and don't want to change their implementations or have to consider this wheel a special case.

scenic vapor
#

Yes, is there a way to process input in that class?

austere grotto
#

I believe by overriding the ReadValueFromXXX methods

#

not something i've ever done

#

but maybe you can just do base.ReadValueFromXXX and then try to examine/operate on the resulting data.

scenic vapor
#

Right, I'll give that a go, thanks. void*, my favourite.

#

I thought the new input system was supposed to make things easier!

scenic vapor
#

I have tried this and ended up only deeper down a rabbit hole of custom InputControls. It seems insane to me that this is an issue at all - why can a web browser handle HID input easily, immediately, with zero setup or configuration while the most popular game engine in the world can't even with hundreds of lines of code configuring it? Would appreciate any support on the above ReadValueFromXXX approach or, ideally, on whatever the correct way to set up the axis in the Input System is.

scenic vapor
#

I've started out this morning by getting a better understanding of the error, and it seems the shape I sketched earlier is not correct, which means any solution that involves scaling the input value is going be be extremely awkward to implement. On the X axis is the correct value, which I'm getting from the gamepad test link I shared earlier. On the Y axis I am plotting the reading from the input debugger. This is a clue, but I'm not sure where it points.

#

The simultaneous drop and change in gradient suggests to me that the sign bit is being misinterpreted. However, when I tried looking at the raw memory I was disappointed that I couldn't see it change in real time.

scenic vapor
# austere grotto you can adjust this by doing `inputValue = (inputValue + .5f) % 1f;`

I have made some progress on the issue. For whatever reason, the HID layout I was looking at seemed to be wrong: The steering axis is actually a ushort value. However, it needs to be combined with a second ushort value which defines a constant offset which is set using the proprietary software for configuring the hardware. In my current setup, this is interpreted as two axes, but I would like it to just be one. This would be easy to do in 'application' code, but it would mean adding a special case and polluting my player control code with a correction for a specific piece of hardware, so I would again like to solve this at the InputDevice level.

#

My question is therefore how can I write code to combine these two AxisControls such that the Input Debugger only reports a single value, which is a combination of the two?

[StructLayout(LayoutKind.Explicit)]
public struct GudsenMozaR9BaseInputReport : IInputStateTypeInfo
{
    public FourCC format => new FourCC('H', 'I', 'D');

    [FieldOffset(0)] public byte reportId;

    [InputControl(name = "fSteeringWheelAngle", layout = "Axis")]
    [FieldOffset(1)] public ushort fSteeringWheelAngle;

    [InputControl(name = "steeringWheelAxle", layout = "Axis")]
    [FieldOffset(3)] public ushort steeringWheelAxle;
...
scenic vapor
#

I've managed to create a composite axis based on two axes, one for each side. However, they are configured such that 1 is in the middle and zero is at the peripheries, so I want to apply processors in the InputActions asset to fix this before the values are read. However, they appear to do literally nothing. To test, I added this 'scale' processor, but the output values are identical to without it. What's going on?

#

They are properly saved in the .inputactions

scenic vapor
#

^ From what I can tell, processors don't work when applied to individual parts of a composite axis. Obviously this behaviour is undocumented, presumably a bug. I've had too many bug reports closed without resolution on me to be bothered filing another, but I believe I have just about found a working configuration so no need to reply to any of the above. Thanks!

vale ridge
#

Is there any way to stop InputSystem.onAnyButtonPress from propogating the event?

I'm using InputSystem.onAnyButtonPress (using CallOnce), which is all working fine and dandy, and I can apply the correct logic.

However, after it runs the supplied callback, it still sends the event forward to the input system. This makes it so that when I use certain buttons that match an action, that action gets performed (eg Submit on the UI). This is unwanted behaviour, I'd like to handle this event as a one-off thing where I'm doing one-time logic. Is there any way to consume the event/stop it from propogating? While there are hacky workarounds such as disabling UI interactability or disabling the actions, it feels like there really ought to be a way of stopping the event somehow.

I've scoured google/documentation but didn't have any luck, the only thing I could find was a forum post asking the same question, with no replies unfortunately: https://forum.unity.com/threads/consuming-inputevent-with-inputsystem-onanybuttonpressed.1508648/

serene kettle
#

Hi. I can't figure out how to prevent multiple callbacks during TouchEnded.
It always fires twice (in some cases three times). Any experiences and remedies to solving this? Thx

austere grotto
serene kettle
#

They do have different phases, but that's not the issue. TouchPhase.Ended propagates twice, like i said originally

#

or three times even

#

it's due onBeforeUpdate and onUpdate and onAfterUpdate (input system internal code)

#

however, if I touch, wait for 0.1s and then release, then it propagates correctly.

#

but i can't rely on this behaviour

lament mountain
#

Quite honestly, I have no idea where to post this. When moving the camera horizontally, it randomly speeds up when looking in the positive z direction. And it only does that at a specific point in the map

#

I have checked and confirmed that it is not an optical illusion, I am extremely confused and at the end of my capabilites. That bug is dark witch craft

lament mountain
#

yeah one sec

#
using System.Collections.Generic;
using UnityEngine;

public class PlayerLook : MonoBehaviour
{
    public Camera cam;
    private float xRotation = 0f;

    public float xSensitivity = 30f;
    public float ySensitivity = 30f;

    public void ProcessLook(Vector2 input)
    {
        float mouseX = input.x;
        float mouseY = input.y;

        xRotation -=(mouseY*Time.deltaTime)* ySensitivity;
        xRotation = Mathf.Clamp(xRotation,-80f, 80f);

        cam.transform.localRotation = Quaternion.Euler(xRotation, 0,0);
        transform.Rotate(Vector3.up*(mouseX*Time.deltaTime)*xSensitivity);
    }
}```
austere grotto
#

That's your main issue

#

Also !code

sonic sageBOT
lament mountain
#

Interesting, thanks I will try that tomorrow. I had copied that code from a yt tutorial quite a long time ago

austere grotto
lament mountain
#

That might be why kek
Cool cat btw.

lament mountain
#

also additionally, even if Time.deltaTime was the issue, wouldn't that issue exist all the time and everywhere in the game?

#

Checking with the stats tab it shows that the place where my mouse is accelerated I have around 180 fps. Everywhere else I have around 400-500

austere grotto
#

you absolutely do NOT want deltaTime

austere grotto
#

Again, get rid of deltaTime, and adjust your sensitivity down to compensate

austere grotto
austere grotto
#

(which is a much more sensible value anyway)

lament mountain
#

yeah will try, thanks in advance

lament mountain
#

That seems to have done the trick

#

although I have to set my sensitivity to 0.05 for it to be playable

austere grotto
lament mountain
#

yeah but I tried all different settings for it and it didn't make much of a difference

#

I used my standard of 2400 DPI, but also the highest of 25600 DPI

austere grotto
#

A standard DPI is like 800?

remote bough
#

anybody know why these occur? I am not sure how to debug this

austere grotto
echo latch
#

at first it was working just fine, until I added the event system

#

now it stops working and only starts to work again when I reload the scene several times

#

even when I remove the input system again it does not fix it,

#

there are two player inputs, does this have something to do with it?

austere grotto
#

unless you have multiple players

#

each one monopolizes a set of devices

echo latch
austere grotto
#

Seems like you should have 0

echo latch
#

everytime i deleted the player input

#

it stops working

austere grotto
austere grotto
echo latch
#

the input

#

this do not work without the playerinput, so I think is required for some part of the code, I was not the guy responsible for that part, just trying to salvage as fast as I can

#

but later I shall see how to better organize this

remote bough
austere grotto
#

What kind of setup are you using?

remote bough
#

yeah when I saw that I was like welp im doing something terrible

#

I think I sort of narrowed it down essentially I was holding down a button and then the scene switches and that error happens whenever I press that bind again

#

my hunch is it has something to do with event subscriptions but I am unsubscribing from everything I can find...

stuck ingot
#

with the new input system is there a way to find the KeyControl on the current keyboard via a string input? For example I want to store "aKey" as a reference, and then determine if Keyboard.current.aKey is pressed, where aKey may be a different value

gloomy arch
#

is there a known bug for the Processor Editor stuff in the unity 6 preview?
I copied and pasted the exact stuff from the docs to sanity check since my vector3 one doesn't display the field and I can't get any version to properly display unless it's a primitive type WITHOUT a custom editor
the scale and invert ones are built in to the package but they work PepeShrug

stuck ingot
austere grotto
#

This has nothing to do with the input system as far as I can tell

tame oracle
#

Oh sorry i didn't mean to send that in this channel 😭

bleak basin
austere grotto
bleak basin
#
InvalidOperationException: 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.GetButtonDown (System.String buttonName) (at <37f4ee0fc1934e1aba69cbe63e6dcdcd>:0)
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:503)
austere grotto
bleak basin
#

I have no idea why it puts so many weird stuff to it.

austere grotto
#

That's beause you're using the old StandaloneInputModule

#

Take a peek at your Event System object in the scene

bleak basin
#

Ok let me retry

#
Action 'left' not found in the Input Action Asset.
UnityEngine.Debug:LogError (object)
ControlsButtonScript:Start () (at Assets/Scripts/UI/ControlsButtonScript.cs:40)

Even though I have a key that is supposed to point left, that currently being A

#

Though nothing lets me specify "hey, yea game, THIS is left, please don't be complicated about it"

#

I already put my player controls script into it

austere grotto
bleak basin
#

The window where I put the keybinds in doesn't have a way to name them, I already tried to see.

austere grotto
#

(it was relevant to the earlier error)

#

You need to open your input actions asset

#

your actions are defined there

austere grotto
bleak basin
austere grotto
#

you have configured it... completely incorrectly

bleak basin
#

I did it like the tutorial did, I added the keys and the binds

austere grotto
#

If a tutorial told you to do that, you should throw it away and find a different tutorial

#

This is a more typical setup example:

#

you define actions

#

and bindings for each action

#

Since you don't currently have an action named "left" your code that tries to find such an action of course fails

bleak basin
#

Okay I'll try that

austere grotto
#

Notice how the action name is gameplay relatd

bleak basin
#

Thanks, I will test it now.

#

In this part, I get sent Action 'left' not found in action 'left'.

void Start()
{
    if (buttonImages == null)
    {
        Debug.Log("No images in buttonImages!");
    }

    if (isUp) { actionName = "jump"; }
    else if (isLeft) { actionName = "left"; }
    else if (isRight) { actionName = "right"; }
    else if (isRun) { actionName = "run"; }
    else if (isShoot) { actionName = "shoot"; }

    // Find the action from the Input Action Asset
    action = inputActionAsset.FindAction(actionName);
    if (action == null)
    {
        Debug.LogError($"Action '{actionName}' not found in the Input Action Asset.");
        return;
    }

    // Enable the action
    action.Enable();
}
austere grotto
bleak basin
#

Yes

austere grotto
#

can you show a screenshot of that?

bleak basin
austere grotto
bleak basin
#

This one?

tulip tartan
#

That is a component from unity

bleak basin
#

I see the top, let me put things in it

austere grotto
#

the one attached to your object in the scene

tulip tartan
tough sail
#

I have a bit of a strange question. I'm FINALLY starting to get into the new input system. Been using a combination of InControl and the old system for years. The thing is, I want to know what is the best way to know if an element/item is being hovered over? In the old days it was OnMouseXXX(). What is used now?

austere grotto
#

IPointerEnterHandler/IPointerExitHandler

#

or the EventTrigger component

bleak basin
austere grotto
austere grotto
tough sail
austere grotto
#

that's the short answer at least

#

the long answer is it works with whatever you set up in the input module

#

the defaults are usually good enough

bleak basin
austere grotto
tough sail
austere grotto
bleak basin
#

Okay. I think I have to make it a script though, because I don't have a player in the scene. It's the Main Menu.

austere grotto
#

well I don't know anything about what this script is doing honestly

bleak basin
#

When the player clicks the rebind button, it should wait for the player to input a key, then it should rebind, for example, the left key to be j instead of a if the player pressed j.

austere grotto
#

sure but I havce no idea why it wants to reference the "Player Control" thing

#

or what it's doing with it

bleak basin
#

I copy pasted it from somewhere because I have no idea how to do it.

#

Should I just start this script from scratch?

normal dagger
#

Does anyone know how I make this button component call a void function from a script in the MainMenu object? Should it even be in "Target"?

austere grotto
# normal dagger

You need to start by setting your inspector back to normal mode. It's in debug mode right now

normal dagger
#

Ooooh that's why it look weird

normal dagger
dull echo
#

How can I make a weapon switching with the new input system

#

I want to make it using mouse scroll

tulip tartan
dull echo
#

I have made 2 weapons just some cylinders for testing purposes. Ill send the script.

#

In this video I built on top of the last one and continue working on the weapon system by adding weapon switching.

PROJECT LINK: https://github.com/Plai-Dev/weapon-system/

Like & Subscribe!

Timestamps

00:00 Intro
00:03 Changing Shoot Point
00:34 Adding More Weapons
01:15 Weapon Switching
03:27 Preventing Bugs
04:10 Outro

Socials:
Discord: h...

▶ Play video
dull echo
#

Never Mind I figured it out

distant sphinx
#

Hey I'm subscribing to InputSystem.onDeviceChange manually myself to detect new devices being added to then create InputUsers by doing InputUser.PerformPairingWithDevice myself, but its not quite working as I expected after entering Play Mode, as the keyboard does not get detected and the controller just gets detected when first plugged in

#

I mean, I guess it is working as intended, because the keyboard does not change as its already plugged in, and neither does the controller after its initial connection

#

But I don't know how I should do it instead

#
    public static class DeviceUtilities
    {
        private static SystemDefaultActions inputActions = new SystemDefaultActions();

        public static void EnableJoining()
        {
            Debug.Log("Joining enabled");
            InputSystem.onDeviceChange += DefaultOnDeviceChange;
        }
        public static void DisableJoining()
        {
            Debug.Log("Joining disabled");
            InputSystem.onDeviceChange -= DefaultOnDeviceChange;
            if (inputActions.System.enabled)
            {
                inputActions.System.Disable();
            }
        }

        public static void DefaultOnDeviceChange(InputDevice device, InputDeviceChange change)
        {
            Debug.Log($"Device change detected: {device.displayName} - {change}");
            if (change == InputDeviceChange.Added)
            {
                // Listen for actions from the new device
                var actionMap = inputActions.System;
                if (!actionMap.enabled)
                {
                    actionMap.Enable();
                }

                // Register the action callback, this should be pressing L+R in a controller or Space in a keyboard
                actionMap.UserJoin.performed += context => DefaultCreateNewUser(device, context);
            }
        }

        public static void DefaultCreateNewUser(InputDevice device, InputAction.CallbackContext context)
        {
            if (context.control.device == device)
            {
                InputUser user = InputUser.PerformPairingWithDevice(device);

                Debug.LogWarning($"Device {device} paired with user {user.index}");

                // Unsubscribe from the action callback
                var actionMap = inputActions.System;
                actionMap.UserJoin.performed -= context => DefaultCreateNewUser(device, context);

                // Disable the action map
                actionMap.Disable();
            }
        }
    }
#

Basically the idea is that you can add as many devices as you want but unless the game allows you to join and you do the join action you aren't registered in the game

#

plus some other stuff i have around, but thats after joining

#

(this is also supposed to support multiplayer, in case anybody sees im doing something wrong)

austere grotto
distant sphinx
#

I'm using DOTS

austere grotto
#

Probably still worth it, IMO

#

3-4 GameObjects won't kill you

distant sphinx
#

I used it previously and I ended up writing my own variation of player input manager and i just scrapped all of it as there were some issues with device and user pairing (i wasnt able to use both a controller and the keyboard to move my character, where i could before by using PlayerInputManager)

#

And I extremely simplified it to the bare minimums, which as of now its just that

fresh galleon
#

still feels like re-inventing the wheel. I believe the PlayerInputManager solution is already pretty light-weight, so just because you're not using absolutely all of it's features doesn't mean you should implement your own, most likely worse, solution to input

distant sphinx
#

I still would rather do it manually

#

I just need the InputUser which I then shove into a component in an entity, which I would then do whatever I want with systems

quartz geyser
#

Hello, I'm trying to understand the 1D axis of the input system, I've set it up like this:

#

It's all working fine except it never goes back to 0, is that expected behavior?

austere grotto
#

Probably you're subscribing only to the performed event and not canceled for example

quartz geyser
#

SO let's say I press Q it return -1 but when I release it it's still returning -1

austere grotto
#

Again, you'd have to show your code

quartz geyser
#

Sure

austere grotto
#

Have you tried adding Debug.Log

#

To OnRotate

mighty spade
#

How is the new input system usually managed, do you put all inputs into 1 class?

austere grotto
#

there isn't really a "usual" by the way, the system can and is used in many different ways by many different games

mighty spade
#

Like have 1 class that stores all the values which other gameobjects can read

austere grotto
#

No that doesn't seem like a great approach

#

That sounds like adding an unecessary middleman

#

But it really depends on your game and your circumstances

mighty spade
#

Coming from web dev, it's normal to have 1 class that has it's purpose to not mix all stuff together

austere grotto
#

There already is such a class

#

InputActionAsset

mighty spade
#

I use that but to read input from it I have to pass it many places to make it work with my state system

austere grotto
#

how is that different from passing your proposed class to many places?

mighty spade
#

To avoid using many different names and know that the name means it has something to do with input

austere grotto
#

No idea what you mean by that

mighty spade
#

it's more that when I modify something I have to back paddle a lot to fix it

#

and it get's more confusing as the project grows

#

So I normally would solve it by making classes for each purpose. Like bulletphysics class, input manager, state manager etc. As I'm fairly new in game dev the approach might be different.

austere grotto
#

What kind of change would you make and what backpedalling would result?

mighty spade
#

For example, I want to disable all inputs with a single function, or I want to add a new input that can modify another input and have it apply to five other states. I want to avoid to go into the 5 other states to add that functionality

austere grotto
keen fulcrum
#

Hi I recently start learning and I want to disable movement related action maps on first scene but I can't do that what am I doing wrong

bright stump
#

Does everyone use the new Input system? Because reading the limitations it seems to still have issues - UGUI not consuming key presses, Monobehaviour mouse methods not supported etc.

austere grotto
distant sphinx
distant sphinx
#

I guess I should look again into the input player manager, after all I did get that modified version off it before even if was janky

#

something im doing wrong with that new code when compared to that

stark solstice
#

I made two keyboard control schemes - "Default" and "Pro". Im trying to use PlayerInput.SwitchCurrentControlScheme to swap between them, but no matter what I do it seems like both schemes are active at the same time. Am i misunderstanding what control schemes are? I want two differnet layouts the player can swap between.

austere grotto
#

Probably a hardware issue

#

your keyboard doesn't support that key combination

blissful sierra
#

how to add 2d Vector composite

timid dagger
# blissful sierra

First, you need to change the action type and control type, then you can add composites

loud light
#

It would be great if Unity simplified this input system starting with Unity 6 and discontinued the input manager. It's annoying having to manage 500 packages just to create the inputs

#

at least for me it took almost 3 days

tulip tartan
loud light
#

it would be pretty cool if unity make an update only to optimize the storage size of the packages and remove (or hide) some legacy stuff

#

when i first started at unity (coming from game maker 2) i looked at the open editor, took a deep breath and thought: "there's too much stuff, im really screwed"

austere grotto
loud light
#

For real

tulip tartan
blissful sierra
#

@timid dagger nah

#

still

#

doesn't work

#

i cant see 2dvector

#

oh i see

#

is that up left down?

#

lmao

timid dagger
blissful sierra
#

i have a some questions

timid dagger
blissful sierra
#

so it is against the rules

timid dagger
#

Btw, after selecting Control Type as Vector2 you will also be able to select sticks/d-pads in regular bindings.

timid dagger
haughty magnet
#

im facing an issue where if I touch twice quickly, the second touch does not get registered.

void Update()
    {
        foreach (Touch touch in Input.touches)
        {
            if (touch.phase == TouchPhase.Began)
            {
                Debug.Log("Start. touch state: " + touch.phase);
            }
            else
            {
                if (touch.phase != TouchPhase.Stationary){
                    Debug.Log("Update. touch state: " + touch.phase);
                }
            }
        }
    }
#

The console log is like this. The bracket being the action im taking

(screen touched)
Start. touch state: Begin
(touch release, and touch again quickly)
Update. touch state: Ended
#

any ideas how I can solve this?

lost swift
#

Guys i found a bug in input system, and i need help to fix it.

So if you using Button action, and you press this button then while pressing that button you do alt+tab, it will no more be pressed, but release trigger also not called.

What can i do to fix it?

timid dagger
austere grotto
#

But yeah using OnApplicationFocus is the workaround

lost swift
#

Thanks guys for help!

tame willow
#

Hello,
I am working on a weapon system, now in the new inputs system, there isn't a "GetKey" , "GetKeyDown"
so I am using a performed and canceld events to check, is this the right way ?

lost swift
lost swift
tame willow
lost swift
#

When i say first frame, i mean only 1 frame

tame willow
lost swift
#

And IsPressed() is for GetKey

tame willow
#

Ok, Thanks for that

marble lotus
#

anyone have any idea why the Sector interaction from the XRToolkit doesn't play nice? Won't let me configure it. Unity 6000.0.5f1

#

when it's something it doesn't like, it does at least stipulate that, but when it's supposed to work it doesn't. if that makes sense.

marble lotus
#

Good point, I'll leave a link there 🙏

zenith shuttle
#

Hello! I have two characters in my 2D scene and two input maps. As it stands now, I also have two seperate scripts, for movement. I'd like to make one script that has a slot to assign an input map, just to streamline things. I've tried to achieve as such by doing what I did below -

public InputActionAsset _fieldControls;

private void Awake() {
    _fieldControls = new InputActionAsset();
    ...
    _moveAction = _fieldControls.Player.Move;

which does result in getting the option to choose the input map when attaching the script to an object like shown.

#

However, it results in the compiler error, also attached to this as an image. How can I fix it so that I can assign an input map to the script outside of the .cs file but still have that script work with that map?

still trout
#

and this is the config for it

zenith shuttle
still trout
#

basically once i spawn a new player i attach the InputController to it which loads the default input map and binds it to the device that triggered the new player creation (keyboard + mouse, controler 1, controler 2) etc

#

if you instead change the map instead of the bound device you can bind a different map to each player

austere grotto
zenith shuttle
austere grotto
#

use the correct type in your code

steady walrus
#

anyone ever use the input system with nintendo switch joycons? simply cannot get right stick to work

willow scarab
#

Whatever nintendo's doing with the joycons, it seems intentionally proprietary and most stuff is easily buggy around them

tawdry heart
#

I'm working on migrating a project from the legacy input to the new input system, is there a way I can easily map something like "Joystick Button 10" to a specific button on a gamepad??

#

I need the equivalents of JoystickButton N to gamepad button, this is because the game uses an alternative controller for inputs so the specific buttons are very important to keep the same

austere grotto
tawdry heart
#

I don't have access to the layout/mapping of Alternative controller input to gamepad input

tawdry heart
#

I'm just trying to figure out what would be "JoystickButton8" for example to its corresponding generic gamepad button

austere grotto
#

I'm not sure I understand to be honest. You don't map buttons to other buttons, you map buttons to actions

tawdry heart
#

Hckskgkdkg ok lemme try to explain it better

#

Gonna log in on PC for screenshots n stuff

#

things are worse than i thought, but basically the game currently uses the KeyCode system and the Input.GetKeyDown methods.

In this picture, Element 0 is set to JoystickButton10, and Element1 is set to JoystickButton8

Since KeyCodes are not something that properly exists in InputSystem, i need to basically map the "Equivalent" gamepad button to it.

Ergo, how could i know which "Gamepad" button is "equal" to JoystickButton8, for example.

sick roost
#

Hi everyone! This is my first post on the Unity Discord, so I'm hoping I'm putting it in the right place. My company AccessVR has a Unity-based VR app that we use to distribute training content. We recently decided to port the app from VR to the iPad. I am doing all of this work myself. At the moment, I have a working version of the app, but the implementation feels fragile. I was hoping that we could find a way to map Touchscreen input actions through the XR Interaction Toolkit—this way, all of the interactivity in our experiences could be implemented once, and consistently, no matter whether the experience is playing through a HMD (like Quest) or on a tablet (like iPad). Happily, this sort of works, but only if the UI elements are fixed to the Camera's Z axis. It's as if the raycasts for the touchscreen events are always being drawn to some point that is really close to the camera instead of to a point that is predicted to be on the other side of the UI, allowing the ray to intersect... well... anything. Additionally, putting the UI Canvas into Screen Space, which is ideal for 2D platforms like the iPad, means they don't receive the input actions at all, even if the UI is fixed to the Z axis. Bottom line: if I put some UI out in Worldspace in a way that is not fixed to Camera Z axis, the touch screen input coordinates don't land where they should. I can work around this by adding some manual raycasting to every UI element, using Touchscreen input actions to trigger the drawing of rays, but this really defeats the purpose and simplicity of the XR Interaction Toolkit. And not being about to use Screen Space means I can't take advantage of things like dynamically resizing canvas (without coding the resize events myself). Has anyone tried anything like this before? Is there a technique I'm missing? It feels like this should work, if only I knew what I don't know I don't know 🙂

silk pasture
#

is there a way to detect whitespace characters using Keyboard.current.onTextInput in WebGL builds? From my testing it properly invokes with standard letters but fails to detect backspace, esc, arrows and other similar whitespace chars.

~~Edit: Found a solution, but it needs to individually check non-printable characters:
cs
private void OnEnable()
{
Keyboard.current.onTextInput += OnKeyInput;
}

private void OnKeyInput(char key)
{
    if (Keyboard.current.backspaceKey.wasPressedThisFrame)
        Debug.Log("Backspace pressed!");
}~~

(doesnt work I was mistaken)

austere grotto
sick roost
# austere grotto I'd recommend using a Screen space UI for iPad. As for input working or not tha...

I thank you for your response—in the very least, it makes me feel like the way I'm describing our challenge makes sense. I think the thing I'm working to eliminate is using XR Interaction Toolkit to support both XR input bindings (like XR Controller/trigger) and Touchscreen input bindings (like Touchscreen/Press). What I have that is almost 100% functional is doing exactly this: we have a custom Action Map with a custom Action called "LeftClick_RightHand" (a weird name, I know, inherited from a much older version of the software), and it is triggered by the RightHand XR Controller/trigger binding as well as the Touchscreen/Press binding. That action is assigned to the UI Press Action input property of the XR Controller (Action-based) component on the RightHand Controller game object in our XR Player Character prefab. Through all of the prewired elements of the XR Interaction Toolkit, this means that pulling the trigger on an XR Controller and touching the screen of the iPad both have the same end result: the XR Ray Interactor casts a ray, the first element that gets touched is the thing being interacted with, and in the case of UI Canvas, the element receives a click. This works without any specific wiring on the UI elements: I don't have to tell a Button that it is specifically receiving "LeftClick_RightHand" action events, because the UI element is (I think) treated like an interactable, and so the XR Interaction Framework triggers it automatically. So again, I think where this all falls down is that the touchscreen events don't seem to have have Z axis rotation data—and the XR Controller trigger events don't either, but in the case of the XR Controller, the angle of the origin for the ray is set by whatever the transform rotation of the controller game object is at the time the trigger action fires. I just don't understand how to achieve the same thing in the touchscreen context without a custom raycaster—custom raycasting works, but then I have to...

#

...setup every UI element manually, instead of relying on the automatic "wiring" that the XR Interaction Framework does so elegantly.

#

I should note too that I am using AR Foundation here for the iPad app so that the user can "look around" in the VR space by rotating the device. And as I'm reading the AR Interaction section of the XR Interaction Framework guide, I think I am realizing that I'm missing a bunch of other built-in components such as the Screen Space Ray Interactor.

distant sphinx
#

I'm trying to use my switch pro controller, but when i press any button it doesnt recognize any, additionally i have generic bindings from "Gamepad", which should cover what im trying to do, but its not working either

#

the device does indeed get recognized as a switch controller
so I don't understand what is happening

#

theres absolutely zero events coming through

#

software that uses SDL input has no issues with my controller (it even reads gyro input, which is what im interested on right now), so its absolutely a Unity thing

#

turning the controller on and off doesn't do anything, other than unity losing the device and bringing it back

#

I'm going through the server's chat history and it seems other users had this issue years ago, but they were all unanswered

#

This is Unity 6, by the way

still trout
distant sphinx
#

I have a xbox controller and it works just fine

#

then there's obviously keyboard and mouse, which also do work fine and the actions i have do work fine

distant sphinx
#

For whatever reason now its sending one trillion events every second, this seems to line up with what some users say, but at least the buttons and mappings work now.

#

All I did was head to Steam and enable / disable their switch pro controller compatibility thing

#

Oh nevermind, its actually reasonable for it to send six million events, its probably the gyroscope

#

I do need to have steam running in the background for it to start sending data for some reason?

#

Actually enabling / disabling Steam Input for Switch Pro controllers on Steam just seems to have wake it up as it doesn't matter if its enabled / disabled it behaves the same

#

its just that enabling it "woke" it up?

distant sphinx
#

Anyways, gyro, is there a way to get it working? I tried binding it to "tilt" in many different bindings yet none works

#

only the right stick one is getting recognized

still trout
#

unity should be able to recognize the controler without steam acting as a connector

distant sphinx
#

I actually closed steam so its not running in the background and turning on / off the controller makes it no longer function in Unity

#

It just doesnt send any data

#

Actually, just opened Yuzu, and just doing that "woke" the controller up and its sending data again

#

Yuzu uses SDL, which is what I assume Steam uses internally as well (as it had Valve employees do commits to its repository regarding controllers)

#

closing Yuzu makes the controller stop sending data

#

So there's something that SDL applications do that tells (?) the controller to send data or not (????????????????)

#

I just launched Zenless Zone Zero which uses Unity and the same thing happened, the game didn't recognize my controller until I opened Yuzu

#

man.... what the hell..

#

This is all wireless, by the way

#

Thought I should mention it considering that most other users that also had this issue in the past said that wireless kinda sucks

still trout
distant sphinx
#

That is obviously not being the case, however

#

I can try wired in a bit

#

But third party software here is actually assisting it to work, otherwise it just doesnt work

#

(I just had Steam)

bitter lotus
#

I just added a friend as a collaborator and his inputs are not causing the character to move when it can work fine on my project. Is there a common issue that can cause this?

#

His project has the Input System package included, the scripts are all identical, etc. (he downloaded it straight from our repository)

distant sphinx
#

Cant seem to be able to test it wired because it just gets forced to run as XInput

distant sphinx
#

SwitchProControllerHID has no members holding data for gyro, though

distant sphinx
#

I tried creating a Vector3 action and binding it to gyroscope and accelerometer paths, and it did absolutely nothing

distant sphinx
#

You know, so it automatically gets wired up with that default gyroscope and accelerometer bindings that the input system offers

#
        public const string SwitchProControllerGyro = @"{
          ""name"": ""SwitchProControllerHIDSensor"",
          ""extend"": ""SwitchProControllerHID"",
          ""controls"": [
            {
            ""name"":""accelerometer"", ""displayName"": ""Accelerometer"", ""format"":""VC3S"", ""offset"":19,
            ""layout"":""Vector3"", ""processors"":""ScaleVector3(x=-1,y=-1,z=1)"", 
            ""usage"": ""<Accelerometer>/acceleration"",
            ""noisy"": true
            },
            {""name"":""accelerometer/x"", ""format"":""SHRT"", ""offset"":0 },
            {""name"":""accelerometer/y"", ""format"":""SHRT"", ""offset"":2 },
            {""name"":""accelerometer/z"", ""format"":""SHRT"", ""offset"":4 },
            {
            ""name"":""gyroscope"", ""displayName"": ""Gyroscope"", ""shortDisplayName"": ""Gyro"", ""format"":""VC3S"", ""offset"":13,
            ""layout"":""Vector3"", ""processors"":""ScaleVector3(x=-1,y=-1,z=1)"",
            ""usage"": ""<Gyroscope>/angularVelocity"",
            ""noisy"": true
            },
            {""name"":""gyroscope/x"", ""format"":""SHRT"", ""offset"":0 },
            {""name"":""gyroscope/y"", ""format"":""SHRT"", ""offset"":2 },
            {""name"":""gyroscope/z"", ""format"":""SHRT"", ""offset"":4 }
          ]}";

this is what I have right now, usage just doesn't work

distant sphinx
#

Okay i got it to work, just had to add it to the action

#

So as a breakdown, that layout there exposes gyroscope and accelerometer data, that can be used as a layout override with InputSystem.RegisterLayoutOverride(LayoutJson);
I managed to figure this out thanks to a Unity Japan video https://www.youtube.com/watch?v=D66gfvktrnM which has example code in a repo in the video description, and actually goes to explain gyro and other stuff

最近の FPS, TPS はゲームパッドのジャイロ入力に対応していることがありますよね。これを Unity の Input System を使って実装するにはどうしたらいいんだろう……と思ったので、試しに作ってみました! ジャイロ入力を作ってみたい!と思っていた方はぜひ参考にしてみてください。

サンプルプロジェクト:
https://github.com/keijiro/GyroInputTest

0:00 イントロ
0:38 DualShock 4
1:28 カスタム拡張定義
2:43 動作確認
3:26 簡単なサンプル
4:44 問題点
5:31 問題の解決
7:38 再び動作確認
9:12 まとめ

▶ Play video
#

Also looking through this server's message history, this user had a issue with Filter Noise on current toggled on not working as expected with the Switch Pro Controller. That problem went entirely unanswered at the moment but it happens because the controller by default isn't marked as noisy

#

More resources to read would be https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/imu_sensor_notes.md , which says things like Internally Switch uses revolutions per second instead of degrees. That's why the gyro calibration is always 13371. which would explain some other issue I've read in the chat history where an user was confused about the data that the controller was giving

GitHub

A look at inner workings of Joycon and Nintendo Switch - dekuNukem/Nintendo_Switch_Reverse_Engineering

#

I hope this info dump assists anybody that tries to search through the server for help on the Switch Pro Controller, especially about motion controls / gyroscope / accelerometer, though using Discord as info storage isn't the most ideal.

iron socket
#

I'm trying to test out my input system on my Android using Unity Remote 5, but it's really glitchy and freezes often. Do you have any advice? I followed the steps here to get it working, and it does play on my Android but it freezes and I need to restart Unity Remote 5 quite often. Here are the steps I followed:
https://stackoverflow.com/questions/65642880/commandinvokationfailure-unity-remote-requirements-check-failed/66345155

#

I'm using Android 10.0 but I set the minimum to be 9.0 'Pie' and the game does come up on my phone, it just freezes a lot, sometimes immediately.