#🖱️┃input-system

1 messages · Page 25 of 1

woven berry
#

i will just re-do it in new iterations, im replanning everything anyway

warped silo
#

Hello, I am doing a school project an on Unity XR application for the mobile, I have set up my XR environment with the AR session, XR origin and a simulated environment.
I would like to implement the strategies for handling touch-screen input, mainly single-tap for select, swipe rotate, pinch for resize.
The problem is that disabling the AR Input Manager breaks the surface recognition.
Does anyone know how I could attempt my own seprarate input manager while keeping the rest of the features intact?

austere grotto
warped silo
#

No, can you explain in short what it allows? I will document on it separately if it's what I need

strange parrot
#

How do you find the correct InputControl for a InputDevice given a binding path such as "*/{Submit}" or "<Gamepad>/buttonSouth"?

strange parrot
#

Alright seems like InputControlPath.TryFindControl(inputDevice, bindingPath) was exactly what I needed

thin moat
#
using UnityEngine;

public class MainMenu : MonoBehaviour
{
    public Animator mainMenuBookHolder;  // Animator for the book UI
    public GameObject canvasInventory;   // Reference to the Canvas that holds the menu

    private bool isMenuOpen = false;     // Track if the menu is open

    void Start()
    {
        canvasInventory.SetActive(false); // Ensure the canvas is hidden initially
    }

    void Update()
    {
        // Listen for Escape key press to toggle menu
        if (Input.GetKeyDown(KeyCode.V))
        {
            if (isMenuOpen)
            {
                CloseMenu();  // Close menu if it's open
            }
            else
            {
                OpenMenu();   // Open menu if it's closed
            }
        }
    }

    // Open menu with animation
    public void OpenMenu()
    {
        canvasInventory.SetActive(true);                 // Show the canvas
        mainMenuBookHolder.SetTrigger("OpenMenu");        // Trigger the "OpenBook" animation
        isMenuOpen = true;
    }

    // Close menu with animation
    public void CloseMenu()
    {
        mainMenuBookHolder.SetTrigger("CloseMenu");       // Trigger the "CloseBook" animation
        isMenuOpen = false;

        StartCoroutine(DisableCanvasAfterAnimation());
    }

    // Disable the canvas after the "CloseBook" animation finishes
    private IEnumerator DisableCanvasAfterAnimation()
    {
        yield return new WaitForSeconds(1f); 
        canvasInventory.SetActive(false);     // Hide the canvas
    }
}```

i think it s not detecting my input i have no output errors
austere grotto
cerulean brook
#

guys i'm having a problem with the new input system and cinemachine, i want to use the action map that i created for the mouse movement and i when i pause the game i disable the input so the camera is not moving, but the camera continues to move with my mouse when i disable the input, any ideas?

austere grotto
#

for example how did you hook the input up to the camera?
And how did you "disable the input"?

cerulean brook
austere grotto
# cerulean brook

the problem is you're not disabling the action maps on the correct instance of the input action asset

#

the input action reference on the axis controller refers to the asset itself in your assets folder

#

the one in your code refers to the new copy you created of the C# wrapper class with new()

oblique raven
#

how do you determine if the key was pressed once (GetKeyDown) in the new input system the Move works but it fires every frame

#
public void Fire(InputAction.CallbackContext callbackContext)
{
  if(callbackContext......) <<
}
```` something like that
#

ah never mind it is performed

#

and now how do you get the getkey event

#

it only fires 2 times but not every frame

fierce compass
#

set a flag when it's pressed and clear that flag when it's released

oblique raven
#

it only fires 2 times when pressed and when released

fierce compass
#

yeah, and you can set something to 1/true when it's pressed and then set that variable back to 0/false when released

oblique raven
#

i get what you say but this is kind of tricky. why is there not a predefined soloution

fierce compass
#

because inputsystem is stateless, you have to keep track of the state yourself, and in doing so, you get a much cleaner state where it's clear what you're recording

#

with the old inputs, the state was internal to Input

#

granted, inputsystem isn't fully stateless, it still keeps track of like, hold duration for interactions, but you're the one driving

oblique raven
#

thanks.

austere grotto
#

or a coroutine

#

It's a misconception people have that the new input system doesn't support polling input in Update

#

THe new input system supports both polling and event based input handling.

oblique raven
#

but the problem is that i am binding the Fire butotn to the Fire action,

#

i need to assign a method, no idea how to use it inside update

austere grotto
#

You mean you are using UnityEvents

oblique raven
#

instead of sendmessage event yes

austere grotto
#

this is for event based handling, yes. You have two main options:

  1. do what you're doing now and just set a bool:
bool isFiring = false;

public void Fire(InputAction.CallbackContext ctx)
{
  if (ctx.started) isFiring = true;
  else if (ctx.canceled) isFiring = false;
}

void Update() {
  if (isFirting) DoSomething();
}
  1. Don't use the event-based handling at all. Just poll the InputAction directly in Update:
[SerializeField]
PlayerInput myPlayerInput; // assign this in the inspector

InputAction fireAction;

void Start() {
  fireAction = myPlayerInput.actions["Player/Fire"]; // assuming your action map is called Player
}

void Update() {
  if (fireAction.IsPressed()) DoSomething();
}```
oblique raven
#

with the 2. method i need to press the "generate class" or

austere grotto
#

no, that's another thing altogether

#

that would be to not use the PlayerInput component at all

oblique raven
#

oh boi what a mess 😉

austere grotto
#

which is also an option

#

there are many, many ways to use the input system

oblique raven
#

why did unity decide to go for sucha user unfriendly method. i mean it requires so much testing nd trying aaround and of course reading docs and watching videos.

austere grotto
#

with the generate class thing you could get rid of the PlayerInput component entirely and just do this:

MyInputClass myInput; // assign this in the inspector

void Awake() {
  myInput = new MyInputClass(); // the generated script, whatever you called it.
}

void OnEnable() {
  myInput.Enable();
}

void OnDisable() {
  myInput.Disable();
}

void Update() {
  if (myInput.Player.Fire.IsPressed()) DoSomething();
}```
oblique raven
#

which approach do you use usually

austere grotto
#

THe old system is really easy for a newbie to learn and make a prototype but when it comes to making a real production game, it's insufficient

oblique raven
#

yeah the cross plattform support is really superioir

austere grotto
#

If you are making anything with local multiplayer, I stick to PlayerInputManager/PlayerInput, because it makes it way simpler to handle players/devices joining and leaving.

#

For anything else I usually use the generated C# class with a singleton input manager that manages a single instance of the generated class.

#

the singleton is not to do input handling in one place, it's juist to manage the instance

#

I let individual scripts get direct access to the single instance of the input class so they can choose to do event based or polling input as needed

oblique raven
#

ty Praetor i learnt something new 😉

#

seems to be by far the easiest and best method to use

cerulean brook
cerulean brook
#

ok forget about it, i fixed it, thank you!

stark sky
#

Hello everyone,
I have a problem with new Input System acceleration.
I am creating simple 2D game on Android but when I am shaking phone it is not working.
When I am playing it in OLD input it works perfectly... but I have to many scripts related to new input and you can't choose both for android game...
this is code on which I am testing the acceleration.

using UnityEngine;

public class ShakeToVibrate : MonoBehaviour
{
    // Sensitivity for shake detection
    public float shakeThreshold = 2.5f;

    // Time interval between shakes to avoid continuous triggering
    public float shakeCooldown = 1.0f;
    private float lastShakeTime = 0.0f;

    void Update()
    {
        // Check if enough time has passed since the last shake
        if (Time.time - lastShakeTime >= shakeCooldown)
        {
            // Check if a shake is detected
            if (IsShakeDetected())
            {
                // Trigger the vibration
                Handheld.Vibrate();

                // Update the last shake time
                lastShakeTime = Time.time;

                Debug.Log("Shake detected! Vibrating...");
                Destroy(gameObject);
            }
        }
    }

    bool IsShakeDetected()
    {
        // Get the current acceleration (device motion)
        Vector3 acceleration = Input.acceleration;

        // Calculate the magnitude of the acceleration vector
        float accelerationMagnitude = acceleration.sqrMagnitude;

        // Log the current acceleration magnitude for debugging
        Debug.Log("Acceleration Magnitude: " + accelerationMagnitude);

        // Check if the magnitude exceeds the threshold for a shake
        return accelerationMagnitude >= shakeThreshold * shakeThreshold;
    }
}

austere grotto
#

If you are set up to use the new system, this will not work.

#

You have to migrate the code to use the new system.

stark sky
#

i fixed it

#

thx for help

#

I didn't enable the input on start...

viral flicker
#

can you poll inputs from a PlayerInput object?

austere grotto
#

Which you can grab with the .actions property on it

viral flicker
#

i need to have a list of "Input"s from different player input objects

austere grotto
#

those are two completely different workflows

viral flicker
austere grotto
#

example of polling "from a PlayerInput":

[SerializeField]
PlayerInput pi;

void Update() {
  InputAction upAction = pi.actions["Play/Up"];
  if (upAction.IsPressed()) // blah blah
}```
austere grotto
#

and it makes a new instance of the asset when you new it

viral flicker
#

so like 10?

viral flicker
austere grotto
austere grotto
#

If you aren't using those, you have to handle it yourself

viral flicker
austere grotto
#

If you want individual variables for them

viral flicker
#

is there a way to like

austere grotto
#

That's the thing the generated C# class conveniently does for you

viral flicker
#

i see

#

i dont feel like manually pairing actions with devices

#

so i'll just do it the long way

austere grotto
#

You can always just do pi.actions["Play/Up"].IsPressed() on demand

#

there's no requirement you make a variable for it

#

compare that with myActions.Play.Up.IsPressed() in the generated class

#

it gives you a little compile safety

viral flicker
austere grotto
#

I'm sure there's overhead associated with it

#

like anything in the world

#

unlikely to be significant but you can always profile it

viral flicker
#

okay

#

thank you!

#

i think thats easier than what i had planned

austere grotto
#

If you want it too you should give me a like/bump 😜

viral flicker
#

just liked 😉

#

why are these diabled?

#

i wasnt getting any inputs from the controller so i checked the debugger

#

and theyre all disabled

marsh mulch
#

If you're not using default player input components

wanton oriole
#

for camera control on the mouse, the path used to be called Delta [Mouse]
does anyone know the new path for the input system?

austere grotto
#

You could and still can create a binding for mouse delta

#

Nothing has changed there

#

If it's not showing up you probably didn't configure the action correctly

#

It needs to be Value/Vector2

oblique raven
#

is there no equiliant to GetAxis in the new input system. I only get the normalized value when using ReadValue so 1 or -1 but not the range as used before in the GetAxis

#

changed the option to analog on the playerinput map doesn´t work either

fierce compass
#

is GetAxis supposed to go over magnitude 1?

austere grotto
#

There's no equivalent to that smoothing in the new system

#

It's extremely simple to write it though

#

It's literally just Mathf.MoveTowards in Update

oblique raven
#

allright thanks, was just wondering

robust harbor
#

Is using OnScreenControl with UI Toolkit still viable solution? Or there is alternative to?

austere grotto
#

Yes it's viable

surreal drum
#

I'm struggling a bit with an issue regarding the input system. I had a friend set it up for me, and I don't think I fully grasp how to work with it.
In my game, I switch between UI and Player action map, which is fine whenever there's UI enabled. However, I also have some "in game" UI that I want to be able to interact with on mouse button press while the Player action map is enabled.

#

I have made this button that "slides" in the inventory from the right on press, and slide it back out of the screen on another press. This only works once, since the game starts with both UI and Player action map enabled, for some reason. After that, it doesn't work

#

As you can see in this recording. I've put two squares on the screen. Top one shows green if Player action map is enabled, bottom one shows green if UI action map is enabled. How should I tackle this?

#

Can I make a button independent from the UI action map?

#
public class PanelSlider : MonoBehaviour
{
    public RectTransform movablePanel;
    public float slideDuration = 0.5f;
    public InputActionAsset inputActionAsset;
    private bool isPanelOpen = false;
    private Coroutine slideCoroutine;
    private InputActionMap playerActionMap;
    private InputActionMap uiActionMap;
    private Vector2 openPosition;
    private Vector2 closedPosition;
    private void Awake()
    {
        if (inputActionAsset != null)
        {
            playerActionMap = inputActionAsset.FindActionMap("Player");
            uiActionMap = inputActionAsset.FindActionMap("UI");
        }
        openPosition = new Vector2(-movablePanel.rect.width / 2f, movablePanel.anchoredPosition.y);
        closedPosition = new Vector2(movablePanel.rect.width / 2f, movablePanel.anchoredPosition.y);
    }

    // Method to be called by the button
    public void TogglePanelPosition()
    {
        if (slideCoroutine != null)
        {
            StopCoroutine(slideCoroutine);
        }

        isPanelOpen = !isPanelOpen;
        Vector2 endPosition = isPanelOpen ? openPosition : closedPosition;
        slideCoroutine = StartCoroutine(SlidePanel(endPosition));
        if (!isPanelOpen)
        {
            SwitchToPlayerInput();
        }
        else
        {
            SwitchToUIInput();
        }
    }
    private IEnumerator SlidePanel(Vector2 endPosition)
    {
        Vector2 startPosition = movablePanel.anchoredPosition;
        float elapsedTime = 0f;
        while (elapsedTime < slideDuration)
        {
            movablePanel.anchoredPosition = Vector2.Lerp(startPosition, endPosition, elapsedTime / slideDuration);
            elapsedTime += Time.deltaTime;
            yield return null;
        }
        movablePanel.anchoredPosition = endPosition;
    }
    private void SwitchToUIInput()
    {
        playerActionMap?.Disable();
        uiActionMap?.Enable();
    }

    private void SwitchToPlayerInput()
}

#

Here's the script for the button, if needed ( had to delete SwitchToPlayerInput() cause my message got too long).

austere grotto
#

Also is it really necessary to create your own UI action map instead of just using the default one on the input module?

surreal drum
raven ether
surreal drum
raven ether
marsh mulch
#

Anyone know why tap gets negated if touch is held?

#

is there any easy way i could just accept the tap immediately

#

specifically talking about touchscreen controls

marsh mulch
#

For anybody wondering in the future, theres a [press] input for touchscreen

austere grotto
marsh mulch
#

specifically which type of inputs fire before others

austere grotto
#

There's no hierarchy

marsh mulch
#

how can i be sure that my press action will fire after touch position action?

#

as in I always need it to be UpdateTouchPosition => PressTouch when tapping the screen

#

Pretty sure its implicit so i shouldnt worry about it... was just curious

austere grotto
marsh mulch
austere grotto
marsh mulch
austere grotto
#

You call ReadValue

#

ReadValue<Vector2>() in this case

marsh mulch
#

Does press return you vector2 position??

austere grotto
#

No

#

Press is just for the press

#

You read the position from a separate action bound to the position

marsh mulch
austere grotto
#

No

#

I specifically said I would do this

#

I said I wouldn't use event based handling for the position

marsh mulch
#

how is reading the position from a seperate action not event based handling?

#

.performed is quite literally an event

austere grotto
#

For the position

#

Only for the press

#

We're directly polling the value for the position action

#

Instead of subscribing to an event on it

marsh mulch
austere grotto
#

I just told you

marsh mulch
#

As in whats the code

#

If you don't mind

austere grotto
marsh mulch
#

And that readvalue<> call would invoke the action?

austere grotto
#

I have no idea what you mean by invoking an action

#

It simply gets you the current touch position

#

Which is what we want

marsh mulch
#

What are you reading a vector2 from bro 💀

austere grotto
#

The input action

#

As I mentioned above

marsh mulch
#

Press doesn't return vector2 afaik, so we need to have two actions, click which reads touch/press and point which reads touch/position no?

austere grotto
marsh mulch
#

Ok what were you responding to when you said that?

#

It seems were in agreement

#

My question was whether not there was a way to ensure they invoked in that order, position, then click

#

But I said I'm pretty sure it's already implicit

#

As in position will always fire before press

austere grotto
#

I'm saying if you do it this way I'm describing it doesn't matter

#

All of the input values get updated before any of the events fire. So if we just read the position directly rather than from a variable we update with an event, we are guaranteed to get the most up to date value

marsh mulch
#

What would i have to do to this code to do it the way youre referring to, where you arent required to cache the position with an event?

#

ohhh i see, you can reference the data directly!

#

I thought you could only read from actions with the CallbackContext which is why i was confused

#

Makes sense

marsh mulch
austere grotto
marsh mulch
#

That's my bad

#

Super good to know that

robust harbor
#

Is it possible to set processor to on screen controls? Like add deadzone to on screen sticks

austere grotto
robust harbor
austere grotto
#

Are you trying to set this all up in code or something?

#

OnScreenControls works with string that is converted to InputControl using attribute.
Yes - and then you later bind that InputControl to an InputAction like any other control

robust harbor
#

I'm building stick control using ui toolkit.
I want to add deadzone to this on screen stick by assigning deadzone processor

I can't find a normal way to achieve my goal

austere grotto
#

by double clicking on your InputActionsAsset

#

you can also add it to this specific binding

robust harbor
#

Let me try something

austere grotto
#

Or a binding

#

there's nothing special about doing this when using an on-screen control

robust harbor
#

Added UGUI on stick control and deadzone processor is working. Gonna debug my code. Thanks for help

ancient hinge
#

alala input-system, what a thread xD

#

Hi ! I'm trying to get data from a virtual joystick ( image with On-Screen Stick component ), I well added the same control path as in my inputasset action, I can well move it but when I debug value it's always 0.. I have no errors :/

austere grotto
ancient hinge
#

I m using Unity 2022.3.47 with input system. and I noticed that if I put the ref to the module there it says I m not using same actionmap and ask me to fix it but after doing that all my UI are ded

#

nop !

austere grotto
ancient hinge
#

trying that now, thx

austere grotto
ancient hinge
#

oh ok

#

I m using unity events tho, do I need to suscribe before maybe ?

austere grotto
#

It's completely unrelated from your PlayerInput component

ancient hinge
#

with Enable() I still don't get anything else than 0 on debugging :/

austere grotto
#

You don't need PlayerInput if you plan on using InputActionReferences

austere grotto
#

Also it's only set up on the mobile control scheme

ancient hinge
#

what do you mean by that ? in the input manager ?

austere grotto
#

yes that's exactly what I mean

#

that part looks ok

#

I suspect it's a control scheme issue

ancient hinge
#

hmm I m using simulator and when I debug the left pad it s correctly receiving data

#

gonna show u

distant salmon
#

the PlayerInput has a reference to the InputActionAsset. Something strange happens when I enter play-mode, and the InputActionAsset is named Inputs (clone) instead of jsut Inputs. When this happens it also stops detecting input.

#

This happened after a restart of the editor.

#

in play-mode I tried swapping the Inputs (clone) for my actual InputActionAsset in my assets - but to no avail. The inputs still didn't come through.

#

I've also checked the hierarchy, and found no conflicting InputActionAssets that could be interfering with the one in the scene.

austere grotto
distant salmon
#

Hmm - this isn't the same for all my projects though. I have another one where the game runs fine and detects inputs. Here it just says "Inputs" without "(clone)".

#

Maybe the fact that it says "clone" isn't the problem, but it started happening when the inputs no longer register.

austere grotto
#

It will depend on the control schemes you're using and the devices connected

#

as well as the number of PlayerInput components in the scene

#

(btw you should only have one such component in the scene unless you're doing local multiplayer)

distant salmon
#

Keyboard and mouse are connected. No controllers.

distant salmon
#

searched the entire hierarchy in play-mode. There's only one.

elder bane
#

How can i change asset of this module via script ?

I am adding this component in runtime but when first run it finds default input asset reference in packages...etc etc

When i stop game and restart always give this error because its not reassign input asset reference anymore , how can i solve this issue or how can i set asset

InvalidOperationException: Action 'UI/Cancel[/Keyboard/escape]' must be part of an InputActionAsset in order to be able to create an InputActionReference for it
UnityEngine.InputSystem.InputActionReference.Set (UnityEngine.InputSystem.InputAction action) (at ./Library/PackageCache/com.unity.inputsystem/InputSystem/Actions/InputActionReference.cs:88)

Input System 1.11.2

austere grotto
elder bane
#

I wanted to add it automatically instead of checking if it was in the Game scene

austere grotto
elder bane
#

@austere grotto Yes that's exactly what I thought there's no other way i guess , thanks 👍🏼

austere grotto
#

There's definitely other ways

#

That's just by far the easiest

hollow quest
#

With the new inputsystem, it's possible to do InputSystem.DisableDevice(Keyboard.current).

Is there a way to do something similar but with a single key (or multiple) and without manually catching each input?

#

Or alternatively, only enabling a single input button with everything else disabled

#

Or maybe I can create a fake/virtual "Keyboard" that serves as a proxy, send all the key strokes to it, unless I disable that bridge

austere grotto
#

What's the end goal here??

mossy void
#

Hi, I've just updated the Input System package, but I'm getting nothing but errors — a relaunch of Unity hasn't done anything, and I'm not sure what to do next. Any help would be greatly appreciated!

austere grotto
#

Maybe just start with the library folder

mossy void
#

cheers

#

all working nicely now

vocal grove
#

Is it possible to ignore the system's touchpad natural scroll settings?
it feels quite jarring to scroll through the hotbar of my game when users have it enabled and scroll on the touchpad, at least if they're running Linux with Gnome like myself, in which case it seems to register as more or less a reverse scroll

#

I know an application should be able to ignore it since Minecraft does so

#

the question is if the new input system can do so

nimble patio
#

im using xr grab interactor but i need to disable the thumbstick to push it or pull it the object pls does somebody know how to disable it?

ancient condor
#

Has anyone else run into an issue where InputAction.IsPressed() returns true on initial button depress, but then flips to false even though the input debugger continues to show expected values?

Once it returns false, it stays "stuck" in that state, frequently until I change input modes to a different device and then back.

Specifically this is for a composite action that is mapped to Dpad / L stick / WASD.

Currently using Unity 6000.0.28f1 Input System 1.11.2

sacred grove
#

how do you rename the action under action map

#

for binding

austere grotto
austere grotto
ancient condor
#

It will likely depend on how you set up

sacred grove
brisk barn
#

Hello, I want to have 3 different actions when the user holds, when they try to drag and when they click. Is there an easy way in the input system to determine what the user is doing? (holding, clicking or dragging?)

tight knot
#

Hey, i have a game where there is a chat. Whenever the player types in the chatbox, the keys can still trigger movement and other things. Is there a way to disable inputs for everything else when writing in an input field?

austere grotto
tight knot
austere grotto
tight knot
austere grotto
#

disable scripts, or have your scripts check a bool before doing the thing.

tight knot
#

ok thanks

simple scarab
#

How do I unset UNITY_INPUT_SYSTEM_INPUT_MODULE_SCROLL_DELTA for the input module? This code is erroring on the latest unity version

#if UNITY_INPUT_SYSTEM_INPUT_MODULE_SCROLL_DELTA
        const float kSmallestScrollDeltaPerTick = 0.00001f;
        public override Vector2 ConvertPointerEventScrollDeltaToTicks(Vector2 scrollDelta)
        {
            if (Mathf.Abs(scrollDeltaPerTick) < kSmallestScrollDeltaPerTick)
                return Vector2.zero;

            return scrollDelta / scrollDeltaPerTick;
        }

#endif
austere grotto
simple scarab
austere grotto
simple scarab
# austere grotto Show the actual full error
Library\PackageCache\com.unity.inputsystem\InputSystem\Plugins\UI\InputSystemUIInputModule.cs(2305,33): error CS0115: 'InputSystemUIInputModule.ConvertPointerEventScrollDeltaToTicks(Vector2)': no suitable method found to override
austere grotto
simple scarab
#

I think I figured out why? Seems like it needed the ugui package to be 3.0+, since it's actually defined there

gusty sierra
#

Hi y'all I'm trying to figure out the new input system, and I have it set up so that every time you press the interact keys it calls a function that for now just displays something to the logs. I'm having issues, because whenever I click, it activates the function twice, and I was wondering if I was doing anything wrong. The code is here:

austere grotto
gusty sierra
#

ah

austere grotto
#

Add this to help understand what's happening:

Debug.Log($"Action phase is {context.phase}");```
gusty sierra
#

Alright thank you, how can I get it to only trigger once the action is performed?

austere grotto
#

if (context.performed) // do something

gusty sierra
#

Thank you

elder bane
#

How can i use trigger this space action in mobile with ui button ?
If i use on screen button premade script it doesnt work .

And i write my main input reader like this , i want to share all events fields in one point.

And i dont use PlayerInput class also on my player.

#

I tried this class to extend but not worked onPointer events works well but input action doesnt triggering and my main InputReader not pressing that consumable pressed etc.

    [AddComponentMenu("Project/In Game Button")]
    public class InGameButton : OnScreenControl,IPointerDownHandler, IPointerUpHandler
    {
        protected override string controlPathInternal
        {
            get => m_ControlPath;
            set => m_ControlPath = value;
        }
        
        [InputControl(layout = "Button")] [SerializeField] private string m_ControlPath;
        
        
        public void OnPointerUp(PointerEventData eventData)
        {
            SendValueToControl(0.0f);
        }

        public void OnPointerDown(PointerEventData eventData)
        {
            SendValueToControl(1.0f);
        }
    } 
austere grotto
#

There's no reason you need to write your own control

finite seal
#

any idea how to make the On-Screen Stick "stay in place" after it's been let go?

#

it always resets the position, and I'm using it for rotation meaning it will always snap back to 0, 0, 0

mortal ridge
#

anyone know how to disable the built in input manager in Unity 6? for some reason i cannot find the setting for it that was available prior to Unity 6

sacred grove
#

why cant i change the name of my action

#

the <No Binding>

fierce compass
#

you can change the action name by clicking on the "New action", which is the current name

#

the bindings will be automatically set when you specify bindings, in the select menu labelled "Path"

sacred grove
#

like the <No Binding>

fierce compass
sacred grove
#

i dont have a headset and im testing out with the XR Device Simulator

fierce compass
#

have you read any inputsystem tutorials?

#

this should be covered pretty early on

sacred grove
sacred grove
#

can you check if my file structure and everything looks fine

elder bane
elder bane
#

Okay now its working i found i forgot to enable my actions ... but now it gives 3 log when i press with this setup

    public class InGameButton : OnScreenControl,IPointerDownHandler, IPointerUpHandler
    {
        protected override string controlPathInternal
        {
            get => m_ControlPath;
            set => m_ControlPath = value;
        }
        
        [InputControl(layout = "Button")] [SerializeField] private string m_ControlPath;
        
        
        public void OnPointerUp(PointerEventData eventData)
        {
            SendValueToControl(0.0f);
        }

        public void OnPointerDown(PointerEventData eventData)
        {
            SendValueToControl(1.0f);
        }
    }
#

ok found again context include started canceled performed therefor i think 😄

simple scarab
#

Does anyone know a good way to implement Post Acceptance Delay to inputs? Basically if you double click twice within some timeframe it counts as only a single press

#

I'd rather not implement it manually on everything that uses it, so if there's a way to have a global processor that can handle it then that'd be cool

#

Looks like processors can be put on controls directly, which might be the best option... Question is if they're allowed to contain state or not

simple scarab
#

Huh, I managed to add a processor to an input action, but it doesn't actually do anything? Does subscribing to "performed" ignore processors?

#

Ah, looks like it doesn't use processors if there's no interactions on it. And that processors shouldn't have any state. But doing a custom interaction might be what I want instead.

simple scarab
#

interaction worked! guess I'll just have to apply it to all actions programmatically

hollow stone
simple scarab
#

It would be ugly to put it there, with the way it's set up

wraith holly
#

guys why i can't use my game pad right stick to move the camera when i try detect the input of it in new input system it only detect Rz and z

violet garden
#

Should I use the unity input actions or normal input detection inside the scripts?

#

I'm new to unity and I'm still trying to figure things out 😅

hollow stone
# violet garden I'm new to unity and I'm still trying to figure things out 😅

the input system is a lot more versatile and handles a lot of things for you (device changes, input mapping for different devices, actions and interactions, durations of presses needed etc). But if you really just want to play around and prototype something, the inline input queries are just fine, using Input.GetKeyDown() etc.

edgy venture
#

Im trying to get on the train of Using ScriptableObjects to handle input. But i have a big problem.. I cannot read what control scheme is curently active if i dont have a PlayerInput component. is there xome other way to read what control scheme is active..? or if you are using keyboard/mouse or gamepad?

fringe kite
#

What is the best method to do the following with the input system.

Movement input: WASD
Menu input: WASD

Only have one or the other action map active, one for gameplay and one for menus.

I want to use the same inputs to control menus when they come up on screen, could be inventory, pause menu, etc. I'm trying to use two ActionMaps, but cannot get anything to work. Reading it may have something to do with instancing, but SwitchCurrentActionMap and FindActionMap("actionmap").Disable() aren't working.

sacred grove
#

in input actions my action just says <No Binding>
when i double click on it, it doesn't let me rename it
how do i rename it

austere grotto
#

No binding means you haven't added any bindings to it

#

not related to its name

wispy gorge
#

For some reason the inputs that I get from the action inputs are different than the input debugger says :/

#

I have a Nintendo switch controller connected but the joy stick isn’t doing the right values

#

It works if I directly get the values from the game pad instead of using the input actions, but I know that’s not very scalable and not ideal

valid plover
#

Is 2kb/frame of GC normal for just listening to input callbacks? Seems very high

austere grotto
valid plover
#

Separate issue but it's crazy how slow InputSystem.FindAction is when passing it a string - quickly fixed this by caching guids to string names of actions in a dictionary but seems very strange Unity doesn't do this by default, a single button lookup using nothing but the inbuilt function was taking 0.4% of frame time. Went from 0.68ms to 0.01ms after fixing it.

austere grotto
valid plover
austere grotto
#

Why not just cache the InputAction reference though

valid plover
#

I did - but users shouldn't need to write a caching system for the primary path of getting an input in a game engine, is my point.

austere grotto
#

Looking up actions by strings every frame isn't really the primary path of getting input though

#

Not with this system

oak basin
#

Hey guys, what's up...?

#

Is there an equivalent to GetKeyDown...? I'm using Invoke Unity Events I think it's called

#

Something like this in my code

#

Because when I jump or wall jump, I can basically cheese it by jumping forever as long as I press and hold the button

#

I want it so that the player can only jump when they tap the button

verbal remnant
oak basin
austere grotto
#

If you're using events like this you should not write the value to a bool

#

just do the jump thing inside the callback directly

oak basin
#

That was actually what I had a month back and the jump was working

#

But it was weird having the code there because I thought I should move all the logic to update

#

Ok that makes sense, I'll redo it in the callback function, because it was much easier that way before

verbal remnant
oak basin
#

I guess it might be easier if I write the movement code directly inside of the Callback function...

#

The only problem with that is what if I need to call that method in Update for something

#

I tried that, that was one of the reasons why I tried moving all my movement code into their own seperate methods and put them in Update

verbal remnant
#

the update method is way better in the long run, you decouple yourself from the concrete source and make an explicit statement what inputs are needed/expected, but for a quick project it might be too much boilerplate

oak basin
#

Yeah I'm trying to make a platformer game, so maybe Update might be better...?

verbal remnant
#

maybe, certainly helps with sequencing

oak basin
#

I don't know, I joined Unity maybe two months back so all of this stuff is new to me

#

I don't know what behavior to use, whether to use Update or FixedUpdate, and all of those other confusing stuff

verbal remnant
#

Then do t worry too much about getting it right, just keep your eyes open for options

#

Try another one next time

verbal remnant
oak basin
#

If Update is better...is there a way to store the CallbackContext as a variable so I can use WasPressedThisFrame() in the Update method...?

verbal remnant
oak basin
#

What would you recommend is the best way...? I'm not sure how exactly to organize my code, especially with having those type of un-callable methods...

verbal remnant
#

I’d just store the result of that method in the struct on event and reset it myself in update.., or some other way. There is really no best way.

verbal remnant
#

that struct is minimal and only contains fields that system needs

#

I don’t like to have input directly call methods… but that’s probably just something i don’t do out of habit because it turned out to be the easiest thing in previous projects, but ymmv

oak basin
#

Yeah true, I mean I could have used the older input system but I came across a YouTube recommendation where they talked about Unity's New Input System and why I should use it (since it's easier to deal with controller/keyboard and changing bindings I think)...

#

They all said it was easy but I still don't understand it to be honest

verbal remnant
#

Old system is just trouble

#

good for Prototypes, not much else

oak basin
#

What's the best way to use Inovke Unity Events...?

#

Because I heard that using Invoke C# Events might be the worst one to use since it's overly complicated

#

And Send/Broadcast Messages are ok, but I don't know them too well

verbal remnant
#

You gotta build so much stuff yourself with the old system and you end up with reinventing the wheel in a bad way each time

verbal remnant
#

They are going to make everything difficult

oak basin
#

Because having methods for each input just specifying the buttons for every action is kind of tedious and wastes lines

#

Is there a better way to write it than this...?

verbal remnant
#

best use send message only for debugging and ‚hacks‘

verbal remnant
#

if you want to use the events then you gotta type that boilerplate

oak basin
#

So basically I can write all those boolean variables in one Input Callback function and maybe use that...?

verbal remnant
#

as mentioned before, in a small project it’s usually fine to do your handling inside the event

oak basin
#

This is what I have in the Inspector

verbal remnant
oak basin
#

Yeah that's how they taught me in the tutorial I watched a month or so back I think...

verbal remnant
#

I find that component is extremely misleading

oak basin
#

Is there a better way to do it than PlayerInput...?

fierce compass
#

playerinput is fine

verbal remnant
#

it’s almost entirely unnecessary

fierce compass
#

everything's unnecessary if you don't want the easy way 🤷

#

the inputsystem is based on inputactions, unlike the old input module which just let you detect keypresses directly
the inputsystem still lets you do that but it's not exactly the intended way to get most of your input

#

inputactions are fed through playerinput, or through a generated class iirc? im not sure about that latter method

verbal remnant
fierce compass
#

what do you think is best then?

verbal remnant
#

Whatever solves the project‘s specific problem without causing problems later

fierce compass
#

right... and there's 2 routes to doing so, playerinput or the generated class

verbal remnant
#

there are way more options than that

#

for example you can use input action references in the components that need the input.

fierce compass
oak basin
#

Ok that works, thank you guys I appreciate you, I'll probably try reworking the code a bit

livid meteor
#

Hey yall, I’ve been using Unity’s old input system in my project, I think it’s referred to as Legacy now? Anyway, it works perfectly and I even set up custom key bind support with it (for keyboards). But the issue is, the old input system is very hard to use with controllers, as buttons seem to randomly map in different controller types. From what I’ve heard, the new Input System does not have these issues, but as I’ve already got everything set up perfectly for keyboards using the old Input System, are there any specific drawbacks to utilising both the old and new input systems in one project? (I want to use the new input system for controller support)

livid meteor
#

And I’m fairly sure I’ve tried it out in the past

fierce compass
#

i must be mistaken then, mb

#

in that case; the drawback would be that you have inconsistent input handling in your project, which may make maintainance harder.

livid meteor
#

Well if won’t significantly impact the game’s optimisation or storage requirements, I’m willing to work with it

fierce compass
#

i'd recommend eventually migrating to inputsystem though, it's generally regarded as a replacement rather than an alternative

livid meteor
#

Yea I would’ve started using it sooner if I had known about it. Just don’t wanna mess with the current keyboard input system in this project in particular since it works as intended.

#

Will definitely use it in a heartbeat for future projects tho

elder ore
#

Can someone please explain to me why my player sometimes Jump when I press the Dash button. I can't understand why it keeps happening.

violet garden
elder ore
#

I also set each to false when ever I used them

violet garden
elder ore
#

You're not using Unity Event?

violet garden
#

and made an input manager instead

#
onFoot.Sprint.performed += sprintCtx => playerMovement.Sprint();
#

where this line will be called whenever the sprint key is pressed and released

#

then I have the sprint function that sets the value to true or false

#
public void Sprint()
{
    isSprinting = !isSprinting;
}
elder ore
#

Okay, hmm. I'll have to reconsider my input system maybe.
It's really weird how 2 different actions / buttons
can trigger the same function even when its not assigned to it in Unity Events.

violet garden
#

Maybe other ppl can help

gritty coral
#

My best guess: unity is triggering all the events or both of them at least, and since the check is on context started instead of performed, you end up in a race condition with no control over which executes first

#

The question becomes: if that is true, why is unity doing that?

#

If you are on the latest unity, I can try playing around with it and see if that happens to me too

#

Though, I usually do it the way xuann did it (using c# events)

elder ore
#

for this specific project im using 2022.3.15f1
Installing 6000.0.22f1 now

gritty coral
#

Let me know how it goes

#

It could be an old bug or something

elder ore
#

thanks, Ill keep you updated.

#

I think Ill uninstall and reinstall the new input system once I got the new Unity version down

gritty coral
#

Sure, you can try that

elder ore
gritty coral
#

perfect 😄

fading pier
#

How can you have inputs only register once even when you hold them down for seconds at a time?
Im doing a pause menu and when you press esc, its registered multiple times such as 10, and if you hold it down for a second, its registered 900 times because of each frame.

supple crow
#

Show the code that's responding to the input.

#

although, first: how are you receiving the input?

  • A PlayerInput component?
  • A class you generated from your input action asset?
fading pier
#
using UnityEngine;
using UnityEngine.InputSystem;

public class PauseMenu : MonoBehaviour
{
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    public GameObject pauseMenu;
    InputActionMap inputs;
    void Start()
    {
        Cursor.visible = false;
        inputs = InputSystem.actions.FindActionMap("PlayerControls");
        pauseMenu.SetActive(false);
    }

    // Update is called once per frame
    void Update()
    {

    }
    private void FixedUpdate()
    {
        if (inputs.FindAction("Escape").ReadValue<float>() == 1)
        {
            if (!pauseMenu.activeSelf)
            {
                Time.timeScale = 0f;
                //Freezes time ingame
                pauseMenu.SetActive(true);
                Cursor.visible = true;
            }
            else
            {
                Time.timeScale = 1.0f;
                pauseMenu.SetActive(false);
                Cursor.visible = false;
            }
        }
    }
    public void quit()
    {
        Application.Quit();
    }
    public void resume()
    {
        Time.timeScale = 1.0f;
        pauseMenu.SetActive(false);
        Cursor.visible = false;
    }
}```
supple crow
#

Okay, so you're directly talking to the input action here

supple crow
#

if (inputs.FindAction("Escape").ReadValue<float>() == 1)

This is true as long as the "Escape" action is being pressed

#

which will flip-flop every frame

#

fortunately, you have...

#

WasPerformedThisFrame()

#

er, actually, go with

#

WasPressedThisFrame()

That's what you actually want

#

It won't matter unless you're using input processors for things like "press and hold"

#

You can also call IsPressed() to check if it's pressed at all

#

Also, here's an easier way to do this!

#
[SerializeField] InputActionReference pauseActionRef;

void FixedUpdate() {
  if (pauseActionRef.action.WasPressedThisFrame()) {
    // ...
  }
}
#

InputActionReference lets you directly refer to a specific input action

#

Rather than fussing around with finding an action map and action by name

hardy moss
#

You can also use action.triggered.

fading pier
#

how would I apply it to if (inputs.FindAction("Escape").ReadValue<float>() == 1)

austere grotto
hardy moss
#

inputs.FindAction("Escape").triggered

austere grotto
supple crow
#

oh, that's nice

#

didn't know about that one!

#

but now I know where I got the idea that "triggered" was a phase like "performed" or "cancelled" :p

austere grotto
#

InputAction had triggered before WasPerformed/Pressed/ReleasedThisFrame all were introduced

flint snow
#

hello there
does anyone know a way to listen for input control scheme changes?

flint snow
sudden lagoon
#

I have two questions, most likely they were asked many times before:

  1. Does input system support multi touch actions like pinch on WebGL?
  2. Is there a way to simulate pinch action on editor to test if code works?
lament jay
#

Hi, nice to meet you.
I'm programming a remap menu with the new input system.
I learned how to do it with an input that has only one binding, but I don't know how to do it for a vector2 input that I use for movement.
My code is this one.

austere grotto
#

Or something else

lament jay
#

I made a vector2 input, what I want to know is how to program a remap system in my script so the Player can remap that input.

lament jay
#

Thanks, I'll take a look at that and see if I can get it working.

sharp coral
#

Hello! I'm trying to make a platformer using the new input system, is it considered good practice to set flags like this for instantaneous actions, or is there a better way to do it?

austere grotto
#

Update could run twice before a single FixedUpdate frame, and you will miss the jump

#

e.g.
Frame 1: FixedUpdate runs - jumpPressed is false, no jump
Frame 1: Update - triggered is true so jumpPressed becomes true
Frame 2: Update - triggered is false, so jumpPressed becomes false
Frame 3: FixedUpdate runs, and it sees jumpPressed is false, no jump

#

You need to do:

if (playerInputMap.Player.Jump.triggered) {
  jumpPressed = true;
}```
#

or shortcut:

jumpPressed = jumpPressed || playerInputMap.Player.Jump.triggered;```
sharp coral
#

from debugging it does look like it's more controlled

#

other than that though, is setting flags like this okay, or is there still a better way to do this?

#

I've seen some people who assign the action press itself into a context function

supple crow
#

I mostly use callbacks for button-style events

#

it'll be more-or-less equivalent here

#

I don't know when callbacks run when compared to the Update loop

sharp coral
supple crow
#

You'd be setting flags to true in the callbacks, just like you are doing in Update here

sharp coral
#

yeah figured I'd needed to do the same thing

#

still don't know if callbacks run on its own time sync or if it checks on the Update() frames

vagrant vale
#

Whenever I add a new Action to the input system, I always get stuck on this iteration and this keeps going on forever. (Unity 6)

sharp coral
#

Oh that’s just a bool value I put in to toggle debugging

#

For the left/right move inputs

supple crow
#

the conditional attribute is really neat

#

It completely omits the method call, including any expressions that are part of the call

#
OnlyInEditor(ThisCrashesTheGame());

This won't do anything in a build

void vale
#

Hey, so i have a third person character camera that is moving with cinemachine free look with this component, it works, but the sensitivity is too high and also the movement is very choppy and when I lower the gain value (which multiplies the speed of rotating the camera) it is no longer choppy, but the sensitivity is too low. How can i adjust the sensitivity without it being choppy?

#

also the horizontal side seems fine, but vertically it is choppy and for some reason has higher sensitivity

austere grotto
#

But you should at least show how you set up the input actions

void vale
void vale
austere grotto
#

that's your main issue I think

#

get rid of all the processors

void vale
#

ok, but it was there by default

austere grotto
#

wdym

#

Looking at my fresh project the default asset doesn't have that

void vale
#

idk i just had it there

#

but it is still choppy

#

didnt fix anything

austere grotto
#

did you save

void vale
#

yes

austere grotto
#

And can you show the Action itself too

#

the Look action

#

not just the binding

void vale
austere grotto
#

ok good

void vale
#

I mean when i dont adjust any sensitivity in cinemachine nor in the input actions it is smooth, but it has very low sens

austere grotto
#

I think the rest of the isse is probably due to the cinemachine settings now

#

but Cinemachine 3 is kinda unfamiliar for me so idk

void vale
#

i just increased my mouse sens with my software to very high and tested it and it works perfectly, but how can i adjust the sens in game for it to work without chopping?

stark notch
#

Did the generated class from the inputactions asset change in Unity 6?

#

I think i see what i was doing, it didn't change i just am using it wrong

void vale
supple crow
#

There's also the "Cancel Delta Time" option on the input axis controller, which which something very similar -- it divides by delta time

#

(This is incorrect. It should be the unscaled delta time)

#

Without that, your mouse input will be choppy

#

Longer frames will have more mouse movement, causing Cinemachine to move the camera faster than during shorter frames

void vale
#

so what should i do to implement that?

supple crow
#

(specifically that binding! if you add controller input, that should not be processed in the same way)

void vale
supple crow
#

Ah, I missed it. Okay, that should be fine, then

supple crow
void vale
#

thats alright

supple crow
#

Removing that processor should have dramatically changed your sensitivity. Did you observe that?

supple crow
#

okay, so it was working, at least :p

#

At 100 FPS, removing it would reduce your apparent sensitivity by 100 times

void vale
#

yeah i get that

#

i also changed to cinemachine 2 and it is also doing some weird chopping, but if you find some solution i would switch back to CM 3

supple crow
#

I would bump it back to 3

supple crow
void vale
#

ok so i just realised that it actually works on cinemachine 2, but only if i maximize the game window, and also i would happily use CM 3, but if it doesnt work then i have no other choice

supple crow
#

that's probably because the game is running at a more consistent framerate

#

Part of this could just be that the editor is hitching regularly

#

you'd want to look at the profiler window to check

void vale
void vale
#

i just realised it is doing the same choppy thing as CM 3 but it has higher sensitivity so it is not as noticable but still

supple crow
#

Update back to Cinemachine 3.0 and get it set up with your input action asset

#

make sure that you have the delta time scale processor on your mouse delta binding

void vale
supple crow
#

right, and I want to make sure it's still there

#

especially after downgrading and upgrading Cinemachine

void vale
#

and also how would you change sensitivity with CM 3?

supple crow
#

You can change...

  • The scaling on the Delta [Pointer] binding
  • The scaling on the entire Look action
  • The gain on the input axis controller
#

I would change one of the latter two

#

In my game, I accept both mouse and joystick input

#

I have the individual bindings scaled so that they both feel...roughly correct at a given sensitivity

void vale
#

yeah i did all of those things and they make the sensitivity higher but also it is more choppy

supple crow
#

and then I scale the entire action to let the player adjust input sensitivity

supple crow
void vale
#

and in your game you dont have any chopping when you move very slowly with your mouse?

supple crow
#

I do not.

You should look at the Profiler window while the game is running. Do you see large spikes in the graph that coincide with the jumps?

void vale
#

no, i dont

supple crow
#

it was using the old input manager

void vale
#

yeah i changed it to the new one afterwards and it was still chopping

#

i just changed to CM 3 and i will try it again

supple crow
#

given that the hitching is happening with both input providers (the new input system and the old input manager), I wonder if there's something wrong outside of Unity

#

your mouse cursor is moving around pretty normally though

void vale
#

ok so i figured out whats wrong, when i used the default input actions it works normally but when i use mine it starts chopping

#

but the thing is it is practically the same as mine

supple crow
#

Do the processors match?

void vale
#

okay, i just made everything match and it works, there is no chopping, but when i change the gain value or the vector scale in the input actions to increase sensitivity it starts chopping again

supple crow
#

I'm going to want to see the actual input data. Add this to something in your scene:

public class InputTest : MonoBehaviour {
  [SerializeField] InputActionReference actionRef;

  void Update() {
    var data = actionRef.action.ReadValue<Vector2>();
    Debug.Log($"{Time.frameCount}: {data} - {Time.deltaTime}");
  }
}
#

This will log the input value every frame, along with the deltaTime value

#

Assign the player look action into the inspector

#

(make sure you get the right one)

void vale
#

okay

supple crow
#

no, that is the correct member -- InputActionReference.action gives you an InputAction

#

you need to assign an action into it in the inspector, though

void vale
#

so first i did it normally when it works without chopping and the i increased the vector scale and it started chopping

supple crow
#

That's really interesting. Most frames have zero input, and then some have a catastrophically large movement

#

This is from the first half. It's a bit weird that many frames have exactly 0 X input, but it's oterhwise sensible

#

I'm seeing camera movement during periods where the logged value is [0,0]. Hm.

void vale
#

yeah its weird and whats even weirder is that i have not changed any setting before and it is a new project

supple crow
#

but it could just be that the console is scrolling very quickly

#

Oh, are you moving the mouse very slowly in the second half?

void vale
#

i can try to make a new project with the same unity version and with CM 3 and try to do the same thing

supple crow
#

It looks like your mouse has to move pretty far before any input is recognized at all

#

almost like there's a "deadzone"

#

How much did you scale it up by?

void vale
supple crow
#

what numbers did you put in to the scale processor?

void vale
#

in the input actions?

#

i showed it in the video

supple crow
#

ah, my aggressive skipping-around missed that -- okay, so it's 10x

#

and it started at 0.1x

#

so there's a 100-fold difference between the two

void vale
#

yes

supple crow
#

That's going to be the issue, I think

void vale
#

yeah i mean if i move by lets say 1 unit and it moves by 100 units it will be choppy, but how do i make it smooth then?

supple crow
#

I think your mouse just isn't providing input precisely enough. Blowing it up by a very large scale factor means that you get very jumpy movements

supple crow
#

it suggests that Unity is getting no input at all if the mouse only moves slightly on one axis

void vale
#

that could be it

supple crow
#

Do you have your mouse set to a low DPI along with a very high input sensitivity in Windows, by any chance?

void vale
supple crow
#

that is a little low sounding

#

Can you increase the mouse DPI and reduce the mouse sensitivity in Windows? See how that feels by comparison

void vale
#

yeah, but my mouse cant be it, it works normally in other games

#

i tried it and it is still the same

#

@supple crow i found this on the internet

supple crow
void vale
supple crow
#

"don't go above 1 (but it's ok)"

void vale
#

does this have something to do with it?

supple crow
#

I was just looking in there

#

That's only used by the axis deadzone processor

void vale
#

and also if you scale the vector by 100 in your game, does it work normally?

supple crow
#

(which is not attached, hopefully..)

#

If I scale it by 100 my mouse sensitivity goes completely crazy

#

I have it scaled by a completely arbitrary 0.18

void vale
supple crow
#

It does get choppy, yeah. It's a lot like what you're seeing, which makes sense

#

The smallest possible input is now a very large camera movement

void vale
#

yeah exactly

supple crow
#

This is a really tiny movement of my mouse

void vale
#

yeah thats what im getting

supple crow
#

Are you moving your mouse by very tiny amounts with the 10x sensitivity?

void vale
#

yeah

supple crow
#

ah, yeah, then that's just how it's going to work

#

your mouse is not able to provide inputs that are small enough and frequent enough to look good at that sensitivity

#

if the mouse can only ever say "I moved by 1", and you multiply its movement by a big number, you're going to get chunky movements

void vale
#

okay, i will leave it like this, because if somebody else plays this game and changes the sensitivity, it probably wont be choppy cuz they will have a reasonable sens

supple crow
#

yes

#

I was under the impression that you were still moving the mouse a decent amount!

#

that would be more confusing

void vale
#

okay, but thanks for the help

#

i just tried this in pubg, i put the sensitivity to the highest (which is only 2x multiplier) and in is also choppy

#

so i was trying to solve a problem that cant be solved

sharp coral
#

okay this is rad, thanks for letting me know!

vocal grove
#

How do I disable this error? the game works exactly as expected using this so I don't care if it's "technically" not the correct method.
Or is there a method on how you're supposed to do it in the new input system?

austere grotto
#

(that goes regardless of which event system you're using)

vocal grove
#

I have a click action with a click that then does like the following simplified code

void OnEnable()
{
    playerInput.onActionTriggered += HandleInput;
    playerInput.onControlsChanged += OnControlsChanged;
}

void OnDisable()
{
    playerInput.onActionTriggered -= HandleInput;
    playerInput.onControlsChanged -= OnControlsChanged;
}

private void HandleInput(InputAction.CallbackContext context)
{
    if (context.action.name == "Fire1" && context.performed)
    {
        OnFire1();
        return;
    }
}

void OnFire1()
{
    if (!DoingSomething() && timeStamp <= Time.time)
    {
        if (GameState.instance.inMenu == false)
        {
            Interact();
        }
    }
}

void Interact()
{
    if (IsPointerOverUI())
        return;
    // DO STUFF
}
private bool IsPointerOverUI()
{
    return EventSystem.current.IsPointerOverGameObject();
}
austere grotto
#

you should use IPointerClickHandler to handle it

#

you will get the "UI blocks interaction" behavior for free.

vocal grove
#

Ah okie

austere grotto
#

Which is why you're doing if (IsPointerOverUI()) in the first place

vocal grove
#

I'll look into adapting my code to that then :D

elder ore
# gritty coral perfect 😄

Nope, still the same issue. The issue doesnt appear when I jump and dash with kb, maybe it's my controller that effed up? I chose the action as a button, I add nothing else to it inside the input controller.....maybe I should?

gritty coral
# elder ore Nope, still the same issue. The issue doesnt appear when I jump and dash with kb...

I don't have my controller on me (I can get it on the weekend) to test it, but try a different controller.

I dont have unity open right now but I'm assuming either the controller is fked or some sort of deadzone setting is not working right (I don't have the settings in front of me to check what buttons have or dont).

So my first guess is try another controller and see if it happens.
If it does => config issue (either your project or unity messing up)
if not => 99% controller's fault

wild harness
#

Howdy folks. I am trying to upgrade my unity 2D project to use the New unity input system, due to a bug with some tablets where finger drags miss pixels :/ But man this has been a trip. I'm currently fighting an issue where my cursor is invisible all the time. I have an extensive set of cursor images/sizes depending on what the cursor is currently over in game. To make this work previously I had to lock the cursor and force it to software. But now, nothing seems to work to make it visible again. Any ideas what might be going on?

drowsy olive
#

Hello there, does anyone know the way to specify a "global" speed scale on all inputs ? The way I see it, we might need to iterate all the map at init time and specify some postprocess programatically. Any other thoughts ?

fierce compass
#

wdym by scaling inputs?

drowsy olive
#

Yes sorry, I knew it was not clear, that's why I said speed scale. Basically I want to reduce the speed of all non binary inputs ( sticks / triggers / mouth delta)

fierce compass
#

basically smoothing analog inputs?

drowsy olive
#

But I want to do it with a single entry point, I could as well create a postprocessor that would handle this on the specified inputs; but had no luck creating processors

#

mmh yes definitelly smoothing, linearly (or any curve)

#

Well I guess I'll try make a custom processor nevertheless. I'll report here.

fierce compass
#

yeah seems like there isn't a built-in way to do that

drowsy olive
#

There are actually two usecase, one which is an infinite analog input (like panning), that can be simply scaled down, and one which has a finite range (such as trigger) and which need to be actually smoothed. The issue beeing Processors are stateless

supple crow
#

There isn't some kind of "global" processor that applies to every single action of a certain type (that'd be a bit weird)

drowsy olive
#

I created Scale Processors child classes that checks for a cli arg in order to apply its scale or not. I just added the processor to any input that need that behaviour. It indeed seems I'll have to handle every bits individually. Not sure about the weirdness of global processors on inputs though. It actually seems quite handy to be able to have global callbacks/plugins, more tool always better imo.

supple crow
#

it would be strange to filter every single Axis-type action, since you can have very different kinds of axis inputs

supple crow
#

(I haven't done that before, mind you)

craggy merlin
#

@supple crow is this what you were talking about

supple crow
#

Yes. You can assign a specific input action in the inspector

craggy merlin
#

would you read it the same?

supple crow
#

it gives you an InputAction

craggy merlin
#

yeah

supple crow
#

you can then subscribe to its events or read its value

craggy merlin
#

what about your Input Manager

#

u said you handle your action maps there

supple crow
#

that just turns entire input action maps on and off depending on the current game state

#

so it turns off the "Humanoid" action map if you aren't controlling a humanoid entity

#

and turns on the "Menu" action map if a menu is open

#

There is no InputActionMapReference, so I just find them by name from an InputActionAsset

craggy merlin
#

or multiple for each map

crimson schooner
#

I've looked everywhere to find the documentation for this but for the life of me I can't figure out how to make input overrides apply to only one specific player input component for local multiplayer. I want to allow both players to rebind their controls at runtime, but any time I try to alter the overrides it applies to a project-wide version of the input actions rather than the private local one and I don't know how to work with it.

See the test class below

public class RebindTest : MonoBehaviour
{
    public PlayerInput testInput;
    public ControllerInput controllerIn;

    private void Start()
    {
        if(controllerIn.ControllerID == 1)
        {
            Debug.Log("Rebind for id " + controllerIn.ControllerID);
            testInput.actions["jump"].ApplyBindingOverride("<Gamepad>/leftTrigger");
        }
    }
}

When I remind the testInput player input, both controllers in my local multiplayer game get rebound even though I want to ask it to rebind only controller 1's controls. I'm sure I'm just missing something here but if someone knows what the issue is here please let me know.

supple crow
craggy merlin
#

so something like this?

supple crow
#

But that'd need to be done before it subscribes to all of the events on the input actions

crimson schooner
#

This was the closest documentation I could find in some unofficial github guide but the link to the private instantiation section doesn't elaborate further

supple crow
#

ah, so it instantiates the asset but doesn't expose the copy

#

(or maybe it instantiates all of the actions individually -- same general idea)

craggy merlin
supple crow
# craggy merlin

Roughly, yeah. I check a few things to decide if each map should be active or not

#

I only switch the map on or off if it needs to change

craggy merlin
#

yeah

supple crow
#

I'm not sure if calling Enable every frame would be a problem

craggy merlin
#

maybe check if its disabled first

supple crow
#

So, for example, if I have an active menu of any kind, the menu actions get activated

supple crow
craggy merlin
#

is there a method to only enable 1 action map and disable the rest?

supple crow
#

You could check if the actions from the two different PlayerInput components have different instance IDs

supple crow
craggy merlin
supple crow
#

I have some actions that are universal and some that are context-specific

craggy merlin
#

yeah

#

alright

#

thank you

crimson schooner
#

Two different instance IDs it seems

supple crow
#

Interesting. I wouldn't expect the binding overrides to apply to both

crimson schooner
#
{
    public PlayerInput testInput;
    public ControllerInput controllerIn;

    private void Start()
    {
        Debug.Log(testInput.actions.GetInstanceID());
    }
}
supple crow
#

Actually, what is testInput.actions?

#

I was thinking of looking at individual actions

#

is it an InputActionAsset?

craggy merlin
crimson schooner
supple crow
#

So I just do it by name

crimson schooner
#

For reference with the previous test script this is the console output

supple crow
#

Log the instance ID of the exact input action that's being rebound

#

Might be useful

crimson schooner
#

Even though the instance IDs are different for each one's testInput.actions, whenever the script runs the jump key that I have bound on keyboard normally gets overridden for player 2 even though only player 1s testInput.actions are getting overriddent

supple crow
#

(not just the ID of the entire input action asset)

crimson schooner
#

I assume the id for the action is just under ID since there is no getInstanceID function

#

Anyways seems identical (I removed the if qualifier for this test)

#

That tells me what's going wrong specifically but I have no idea how I would even begin to go about troubleshooting it

supple crow
#

Ah, right, it's not a unity object

craggy merlin
#

what am i doing wrong

#

Property or indexer 'InputActionMap.enabled' cannot be assigned to -- it is read only

#

how do i disable/enable it then

supple crow
craggy merlin
supple crow
#

it has methods to enable or disable

#

ye

crimson schooner
#

Basically every tutorial I watch is only for single player applications and black boxes imported packages so much I can't even begin to try and build it for my own purposes

craggy merlin
supple crow
#

Not that I'm aware of. Iterate over all of the maps and disable them

craggy merlin
supple crow
#

well, I guess it does exist after all :p

#

yeah, Disable disables every map

#

which disables every action

crimson schooner
#

Currently I'm working on building a smash bros style "Name" control selection UI. Basically controls are tied to a player profile that I intend to save to a json file. Players can then load a player profile from the list of "names". This will then apply the override to their controls from the base using the specifications from the json file. If I can just figure out how to change the controls at runtime I think I'm set but this issue is driving me crazy.

supple crow
#

Would that help with the problem they're having? Rebinding on one player's action is changing the other player's action

crimson schooner
crimson schooner
#

I'm already familiar with json save and load (I'm probably going to make custom versions of these functions)

#

My main issue is rebinding in a local multiplayer environment

#

Because when I rebind for one playerInput it rebinds for all of them

supple crow
#

well this is mildly interesting

austere grotto
supple crow
#
public InputActionAsset actions
{
    get
    {
        if (!m_ActionsInitialized && gameObject.activeInHierarchy)
            InitializeActions();
        return m_Actions;
    }
    // setter
 }

This is the "private copy"

crimson schooner
austere grotto
crimson schooner
supple crow
#

But the docs claim that actions is somehow different from the "private copy"

crimson schooner
supple crow
#

that action would have to actually be connected to something to do anything

#

Oh!

#

I know what it is

crimson schooner
#

The InputActionsAsset has a different ID but the actions themselves don't

supple crow
#

yeah I get it

#

The first PlayerInput doesn't instantiate the input action asset

austere grotto
#

The first one uses the og?

supple crow
#

I was kind of suspecting that earlier, but I wasn't at my computer and couldn't check it

austere grotto
#

I think I've seen hints of that before

supple crow
#

So if you do anything to that player's actions, it'll affect any subsequent players' actions

#

It probably makes singleplayer easier to deal with

crimson schooner
#

That's

#

Insane

supple crow
#

you could instantiate the input action asset before giving it to the first player's PlayerInput

#
actions = Instantiate(actions);
player1.actions = actions;
player2.actions = actions;
#

etc.

supple crow
#

good to know for when I start doing this stuff..

crimson schooner
#

Would I add a script to my PlayerInputManager object that does this?

supple crow
#

You should be able to just do:

testInput.actions = Instantiate(testInput.actions);
#

I guess it'd be ideal to only do this for the first player

#

but the cost should be negligible

crimson schooner
#

I see

supple crow
#

It does automatically*

#

(:

#

plus or minus

crimson schooner
#

Ok so I tried this and now every time I press an input every it tries to create a new playerInput from the playerInput manager?

supple crow
#

Ah, I bet that's becaues it doesn't understand that a playerinput already exists for that device

crimson schooner
supple crow
#

I wonder if you need to do this

crimson schooner
#

(For reference the player input manager tries to create a prefeb for the controller whenever I press a button until it reaches max capacity)

supple crow
#

I don't quite understand this, but I have a feeling it affects which specific InputDevice is being used by

#
                    var oldActions = m_Actions;
                    m_Actions = Instantiate(m_Actions);
                    for (var actionMap = 0; actionMap < oldActions.actionMaps.Count; actionMap++)
                    {
                        for (var binding = 0; binding < oldActions.actionMaps[actionMap].bindings.Count; binding++)
                            m_Actions.actionMaps[actionMap].ApplyBindingOverride(binding, oldActions.actionMaps[actionMap].bindings[binding]);
                    }

This is how the PlayerInput component copies an input action asset

crimson schooner
#

I'm confused

supple crow
#

that makes the two of us!

#

I haven't looked very closely at how multiplayer works before

crimson schooner
#

I'm going to cry why did they design it like this 😭

#

Maybe this is the problem?

#
for (var i = 0; i < s_AllActivePlayersCount; ++i)
                if (s_AllActivePlayers[i].m_Actions == m_Actions && s_AllActivePlayers[i] != this)
                {
                    var oldActions = m_Actions;
                    m_Actions = Instantiate(m_Actions);
                    for (var actionMap = 0; actionMap < oldActions.actionMaps.Count; actionMap++)
                    {
                        for (var binding = 0; binding < oldActions.actionMaps[actionMap].bindings.Count; binding++)
                            m_Actions.actionMaps[actionMap].ApplyBindingOverride(binding, oldActions.actionMaps[actionMap].bindings[binding]);
                    }

                    break;
                }```
crimson schooner
# supple crow that makes the two of us!

Ok so if I comment it out like this it works

// Check if we need to duplicate our actions by looking at all other players. If any
            // has the same actions, duplicate.
            //for (var i = 0; i < s_AllActivePlayersCount; ++i)
                //if (s_AllActivePlayers[i].m_Actions == m_Actions && s_AllActivePlayers[i] != this)
                //{
                    var oldActions = m_Actions;
                    m_Actions = Instantiate(m_Actions);
                    for (var actionMap = 0; actionMap < oldActions.actionMaps.Count; actionMap++)
                    {
                        for (var binding = 0; binding < oldActions.actionMaps[actionMap].bindings.Count; binding++)
                            m_Actions.actionMaps[actionMap].ApplyBindingOverride(binding, oldActions.actionMaps[actionMap].bindings[binding]);
                    }

                    //break;
                //}```
#

The problem is that I have no idea how to change input system without unity freaking out and reverting it

supple crow
#

ah, so now you're manually making the duplicate?

#

and not allowing PlayerInput to do that

#

Oh, I misread

crimson schooner
#

PlayerInput is checking to see if the InputAction already exists and if so it duplicates it

supple crow
#

you're unconditonally having it copy the asset

crimson schooner
#

If I modify playerInput it works

#

Because now it always copies

shadow lance
#

Hey, I am a very beginner unity user, and I was wondering if there was anyone who would be able to help me with some problems I've encountered through making my project. I've been trying to follow tutorials, but most are outdated or vague

crimson schooner
#

But IDK how to change a unity package to work 😭

supple crow
crimson schooner
#

Every time I make the change it goes "NOPE"

supple crow
#

Copy the folder from /Library/PackageCache into /Packages

#

Packages that are installed normally through the package manager are put into the Library

#

When you put that folder into Packages, Unity recognizes that you've got a copy of the package in your project

#

You're allowed to do whatever you want with those files

#

If you delete the folder from Packages, Unity will put a copy of the package back into /Library/PackageCache

supple crow
#

But it would break the next time it recreated anything in the package cache

crimson schooner
#

Like do I have to do any weird finageling with duplicate packages or anything of the kind

supple crow
#

Unity will see that the package is in the Packages folder and get rid of the copy in the package cache

#

It's really painless

#

I embed a number of packages. I've made some tweaks to Splines to make it perform better for me

crimson schooner
#

Dope

supple crow
#

(i frequently modify splines every frame, so doing lots of work to cache data for the spline is pointless because it gets thrown out immediately)

#

Now, if you want to update the Input System package in the future, you'll need to get rid of the folder in /Packages and then update through the package manager

#

So this adds a little wrinkle to updates

crimson schooner
#

I don't think I'm likely to

#

But yeah that helps a lot appreciate the help

supple crow
#

no prob! i got to learn something as well :p

crimson schooner
trim rover
#

Is there a (straightforward) way to not register clicks that occur within my UI Toolkit UI in my input handler? Basically i dont want to attack an enemy if the player was clicking on a UI element, for instance

supple crow
#

hmm, with UGUI, you can ask the event system if the cursor is over a UI element

#

I'm not sure if the same applies to UIToolkit (it does use the event system..)

boreal ruin
#

Hey, i need to use a keybind for two actions. One simple press, and it does something, but if i hold, it only does another method, but not the first one.

I tried to do with two actions, with the same keybind, one with hold interaction, and one without. However, when i hold, it does the first action, then after a few seconds, the second one.

Does anyone have a solution for this? Thanks 🙂

supple crow
#

You need a "Tap" interaction on the other action

#

This prevents it from performing if the button is held for too long

boreal ruin
#

Oooh okay, thanks a lot 🙂 i'm gonna try

#

That's awesome, great thanks

#

This new input system is really insane

supple crow
#

It's a bit intimidating at first -- mostly because it gives you so many ways to receive input

#

I really like it

#

I can automatically construct a hint popup for any input action

boreal ruin
#

That's huge

supple crow
#

InputActionReference is also very nice

#

I just plug in the relevant action wherever I need an input

craggy merlin
#

i have DigitalNormalized selected for the 2D Vector

#

and when i walk sideways by holding W and S for example

#

this is what shows up

#

is that correct?

#

does that block the player from walking faster sideways?

#

or would it have to be 0.5, 0.5

supple crow
#

That's correct.

#

0.707107^2 is almost exactly 0.5

#

sum two of those up and you get 1

supple crow
craggy merlin
#

thats why i was confused

supple crow
#

I'm just writing the math out by hand

#

The magnitude of that vector is not 0.707 + 0.707

#

It's 0.707 * 0.707 + 0.707 * 0.707

#

which is roughly 1

craggy merlin
#

makes more sense

#

thanks

austere grotto
supple crow
#

sqrt(0.5)

prisma shard
#

Does anyone know a possible reason why, despite the on screen controller being present and working per the input debugger, the script cannot read any values from it?

#

I've checked everything and the actions seem to be set and work correctly when using a keyboard

prisma shard
#

For anyone that's interested, the problem was me using two PlayerInput components with the same actions because I mistakenly thought that any object would need that to use the input action reference correctly.
No idea why it would block only mobile controls but I'll take it and leave

austere grotto
prisma shard
#

Got it, thanks

earnest wagon
#

I have a rather peculiar problem with input: I'm building a R/C flight sim on the Meta Quest (Android) and as such want to support R/C controllers as input device. I have gone so far as to query all axis and read out the value and position in the StateBlock buffer coming from the controller. I have one controller that on the path "/rightStick/y" is providing me with the incorrect offset (off by 8 bytes) in the StateBlock. I'm on 2022.3.54. Before I was using an older 2022.3 version and there all gamepads had the same issue, so I hacked the system to automatically correct the offset for that axis. In the newer version however, a bluetooth gamepad and an XBOX controller work correctly out of the box (so my hack will break it). So now I am left with no way of knowing the correct offset for the rightStick/y axis.
I have a hunch it's either an issue with Unity or the Quest because on a "Game Controller Tester" app on my Android phone, the controller is read correctly.

soft crystal
#

is there a way to trigger an input system action from code?

soft crystal
#

yeah I need it in builds

#

my use case is programmatically generated menu items

austere grotto
#

and bind your custom device to the action

soft crystal
#

hmm alright

#

euuugh idk how to set this up with GenericDropdownMenu items

#

since I don't get access to that visual element in the AddItem function

#
class HalfEdgeDropdownMenu : GenericDropdownMenu {
    public void AddItem( InputAction action ) {
        string keyBind = action.bindings.First().ToDisplayString();
        string label = action.name;
        if( string.IsNullOrWhiteSpace( keyBind ) == false )
            label += $" {keyBind}";
        base.AddItem( label, isChecked: false, () => {
            action.performed.Invoke(); // <-- I just want to do this ;-;
            // ClickEvent e = new ClickEvent();
            // e.target = ???
            // InputSystem.FindControl( "mouse" ).WriteValueIntoEvent(  );
            // _ = 0;
        } );
    }
}```
austere grotto
#

Maybe figuring out some side channel to do this is better

soft crystal
#

side channel?

austere grotto
#

By which I just mean "a different approach"

#

What's the goal here?

soft crystal
#

oh, maybe yeah

#

the goal is to have a menu item at the top of my application that can perform the same actions you would if you pressed that hotkey

austere grotto
#

Reflection is, of course, always an option but terribly hacky...

austere grotto
#

Ahhh that's only for the event system... oops

#

Yeah OnScreenControl is a MonoBehaviour >_>

#

I think your best bet is reading the source for OnScreenControl and seeing if it can be adapted to UITK

soft crystal
#

SCWWcrying guess I'll just make a whole wrapper thingy

#

as in like, the script that hooks up inputs to actions also hooks up the menu items while it's at it

#

I might have to do that anyway to add menu item enabled/disabled validation

supple crow
#

I am also interested in doing this -- mostly in the editor

#

I want to be able to fuzz my game by just spewing random actions at it

#

it'd be nice to have in builds too

glass ginkgo
#

My FPS camera controller is working weirdly.
This is not the first time this happened.

I once made a third-person camera system with Cinemachine, and the same problem occurred, where the camera would egregiously tilt downwards in the first frame.
Plus, for some reason, the camera aim is not consistent. If I move my mouse slowly, it moves just fine, but if I move it quickly, it overshoots - is this mouse acceleration?

I'm using the old Input System, and I'm thinking of moving to the new one. But I'm not too worried about that for now unless that can solve the aforementioned problems.

Here's the source code:

using Unity.VisualScripting;
using UnityEngine;

public class CameraController : MonoBehaviour
{
    [SerializeField] Transform CameraTransform;
    [SerializeField] Transform PlayerTransform;

    [Space(10)]
    [SerializeField] Vector2 Sensitivity;

    float xRotation;
    float yRotation;

    private void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;

        xRotation = transform.eulerAngles.x;
        yRotation = transform.eulerAngles.y;
    }

    private void Update()
    {
        MoveMouse();
    }

    void MoveMouse()
    {
        float mouseX = Input.GetAxis("Mouse X") * Time.deltaTime * Sensitivity.x;
        float mouseY = Input.GetAxis("Mouse Y") * Time.deltaTime * Sensitivity.y;

        
        xRotation = Mathf.Clamp(xRotation - mouseY, -90f, 90f);
        yRotation += mouseX;
        
        CameraTransform.localRotation = Quaternion.Euler(xRotation, 0, 0);
        PlayerTransform.localRotation = Quaternion.Euler(0, yRotation, 0);
    }
}```

It works just fine except for those two concerns pinpointed above.
earnest wagon
#

My FPS camera controller is working

austere grotto
supple crow
#

If you're unsure of why that helped -- mouse input is an amount of movement, not a rate of movement

#

You multiply joystick input by deltaTime because the value tells you how far the stick has been tilted. It's how fast you want to move

#

The mouse tells you how much you want to move

trim rover
#

Is there a way to make clicks that hit UI Toolkit documents not hit the world?

glass ginkgo
#

But do you know anything about the downward tilt?

supple crow
#

The jarring movement could be caused by locking or unlocking the cursor

#

the cursor gets pinned to the center of the screen

#

I had a problem with that in my game -- when closing the debug menu, which re-locked the cursor, the camera would suddenly move quite a bit

#

I have a static field that tells me that the camera was locked this frame. I ignore all Look input when that field is true

austere grotto
hollow roost
#

i want in my 2d game to make player press mouse button, read value of the mouse position and cast a spell from player to position. The problem is i can either make input action of value vector2 type and constantly be reading position of the mouse or type button but not read the position of the mouse. How do i combine those two so that the position of the mouse is only read on mouse click?

austere grotto
#

one for the position, one for the click

hollow roost
#

ty

glass ginkgo