#🖱️┃input-system

1 messages · Page 31 of 1

lost moon
#

why not?

austere grotto
#

old:

if (Input.GetKeyDown(KeyCode.Space))

new:

if (Keyboard.current[Key.Space].wasPressedThisFrame)```
austere grotto
# lost moon why not?

Because there's no ability to do key rebinding or binding multiple keys or devices to this

#

but for a quick prototype it's fine

lost moon
#

oh, i meant more i want the ability to use the new system but still get that kind of functionality, if that makes sense

austere grotto
#

yes I understood you entirely, that's what I was responding to

lost moon
#

in my view, the new system involves creating an input actions assets and subscribing to the events so that you can do remapping easily

#

I was unaware of the other parts of it

austere grotto
#

but yes, like I said, this approach, which is analagous to the old system which you wanted identical functionality to, does not allow remapping

#

and event-based stuff is a totally different concept, unrelated to remapping

#

Another approach that's more like the old Input.GetButton/GetAxis workflow is to use a project-wide actions asset.

#

then you can do stuff like InputSystem.actions["Jump"].WasPressedThisFrame()

#

or use event-based handling if you so choose

#

that one will allow rebinding

lost moon
#

ah that method was exactly what i was looking for

austere grotto
#

alright - well you mentioned the GetKey approach which is more limited than GetButton/GetAxis

lost moon
#

if im going to also need the ability to read input on a tick basis, would you recommend just writing my own WasPressedThisFrame() & WasPressedThisTick()

austere grotto
#

what do you mean by reading input on a tick basis?

#

like for networking stuff?

#

you need to read input in Update or with events and cue it up to be included in the next tick

lost moon
#

Thats a good approach

#

Even if it wasnt for networking though, wouldn't people run into issues if they tried to use per frame input on fixed update movement code

austere grotto
#

nothing about that has changed since the beginning of unity

#

the same solutions apply

lost moon
#

Ok thanks for your time

austere grotto
#

read input in Update -> consume it in FIxed

golden river
#

Hey peeps - how do I get mouselook to work in Unity 6 with the Input System? It simply refuses to work. Tried:

  • Custom Actions > Look = Delta mouse, Delta pointer
  • EventSystem > Input System UI module > Point = Player > Look
  • CharacterController > Player Input > Events > Player > Look = Controller.onLook

FIXED: I had Simulate mouse as touch in Window > Analysis > Input Debugger > Options, which hid the mouse from Unity

ornate star
#

What key binding I have to use for UI Buttons? Because when I used "Primary Touch/Tap" then jump function was getting triggered from anywhere on screen. Do I use Event System or something else instead of using "Primary Touch/Tap" binding in on-screen button component?

austere grotto
#

Are you talking about on screen controls?

#

Use like Keyboard/J or something

fathom wraith
#

how do I detect what key is pressed under any key thro the input system

fierce compass
austere timber
#

im making a grid based roguelike. id like the player to be able to move when pressing a direction key which works for cardinal directions, but I would also like there to be diagnal buttons as well (think numpad movement on older roguelikes)

is there a way to do this with vector 2 input?
or am I better off making seperate inputs for each direction in addition to a vector 2 movement input (lets say if I wanted to use a joystick on a controller)

austere grotto
#

Or you mean hoilding 8 and 6 simultaneously to move diagonally, for example?

austere timber
#

yeah using 7913 as movement buttons essentially.

#

I almost wanted to have a 'northwest

#

binding for the action that I could assign

austere grotto
#

and combine that with the cardinal direction input

austere timber
#

yeah this is the cleanest solution I can think of too. I appreciate the input

opaque pollen
#

I'm trying to figure out what the "best/correct" way to set up the input actions for me to be able to turn 90 degrees left or right after "bumping" the right stick of a gamepad left or right. Is there a way to make that input work like a digital/button input?

Should I just use a normal axis and check for value within a tolerance range?

What is recommended?

austere grotto
opaque pollen
#

okay, went with buttons.

Any idea why the right stick right is triggering as right stick left?

#

🤦‍♂️ needed to save the input actions asset after editing it

#

it works

coral jasper
#

how can i make one of the input action listen to a runtime vector2 value?

#

instead of making default buttons/bindings

coral jasper
kindred mirage
#

I have this issue where when I save the input action editor how it is in the image and when I click on a different tab and a few minutes later the control scheme will change back to keyboard only. How can I fix this?

molten bay
#

If it's not a bug and you do have to enable the default map explicitly, is there a better way?
I just came up with this by looking at the autocompletion.

molten bay
#

How do I get a reference to that asset tho?
Like the default asset.

#

like is this fine?

InputSystem.actions.Enable();
fierce compass
molten bay
#

thanks!

coral jasper
#

i know its a violation tho, but it will save me more efforts if i can do that lol

fierce compass
#

don't ping specific people for help

coral jasper
#

sry

timid phoenix
#

I've noticed that my game window mouse value goes insane when I unfocus from the game window. If I'm not cursor locked in the game screen the mouse spins 1000x times and still tracks my mouse movement. Have any of you encountered this? When I'm in the game window, everything works fine

still trout
#

if its bothering you you can check if the game is currently in focus and ignore all inputs otherwise (which is not a bad idea anyways)

polar fulcrum
#

hello! not sure if this is the right channel but i guess its related.
as u can see i tried making a simple dash button.
yet, when pressed, only the debug.log are working, while the rest doesnt. everything from movement, jumping n sprinting works while this doesnt, any idea why?

fierce compass
#

!code

sonic sageBOT
fierce compass
#

also configure your !ide

sonic sageBOT
oblique raven
#

please post all of the script as code

fierce compass
#

you're probably resetting the linearVelocity elsewhere

polar fulcrum
#

my bad holup

oblique raven
#

can you also Debug.Log(moveinput)

polar fulcrum
#
using UnityEngine.InputSystem;

public class playerControl : MonoBehaviour
{
    public float speed = 5f;
    Rigidbody2D rb;
    Vector2 moveinput;
    public bool isMoving;
    public touchingDir touchingDir;
    public int jumpCounter;
    public bool isFacingRight;
    public bool isFacingLeft;

    void Awake()
    {
        rb = GetComponent<Rigidbody2D>();
    }
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        
    }

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

    }

    private void FixedUpdate()
    {
        rb.linearVelocity = new Vector2(moveinput.x * speed, rb.linearVelocity.y);
    }

    public void OnMove(InputAction.CallbackContext context)
    {
        moveinput = context.ReadValue<Vector2>();

        if(moveinput.x > 0){
            isFacingRight = true;
            isFacingLeft = false;
        } else if (moveinput.x < 0){
            isFacingRight = false;
            isFacingLeft = true;
        }


        isMoving = moveinput != Vector2.zero;
    }

    public void OnRun(InputAction.CallbackContext context)
    {
        if(context.started){
            speed = 10f;
        } else if(context.canceled){
            speed = 5f;
        }
    }

    public void OnJump(InputAction.CallbackContext context)
    {
        if(touchingDir.isOnGround){
            jumpCounter = 1;
        }
        if(jumpCounter > 0){
            if (context.started)
            {
                rb.linearVelocity = new Vector2(rb.linearVelocity.x, 5f);
                jumpCounter--;
            }
        }

    }

    public void OnDash(InputAction.CallbackContext context)
    {
        if (context.started && isMoving)
        {
            Debug.Log("Dash");
            Debug.Log("move: " + moveinput);
            rb.linearVelocity = Vector2.zero;
            rb.AddForce(moveinput.normalized * 50f, ForceMode2D.Impulse);
        }
    }
}
#

tried checking rigidbody properties but it seems as normal as ever

fierce compass
fierce compass
polar fulcrum
#

ah mb didnt see the message

polar fulcrum
#

the dash force was being overwritten by the fixedupdate

#

just had to make a bool

#

thank you

slender spire
#

Hey folks, I have a question. I'm setting up the player character and noticed that when I call for dodge/jumo/crouch etc. sometimes the input system doesn't register the action. l

ike at one moment I can dodge perfectly 3 times in a row and the next dodge doesn't happen, it's like it's stuck on something(this also applies to jump and others).

I tried to put in the animator transition durations that are small. even put press in the input actions even though it says default is enough, I checked isgrounded in update and nothing is wrong.

For the life of me i can't figure out why it behaves like this, any ideeas?

fierce compass
slender spire
fathom wraith
#

why does the acceleration not work in mobile?

fierce compass
#

can you be more specific

tawdry wasp
#

I have it set up on my project so when I press 1 it invokes the unity event to place water, but it instantiates 3 of the prefabs instead of just 1

I'm not calling PlaceWater() from aynwhere else, does nayone have an idea what it could be?

#

but with a Debug.Log in the placewater I see it does get called 3 times somehow

fierce compass
#

with the callback context version, make sure to check the phase

#

(you can easily check that's happening by logging the phase, or holding the button down - you should see 2 calls immediately, then another call when you release)

tawdry wasp
#

I've not really used this new input system before took a massive break from unity so i'm not sure how i'd check that, I call it exclusively through the invoke unity event with no code related to button pressing

fierce compass
#

check what exactly?

fierce compass
#

then yes the inputsystem is invoking the event for each phase

#

the callback isn't invoked when it's pressed, the callback is invoked when the state changes

#

the callbackcontext provides a .phase property iirc?

#

autocomplete should be able to tell you the correct name if that's not right

#

ah, there are also bool props you can use, so just .performed

tawdry wasp
#

I see, so I will need code to do this I can't just invoke the unity event like I was doing?

fierce compass
#

your unity event is already code

#

you just add a condition in the body of the method you're calling

tawdry wasp
#

okay i'll look up that thankyou 🙂

rigid moat
#

Can you guys help me with something real quick? I've been writing something relating to the Input System and somehow it ended up messing up the input... it's all jittery now kind of working like grinding metal against a cheese grinder (that's the best description I can provide because I'm not really able to share a video atm...)
THe update mode is set to dynamic, I've tried to look for all sorts of help but this is a huge issue for me. Can anyone help me out??

austere grotto
#

Most likely a physics object is not being interpolated properly due to your setup

austere grotto
#

Jittering wouldn't generally be directly input related

lusty summit
#

Excuse me i have a question,

I try to make 2D Action RPG in Mobile Android but i still don't know about new input system and how to fix my player movement in virtual joystick ?

Because when I use keyboard input, the top down movement is alright.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerMovement : MonoBehaviour
{
    [SerializeField] private float moveSpeed = 5f;
    private Rigidbody2D rb;
    private Vector2 moveInput;
    private Animator animator;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
        animator = GetComponent<Animator>();
    }

    void Update()
    {
        if (PauseController.IsGamePaused)
        {
            rb.velocity = Vector2.zero; // Stop movement
            animator.SetBool("isWalking", false);
            return;
        }
        rb.velocity = moveInput * moveSpeed;
        animator.SetBool("isWalking", rb.velocity.magnitude > 0);
    }

    public void Move(InputAction.CallbackContext context)
    {
        if (context.canceled)
        {
            animator.SetBool("isWalking", false);
            animator.SetFloat("LastInputX", moveInput.x);
            animator.SetFloat("LastInputY", moveInput.y);
        }
        moveInput = context.ReadValue<Vector2>();
        animator.SetFloat("InputX", moveInput.x);
        animator.SetFloat("InputY", moveInput.y);
    }
}
still trout
austere grotto
tawdry wasp
lusty summit
# austere grotto it looks to me like the motion is fine - it's your animation that is not working...

Yes, I think my animation isn't working properly with joystick virtual and the on-screen stick component (built-in Unity) seems to have a delay in reading it. How to fix it ?

this is the video when i test with a joystick and keyboard, there is a difference in the animator parameter input. https://drive.google.com/file/d/1u03u_t7oxyoKBJwTi2QkgkD78UnnVMrx/view?usp=drive_link

rigid moat
livid nymph
#

does anyone here use the new unity input system?

fierce compass
#

tons

blissful comet
toxic lintel
#

New Unity Input System isn’t real, it can’t hurt you notlikethis

livid nymph
storm cobalt
#

i hate the new input system atwhatcost

oblique raven
#

takes a few days to figure out how it works

fading mist
#

I have an issue with the VirtualMouseInput where on loading a scene with a gamepad enabled, I'm unable to interact with any of my UI. Only until I move my mouse, and then enable my gamepad again does the UI work.
I have a single PlayerInput that doesn't get destroyed when I change scenes. Each scene has a single Event System and UIInputModule, the latter having all the correct input and is being synchronized with the PlayerInput class.
I tried everything from making that UIInputModule a DontDestroyOnLoad object, manually pairing the VirtualMouse device, and even forcing the position of the virtual mouse to be changed through script so that the UIInputModule can pick it up. Nothing's worked so far.

flint snow
#

Hello there
is there a way to capture UI navigation events in general?
I'm trying to create as system that can ensure that some Selectable is always selected during UI navigation.

public sealed class EnsureNavigation : MonoBehaviour, IMoveHandler {
    public void OnMove ( AxisEventData eventData ) {
    }
}

I've tried this but it's not working

slender sleet
#

what would be the best way of having getting a input from each number with the new input system?

slender sleet
latent tangle
slender sleet
latent tangle
slender sleet
latent tangle
#

plus if you want an int to come e.g. then you could make a simple function to check for the input and return the correct num

fierce compass
slender sleet
fierce compass
#

having them as separate actions would let you rebind them individually easily

slender sleet
fierce compass
#

how do you plan on detecting them separately then

slender sleet
fierce compass
#

no, that's not what scale does

#

output... what, the key?

slender sleet
slender sleet
hollow bloom
#

How do i check when a layer stops giving input for something like movement using the new input system? I'm not seeing anything on the docs for it

fierce compass
#

what method are you using for detecting it to begin with?

hollow bloom
#

movement

fierce compass
#

no, like, PlayerInput, InputActionReferences, polling, a generated class, etc?

hollow bloom
#

PlayerInput

fierce compass
#

alright, and which behavior is it set to

hollow bloom
#

unity events

fierce compass
#

you can check for the callbackcontext being "cancelled"

hollow bloom
#

im trying to switch over my player movement code to using the new system but its not working as expected https://paste.ofcode.org/KYJkjViQY52hkhciQrvPbc
Currently i cant move forward or backwards and A and D move me super fast in either direction

#

am i using the input system incorrectly?

austere grotto
#

multiplying by the scale here is weird

hollow bloom
#

It’s weird yes but nessesary so you arnt super fast or slow

austere grotto
#

basically you have an issue here in that you're mixing frames of reference

#

that velocity code is in world space

#

so it isn't properly accounting for which direction the player is facing

hollow bloom
#

Ah

hollow bloom
#

Previously in the code when W and S worked they moved me at normal speed

#

While A and D still moved me quickly

austere grotto
#

start by adding Debug.Log statements to your code

#

you'll want to print out what input values you're getting to start with

#

then keep printing things until you see something unexpected

#

that will be where your bug is

austere grotto
# hollow bloom That’s because the game is about scaling

also, in a game like this it's probably better not to directly use the Transform scale as the source of truth. A custom component with a ScaleFactor property on it as the source of truth to manage all the scaling stuff would be more extensible and easier to work with.

hollow bloom
austere grotto
# hollow bloom Why is the transform scale untrustworthy?

It's not so much untrustworthy it's just poor code architecture.

  1. Any script can change it at any time, including things that are maybe just supposed to be visual and not affect anything else
  2. Using a custom property would let you control what else changes when you change the scale. For example when the scale changes you might also want to change some camera settings, change the player's health, modify a postprocssing effect, play a sound, do an animation, whatever, right? If you use a centralized property that will guarantee all those things always happen when the scale changes. It makes it so you can't forget anything by accident.
  3. It also has benefits for serialization and game state management. You can't serialize a Transform,
hollow bloom
#

mmm i see what you mean but in the game the only objects who's scale will change effects are interactable objects like boxes and the player with the only thing effecting scale being the tunnel that changes the scale of the object with a script that tells it to do so

#

this method also lets me personally change the scale of objects in editor and see the scale change still in editor

austere grotto
#

That sounds like even more of a reason to use a special component for it

austere grotto
#

anyway I'll drop it, just my recommendation

#

let me know if you need help debugging the original issue

hollow bloom
#

yeah i will. ive had a few years of experience in Unity level design and light c++ experience but im trying my hardest to try and get better at the c++ half and this movement system is giving me a lot of pain so far

hollow bloom
#

stuff works before then but not after, velocity isnt being set to anything when W and S are pressed

austere grotto
#

You should print out what moveDir, moveSpeed, and velocity are at that point

#

as well as what the scale is

hollow bloom
#

ah the issue seems to be W and S is moving me up but gravity keeps me down so nothing happens

austere grotto
#

not up/down?

#

Yeah you're not swizzling your input vector to x/z

#

you're leaving it as x/y

hollow bloom
proper iron
#

so I take it if you put playerControls.Player.Enable(); this it'll enable all of the commands within these actions within said Actionmap

#

on the map called player

#

you would have the same for the UI map, correct?

austere grotto
hollow bloom
#

Im trying to have my interact prompt be used to grab a box but for when i press E it counts as multiple press so i repeatedly pick up and drop it. Is there a way to only count unique instances of pressing E?

austere grotto
proper iron
austere grotto
#

If you're using events it's different

hollow bloom
#
    public void Interact(InputAction.CallbackContext context)
    {
        Debug.Log("pressedE");
        if (item == null)
        {
            Debug.Log("grabbed");
            pressed = true;
            OnGrab();
        }
        else
        {
            Debug.Log("relesed");
            pressed = false;
            OnRelese();
        }
    }
#

thats my current code

proper iron
austere grotto
austere grotto
proper iron
austere grotto
proper iron
austere grotto
austere grotto
hollow bloom
# austere grotto You have to do `if (context.performed)`

if its like this, it dosent seem to be working

    public void Interact(InputAction.CallbackContext context)
    {
        if (context.performed)
        {
            Debug.Log("Pressed E");
            if (item == null)
            {
                Debug.Log("grabbed");
                pressed = true;
                OnGrab();
            }
            else
            {
                Debug.Log("relesed");
                pressed = false;
                OnRelese();
            }
        }
    }
hollow bloom
austere grotto
#

You can add:

Debug.Log($"Input phase is {context.phase}");``` to the top of the method to see what's going on
proper iron
#

is there a tutorial explaining how to use the new input system well using reffrences like if statements etc?

#

Since Documentation isn't adhd friendly lol

austere grotto
hollow bloom
#

oh it works if i press and hold

austere grotto
#

was that on purpose?

#

Sounds like it wasn't

hollow bloom
#

it was not

austere grotto
#

you should remove all interactions from it

proper iron
#

How would you flip a character with the new input system?

#

like a sprite

hollow bloom
proper iron
#

since Originally I had the old input system to do that

austere grotto
#

you need to open the actions asset

hollow bloom
#

oh i see what you mean ok fixed

austere grotto
#

and look at the Interact action

waxen token
#
{
        isPointerOverUI = EventSystem.current.IsPointerOverGameObject();
}```
#

This won't work on mobile right?

#

Since with an empty parameter it will only work with mouse

#

Or am I missing something?

oblique raven
#

just try it out and find out

waxen token
vocal swallow
#

the rebind isnt applying instantly but only after i reload the scene

#

why is that

austere grotto
#

One possibility I'm imagining:

  • At the beginning of the scene you are making a copy of the InputActionAsset and using that - therefore the copy doesn't pick up the changes made to the original.
#

if you're using the PlayerInput component, I believe that component makes a copy by default.

vocal swallow
austere grotto
#

that explains it, as per what I said above about the copy

vocal swallow
#

how do i update the copy?

coral jasper
#

this is a virtual joystick, it can read value and move characters, however, i want to make it more flexible

#

i only missed one step to finish it, i want to change its position and start reading value once the player tap onto the area below, it must ignore all other taps if its outside of the area or if the tap was on certain UI

#

my question is , how can i trigger these two things when i tap onto the area , with sequence

  1. change the position of the joystick
  2. do whatever the joystick used to do

its using onscreenstick btw

austere grotto
coral jasper
coral jasper
#

but if it became children, it wont limit the position right? as it moves along with the joystick (the green area will move together)

#

i guess manually reset it should be fine

coral jasper
#

how will u deal with input noise when u swiping ur smartphone for controls like "looking"

#

i can pickup values and move my camera, but maybe because my fingers are too big , when i swipe left, the value i picked up had vertical input noise, and it is way too significant i cant even suppress it

#
public class Look : OnScreenControl, IPointerDownHandler, IPointerUpHandler , IDragHandler
{
    [InputControl(layout = "RJoystick"),SerializeField] private string m_ControlPath;
    
    protected override string controlPathInternal
    {
        get => m_ControlPath;
        set => m_ControlPath = value;
    }

    public void OnPointerDown(PointerEventData data) => SendValueToControl(data.delta);
    public void OnDrag(PointerEventData data) => SendValueToControl(data.delta);
    public void OnPointerUp(PointerEventData data) => SendValueToControl(data.delta);
}```
#

i think i will try to make a input dead zone first

dawn plover
#

How do I make it.ao something happens when I hold a key down for a specific amount of time for example like 5 secs

austere grotto
hollow bloom
#

I'm getting stuck up on Ui buttons. Currently when i click on them nohting happens.

#

my button looks like this

timid dagger
hollow bloom
#

Ah I have no graphic ray cast I’ll be sure to try that tomorrow

vocal swallow
#

also even when inputActionAsset.Disable(); it doesnt seem to be doing anything

#

isnt it supposed to stop the inputactionasset from functioning

#

im using only one inputactionasset

austere grotto
#

All of the symptoms you are describing match the idea that there's an asset copy, which PlayerInput certainly is known to create

vocal swallow
#

nvm i was just getting the id of the inputasset allocated in inspector

#

the save seems to be working and when i load the saved bindings on awake it still doesnt take effect until after i reload the scene

#

the ui is updated on awake tho

vocal swallow
#

found the issue

#

i cant have Player Input attached to more than 1 object

austere grotto
#

Didn't know you had

fierce compass
#

huh? i have several PlayerInputs on separate objects just fine

#

or is there more specific context here?

austere grotto
#

that's the only way that generally makes sense

#

PlayerInput grabs an exclusive hold on the devices they claim.

#

It's designed as 1 PlayerInput == 1 human player

fierce compass
#

im not, im doing it all singleplayer

#

i wasn't super familiar with the other methods when i started the project, so i used playerinput wherever i needed to receive input

#

i have one on the player for player control and one on the game manager for controlling overlay menus

#

they're using separate action maps though

#

though the same default input action asset, so not sure that matters

deft geyser
#

Why is there hardly any information regarding thew new input system in the documentation?

austere grotto
deft geyser
#

If I want to find this Mouse.current.position.x.GetValue() and other related comands where do I go?

deft geyser
#

Ah, I see, thanks

#

There's almost nothing there

#

Don't know why

austere grotto
obsidian beacon
#

someone got some time to help with a small conversion from old input system to new one, it's very basic tho

austere grotto
#

You need to just share the details of your issue

#

Nobody is going to commit to helping you ahead of time.

fierce compass
#

i linked you this 30 minutes ago

#

if you had just asked then you probably wouldve already gotten an answer lol

obsidian beacon
#

I didn't see it probably because I'm pulling hair out with this basic stuff (I'm new to Unity) but yeah my bad

#

so I've been trying to migrate from the old input system to the new one, been following a tutorial for a 2D arcade style car racing game but it's using the old system

#

do I just put a piece of code in here?

austere grotto
#

share all relevant information, including code and a description of your issue.

#

!code

sonic sageBOT
obsidian beacon
#

yeah I'm aware of code block thingy

#

new input system conversion

deft geyser
austere grotto
muted cliff
#

Hi, I recently upgraded my project from Unity 2022 to 6.1 and noticed some input action changes. Previously, Enter used to submit for input fields, but now I have to do Ctrl+Enter. However, the Unity input actions asset still show the UI Submit action as just Enter. Is there some other place that is controlling this behavior now?

austere grotto
#

you definitely shouldn't need ctrl+enter

#

it would be configured in the input action asset assigned to your input module, which is typically the default asset

#

it's unusual to change that

muted cliff
#

Any idea what might be going wrong? I've never touched the input action asset in regards to the Submit action, and its derived bindings still show "Keyboard > enter"...

#

Whenever I press Enter, it selects all of the text as if I'm focusing on the text field.

austere grotto
#

or a cat resting on a key

#

or any stray devices plugged in

muted cliff
#

Not that I know of. My teammates are also experiencing the same thing on their end 😅

#

Our old build in Unity 2022 still behaves normally, so we figured something changed when updating to Unity 6.1

vocal swallow
hollow bloom
timid dagger
# hollow bloom how can i check the last one? and do i need to do anything with the event system...

The EventSystem is just necessary for UI to work. Default settings should work fine.
For checking out the currently hovered object, you can create a script containing the following code:

    void Update()
    {
        PointerEventData pointerData = new PointerEventData(EventSystem.current)
        {
            //position = Input.mousePosition // if you're using old input system
            position = Mouse.current.position.ReadValue() // if you're using new input system
        };

        List<RaycastResult> results = new List<RaycastResult>();
        EventSystem.current.RaycastAll(pointerData, results);

        if (results.Count > 0)
            Debug.Log("Hovering over: " + results[0].gameObject.name, gameObject);
    }
hollow bloom
analog fable
#

Guys, I have a game with a ready-made set of input elements, and everything works fine.

However, when I switch to the new input system package, I encounter errors.

My question is, for a multiplayer game or even a single-player game, which input system is better to use? The old one or the new one?

fierce compass
#

the new one is more flexible and generally recommended

#

what are said errors?

analog fable
austere grotto
gleaming oar
#

Why is Unity's default button behavior to leave a button in the "selected/pressed" state after my mouse has left the button?

austere grotto
#

Clicking on any selectable selects it.

gleaming oar
#

so it being selected sets it as "highlighted" is there a way to have it not be selected when mouse exits the button?
I tried calling EventSystem.current.SetSelectedGameObject(obj); in my onpointerexit and no joy

zinc stump
#

You can just set highlighted color to not highlighted.

#

Selected rather.

gleaming oar
#

I set the selected sprite to normal sprite (doing sprite swap instead of color tint) and it exhibits the same behavior

the edge case is press on button and drag mouse off of button while keeping the left mouse button held down

#

the button appears lit up, the desired is that the button stops being lit as soon as the mouse button has exited, regardless of the mouse being held down

austere grotto
coral jasper
#

plus the new one has a lot of extra components that helps simulate those classic inputs u found in smartphone games

molten bay
#

Hey, I am working with Unity 6.3 and inputs just seem messed up in the build, is this a bug or am I doing something incorrectly?
I have the Input/Asset as shown in the 1st image.
It's set as the default thing in the project settings, as send in the 2nd image.
I have inspector references to these actions in my rebinds, as seen in the 3rd image.
They work fine as seen in the editor and logs(intentionally error logs), picture 4.
Lastly, they are null(editor log) in the build and rebinds obviously don't work, as seen in the pictures 5 and 6.
I have a feeling this is due to unity not handling the default input asset correctly or something but I am not 100% sure, that wouldn't explain inspector references missing at all.
Please @ me and thanks in advance!

molten bay
austere grotto
molten bay
#

btw, I don't htink it's that script really

#

my in game inputs don't work either and I am getting them in a similar way

#
molten bay
#

btw, in case you are planning to clone the repo, make sure you use --recurse, and also, build times take at least 1-2h the first time you do it, unity is great at shader compilation

molten bay
molten bay
vague wedge
#

I have an issue with the play mode and pointer press event.
When I enter play mode, the game view does not register pointer events until I click in the view. But when I do click the game view, it triggers the press callback which I don't want happening.

lament wraith
#

how do I clone action maps for multiple players?

austere grotto
lethal shore
#

glad there's an input channel but I'm wanting to use the dpad as buttons in the old input manager but I'm running into a wall with the vertical slots. got the horizontal working through some trial and error but for the life of me I can't figure out the up and down

#

I initially went through the inputs trying to find a combination that let me move the up and down but now I just have it set to what I had the horizontal buttons set to out of convenience. here's the code and input manager

austere grotto
#

so you'd have to have a second joystick/controller plugged in and to use those same buttons there for that to work

#

For most controllers (e.g. standard xbox and playstation controllers) it should be Axis 6 for dpad left/right and axis 7 for up/down

lethal shore
#

saw that as a solution on google and chatgpt but for some reason that doesn't work either. not sure if it's because my controller's drifting or what but 6 on the horizontal and 7 on the vertical didn't work for me

austere grotto
#

what kind of controller are you using?

#

that would be step 1

lethal shore
#

ps5

#

about to try it with my xbox one controller

austere grotto
lethal shore
#

wired in both cases

austere grotto
#

ok yes, try your xbone with both set to Joystick 1 and try the 6 and 7 axis.
Also actually debug what you're seing. E.g.:

Vector2 inputVector = new(Input.GetAxis("DPAD Horizontal"), Input.GetAxis("DPAD Vertical"));
Debug.Log($"Input vector is {inputVector});```
lethal shore
#

yeah ig it was just the ps5 controller bc the xbox controller works perfectly

#

weird. thanks Praetor

toxic lintel
#

No I did not see the date that was posted 🙃

lethal shore
#

Yeah it looks alot easier but my pc can't support another update at the time but when I get a proper pc I'll make the switch

fathom sigil
#

what dose this mean

#

in unity

fierce compass
bleak oyster
austere grotto
maiden kiln
#

Design question, how do you usually access input actions in your project? One big singleton with input actions referenced?

austere grotto
maiden kiln
austere grotto
maiden kiln
#

Might be bad practice though I don't know 😄

austere grotto
#

Yeah that's fine it's just most tutorials focus on PlayerInput so that's how most people learn it

maiden kiln
#

I tend to prefer handling stuff myself rather than through built-in components

#

It's mainly because of my lack of knowledge of the new input manager package I guess

#

Another question, how do you usually handle the pass-through click event when you interact with UI?

#

I'm using the EventSystem.current.IsPointerOverGameObject() but I don't like it, I'm sure there might be a better way 😄

austere grotto
#

then you get the behavior for free

#

for example - let's say you have a top down game where you can click somewhere in the game world to have your character walk there.

It's tempting to make an input action for the click, and then in Update you look for that click and do your own raycast etc.

This would be the wrong approach. The better approach is to give the ground object an IPointerClickHandler script and handle the clicking there

#

then you get the "ui blocks this" behavior for free

#

work with the event system, not around it

maiden kiln
#

Ah that sounds great indeed!!

#

I'll look into that rather than direct calls to its API

austere grotto
#

just note for that to work you need an EventSystem in the scene and a Physics Raycaster on the camera

maiden kiln
#

Sure, thanks!

real anvil
#

anyone know what's up with this? only in unity, multiple editor versions, fresh projects with new input system, nothing but keyboard and mouse plugged in.

#

Windows/other tools don't see any gamepads/inputs at all

real anvil
#

this has been a problem for multiple years and it's entirely prevented me from using the new input system

austere grotto
proper iron
#

With the new input system, can you integrate it with a Nav Mesh?

#

If so is there a guide to do it that isn't too complicated

verbal remnant
#

any integration would be custom-made by you

austere grotto
proper iron
austere grotto
#

Can you write a full sentence explaining what you are trying to accomplish with the input system and NavMesh?

proper iron
#

I'm currently doing a project, instead of using a mouse click, I want to convert the inputs to the new input system for more functionality with supported gamepad etc that behaves similer to the mouse click, but this is for a toush screen behaviour aswel

austere grotto
sick kite
#

Hey, I'm using the new input system.

       private void OnMove(InputValue value)
        {
            Vector2 rawMovementInput = value.Get<Vector2>();
            _movementInput = rawMovementInput.magnitude < _deadZone ? Vector2.zero : rawMovementInput;
        }

I have a function like this, and if I understand correctly it is triggered by PlayerInput using SendMessage?
How can I do something like this for a button? I have a sprint button which basically is a Left Stick Press. I want to detect when it is held and when not

#

okay, I did something like this and it works,

 private bool _isSprinting = false;

        private void OnSprint(InputValue value)
        {
            _isSprinting = value.isPressed;
    
            if (_isSprinting)
            {
                Debug.Log("Started sprinting");
            }
            else
            {
                Debug.Log("Stopped sprinting");
            }
        }
#

not sure if this is the correct approach?

fierce compass
#

this is a pretty typical approach, yeah

sick kite
#

alright, thanks

viral flicker
#

okay, i have no idea why but putting turn on top of sprint seemed to fix it

mental sedge
#

I'm having issues with the Netcode multiplayer just.. not taking input? the host uses the action map perfectly fine and everything works well on it, but whenever i connect the client, NOTHING is received (on the client side, the host works just fine). I've tried everything, making multiple action maps, all that, but I just can't figure it out
I really really need help with this :|

mental sedge
simple scarab
#

Is there some way to make the InputSystemUIInputModule ignore the regular mouse?

#

When we use gamepad we hide the mouse and use a different control scheme, but if an element moves under the mouse it ends up hovering it

#

Setting "point" to none on it makes it not use the mouse, but that doesn't seem to work at runtime, and probably would also disable the virtual mouse.

#

Looks like VirtualMouseInput does InputSystem.DisableDevice, so maybe that's the move

trim arch
# mental sedge I'm having issues with the Netcode multiplayer just.. not taking input? the host...

I’ve worked with Unity Netcode + the new Input System before, and that “cloned” action map issue usually comes from how the input is being instantiated or bound on clients. I can help you debug and set up the input handling so both host and clients register actions properly. Are you currently enabling the action map in a PlayerInput component or through script on the client side? @mental sedge

mental sedge
#

Essentially there's multiple classes in my game, therefor multiple player prefabs

austere grotto
# mental sedge Essentially there's multiple classes in my game, therefor multiple player prefab...

It's kind of problematic to have PlayerInput directly on the player prefab in a networked game.

  1. PlayerInput is a "there should only be one of these in the game per physial human player on this device" component
  2. When you do a networked game you're typically spawning one copy of the player prefab per connected player.
  3. therefore you're getting multiple PlayerInput components in the scene.

Each time a PlayerInput is spawned it looks for an eligible set of devices (per your control schemes) on the local machine and claims them for its own exclusive use. So essentially what may be happening here is you're getting secondary PlayerInput components for non local players, which messes with your ability to control the local player.

#

Does that sound about right?

#

Also if you are spawning more than one of your player objects for a single player, that is a further issue when using PlayerInput.

mental sedge
#

it's weird cause I thought I found a fix, which was just reassigning the input to be the player action map instead of the clone, which worked, then i went to dinner and it stopped working

#

so what do you think I should do

#

For multiple players

austere grotto
#

Do you need to support local multiplayer in this game at all?

#

Or only networked multiplayer

mental sedge
#

Only networked cause I'm just planning on giving this to my friends, maybe something with itch.io but mainly just networked with me and my friends

austere grotto
#

Then the simplest thing to do is to stop using the PlayerInput component, which is really designed for local multiplayer.

mental sedge
#

oh, I thought it was a needed component to have input go through

#

If not a playerinput component then how do I receive input?

fierce compass
#

i think i made a list here once, one sec

#

that isn't even everything

#

there's also hardware device polling

#

and probably more that im forgetting

mental sedge
#

i have like no clue how to use any of that lol

#

Is it on documentation

fierce compass
#

yeah

mental sedge
#

i mean which would you recommend for networked multiplayer

austere grotto
#

The other alternative here is to keep using PlayerInput but don't put it on the player prefab itself

#

you'd need some glue code to get it to control the instantiated player object then though.

mental sedge
#

sorry I'm very new to all of this

mental sedge
#

thank you so much for the help

rain halo
#

The Image has a width of 100 and the Input Text has a width of 100... Why are they not aligned at the end?

fierce compass
mossy steppe
#

Hello !

I'm facing some difficulty with the new input system and cinemachine

I'm implementing the "new" input system in my game with a generated C# class.
However, when I tried making a pause menu, I noticed that my Cinemachine camera didn't listen to the deactivation of the Action Map (Disable() ), my camera is still receiving input
I changed the default X and Y Look Orbit axis by my custom action axis in the cinemachine input axis controller
I tried unchecking the box "Auto Enable Inputs" in the cinemachine input axis controller which did the opposite effect where the orbit input didn't received any input at all even by manually enabling my action map

Is this a known problem or did I missed something while setting things up ?

I'm using Unity 6000.0.45f1 with the new input system 1.14.0 and cinemachine 3.1.4

austere grotto
#

When you do new MyGeneratedClass() you're creating a brand new instance

mossy steppe
sullen badger
#

anyone know what's up with these errors? the game still works normally, at least on the editor

#

i have a debugger connected and nothing's showing up

#

it does apparently make it so a certain event isnt registered when playing on a build

#

im also getting those errors while on the editor OUTSIDE of play mode

#

for example, typing something into the asset search bar

sullen badger
#

Now I'm trying to update the package but it says it's up to date with 1.2.0
Changing it in the package-lock.json does nothing as Unity automatically reverts it back to 1.2.0

#

But up to 1.12.0 should be compatible with my Unity version (2021.2)

sullen badger
#

For further reference so people can search for the error: Event must be a StateEvent or DeltaStateEvent but is a TEXT instead Parameter name: eventPtr

hidden rover
#

I desperately need help with using an HID device having a lot of strange input artifacts that I don't even know how to describe. If I can't fix this, my game is scrapped. Anyone is welcomed and encouraged to DM me to try to help, I have tried everything I can think of. My issue involves a HOTAS, so if you have any experience with that, even better. Please help

fierce compass
#

we don't really do DM support here

#

you'll probably have to provide more info here

tropic sorrel
#

I'm adding mobile touch screen controls to my game, and have some problems.
The regular joypad sends like vector(1,0) when I press right, and when I eventually release it sends (0,0).

The digital joystick just seem to send values as long as I'm dragging my finger on the screen, while I wish it would behave like a d-pad/joystick. Is this an easy setting, or do I need to code it myself?

austere grotto
#

Alternative question: why is this an issue for your game and what are you trying to achieve with the controls?

tropic sorrel
#

Well, my game works great with gamepad or keyboard. I press and hold <right> on gamepad or D on keyboard and the character keeps moving to the right, until I release the trigger.

I would like it when I press the screen and drag a bit to the right and hold, that it would act the same way ...

#

But instead the screen control sends (1,0) when I'm dragging my thumb, but as soon as i stop dragging and just hold it, it sends (0,0) instead.

#

You see, it's acting like a mouse rather than a joystick

keen zodiac
#

hi, i'm wondering what happened with this issue:

calling Gamepad.SetMotorSpeeds can be extremely slow over bluetooth. I found 3 threads on the subject but no response from unity.

what should I do? Should I just not use this method if the gamepad is wireless for now?

here are the threads:

https://discussions.unity.com/t/inputsystem-rumble-should-not-be-used-with-bluetooth-controllers/855000
https://discussions.unity.com/t/gamepad-setmotorspeeds-is-very-slow/938302/2
https://discussions.unity.com/t/gamepad-setmotorspeeds-cpu-usage-is-very-high-with-bluetooth-controllers/853942/7

keen zodiac
#

is there a way to know if the controller is connected via USB or bluetooth? I can't find any way to detect that

sinful timber
#

I need some help with controller and input system. I want to move the ship in my game with d-pad. I've tried adding "D-Pad [Gamepad]" it didn't work. I've then tried "Hatswitch [Any]" it also didn't work. And only when adding "Hatswitch [Lic Pro Controller]", which is the specific input for my controller, it did work.
I thought that "Hatswitch [Any]" would cover, as the name say, any hatswitch controller. Is that NOT the case?
I'm afraid that I'll have to add all the different variants of controller in existence for it to work for all players. It doesn't sound like a good approach. Help!

verbal remnant
#

Also make sure your input scheme doesn’t require additional devices to be present. Schemes only activate when all required devices are present.

austere garnet
#

I have figured out the basics like how I can change the sprite of an instance on click, but I have no idea how I can do more complex stuff like detecting a drag click and broadcasting the destination when the LMB is released.

#

I have no idea what extra information you'd need to assist, but I've been struggling with using this menu for half an hour now

sinful timber
#

And thank you for the answer!

austere grotto
verbal remnant
verbal remnant
#

iirc rewired is just a layer on top of input system nowadays

forest echo
#

Hello il have a problem with the input system, i create a game for Android, in the editor, all of the buttons works but on my Phone it's does not work

loud pendant
#

Hi all, I'm currently working on a game that will utilize RC Remotes with USB functionality to control an FPV Drone in game. The issue I'm having is that there is no universal standard for how these radios report to the host and what their controls are. Is there a way to get the latest input event from an axis of the joystick connected to let the user rebind it themselves?

austere grotto
#

As for the USB radio protocol etc, you'll probably need to make a custom input device

loud pendant
# austere grotto As for the USB radio protocol etc, you'll probably need to make a custom input d...

Thanks for getting my attention to passthrough actions. As for the Radio, it's not like they use some proprietary driver. They report as regular HID Joysticks in Windows, however the issue is that how they expose their controls isn't standard. Some have the right stick as an actual stick input and put the left stick on two separate axes, some do the opposite and some others do a mix of what input maps to the stick.
I think it would be best if I listened to what input device has a changing value / axis and then use that as my input action. Is there a way to get the latest moved / pressed input?

austere grotto
ornate star
fierce compass
#

probably because something's set up incorrectly
you didn't really give any info whatsoever to work with lmao

ornate star
#

Oh sorry I forgot to send codes

fierce compass
#

debug your values. see if it's the input that's wrong or the mesh direction or something else

ornate star
# ornate star Do someone know that why character is moving diagonally when I hold movement key...
using TMPro;
using UnityEngine;

public class PlayerControls : MonoBehaviour
{
    public Rigidbody character;
    private Animator characterAnims;
    private PlayerInputs inputActions;
    private Vector2 characterMovement;
    public float characterMovementSpeed = 1.5f;
    public TMP_Text movementKeyDebug;

    void Start()
    {
        character = GetComponent<Rigidbody>();
        characterAnims = GetComponent<Animator>();
        inputActions = new PlayerInputs();
        inputActions.Player.Enable();
    }

    void FixedUpdate()
    {
        characterMovement = inputActions.Player.Move.ReadValue<Vector2>();
        if(characterMovement == Vector2.zero) movementKeyDebug.text = "";
        else if(characterMovement.y > 0) movementKeyDebug.text = "W";
        else if(characterMovement.y < 0) movementKeyDebug.text = "S";
        else if(characterMovement.x < 0) movementKeyDebug.text = "A";
        else if(characterMovement.x > 0) movementKeyDebug.text = "D";
        if(characterMovement != Vector2.zero)
        {
            Vector3 move = new Vector3(characterMovement.x, 0f, characterMovement.y);
            character.MovePosition(character.position + move * characterMovementSpeed * Time.fixedDeltaTime);
            characterAnims.SetBool("isWalking", true);
        }
        else characterAnims.SetBool("isWalking", false);
    }

}
fierce compass
#

your character probably just isn't aligned with the world axes if i had to guess

#

this still isn't much info

ornate star
jolly venture
#

I have a windows Unity app. I want to port it to be a mobile app. I need controls for wasd and some more buttons. What is the fastest way to get there? Which packages are helpful there?

verbal remnant
# jolly venture I have a windows Unity app. I want to port it to be a mobile app. I need control...

A game designed for WASD + even more buttons is not gonna translate well to mobile. Regardless, you may want to look at fingers (asset) https://assetstore.unity.com/packages/tools/input-management/fingers-touch-gestures-for-unity-41076

Get the Fingers - Touch Gestures for Unity package from Digital Ruby (Jeff Johnson) and speed up your game development process. Find this & other Input Management options on the Unity Asset Store.

jolly venture
verbal remnant
# jolly venture How so? Wasd is not difficult on mobile, is it?

think a bit about what 'touch' input really means and whether your game remains truly fun to play when people have to press & hold a bunch of on-screen buttons just to move around. Mobile works best when the input the game needs is designed around finger-gestures and tap-interactions (not press-hold or hover-click)

austere grotto
jolly venture
# austere grotto The fastest way is to use On Screen Controls from the new input system. (E.g. On...

In this third video in our tutorial series, we’ll show you how to add mobile touch controls to your game using Unity’s Input System.

You’ll learn how to use the On-Screen Stick and On-Screen Button components to set up on-screen controls for mobile devices, enabling touch-based input for third-person character movement.

More resources:
...

▶ Play video
austere grotto
#

Yes that tutorial uses on screen controls

viral flicker
#

How can i get an asset inputassetcollection? theyre not available in the inspector, and in my context i dont have a PlayerInput instance that you can read from. I want to be able to remove all binding overrides

viral flicker
#

never mind figured it out

opal moon
#

I have a very weird bug. 2 separate friends (one windows 10, one windows 11) both cant move in my game, but they CAN press other interactable buttons in the game used by the inputsystem such as opeinng the map.

Even weirder one of them has an old build of the game they previously could move perfectly fine on months ago but when they now load it up they can't move anymore.

On my computer, all works perfectly fine.

    private void OnMove(InputValue movementValue)
    {
        Debug.Log("Attempting to move " + isLocked + " loading: " + GameManager.isGameLoading);
        if (!isLocked && !GameManager.isGameLoading)
        {
            _movementInput = movementValue.Get<Vector2>();
            Debug.Log("Moving " + _movementInput);
        }
        else if (_animator.GetBool("isSleeping") || _animator.GetBool("isSitting"))
        {
            _animator.SetBool("isSleeping", false);
            _animator.SetBool("isSitting", false);
            isLocked = false;
        }
    }

My movement code, although im not doing anything special.

And the player controller

austere grotto
#

this will cause pretty much the exact symptoms you're describing

#

Also the thing you called "the player controller" is an Input Actions Asset

opal moon
#

if it makes a difference both also have unity installed but idk why or how that would have any effect. im just bewildered about the old build suddenly breaking

austere grotto
#

Well, you haven't really provided enough info here to debug

opal moon
austere grotto
opal moon
#

for anyone else wondering how to fix this code fixed it for me (run it on start)

    private IEnumerator Check()
    {
        Debug.LogError("console is free");
        Debug.Log("Starting check, waiting 5 seconds...");

        // Wait for 5 seconds
        yield return new WaitForSeconds(5f);

        PlayerInput playerInput = GetComponent<PlayerInput>();
        Debug.Log("CHECKING PLAYER INPUT AFTER 5 SECONDS");

        while (!playerInput.user.valid)
        {
            Debug.Log("Waiting for PlayerInput user to become valid...");
            yield return null; // wait 
        }

        if (playerInput != null)
        {
            Debug.Log("PLAYER INPUT NOT NULL");

            // control scheme switch
            playerInput.SwitchCurrentControlScheme(
                "Keyboard&Mouse",
                Keyboard.current,
                Mouse.current
            );

            Debug.Log("Switched control scheme to Keyboard&Mouse");

            if (playerInput.currentActionMap != null)
            {
                Debug.Log("Current action map: " + playerInput.currentActionMap.name);
            }
        }
    }```

+ disabling gamepad from the input actions asset

I'll mull this over tomorrow and properly implement the fix. very weird nonetheless!
austere grotto
#

you can still freely add bindings from different devices to your actions

#

but PlayerInput uses control schemes to assign devices to players

tropic sorrel
#

I'm having some problems with input system:

  • I click a button (Enter) to enter the game and switch ActionMap to "Game"
  • The first thing that happens when entering the game, is that the "Game" actionmap sees that Enter is pressed, and acts on that event.

This happens even if I use context.canceled to trigger the switching of actionmap.

Should I clear some buffer or cache or something? Ideas?

austere grotto
#

This happens even if I use context.canceled to trigger the switching of actionmap.
Though this is odd and implies to me you're not checking the action phase for your in-game input handling

#

I would expect to see a canceled but not a performed most likely

fallow remnant
#

So I'm pretty new to UI in general, but I've been working on trying to implement UI Toolkit (UXML files) with the Input System.

I really like UI that is controlled with WASD/gamepad rather than mouse clicks, and I've been trying to use Input system with UI Toolkit, but it's super unintuitive... (I mention this specifically, because every single Toolkit tutorial I've seen uses the same exact example of clicking a button on the screen)

Does anyone have any workflows they do when trying to make interactive UI with Toolkit that doesn't involve mouse click buttons?

tropic sorrel
#

I'm mostly using context.performed to trigger events, but I guess this is not what you're talking about?

ornate star
#

I don't know why but sometimes characterRunning value becomes 0 randomly while running causing character to do walk animation for a moment while running even though I don't stop holding space bar?:

//In FixedUpdate():
Vector2 characterWalking = inputActions.Player.Move.ReadValue<Vector2>();
inputActions.Player.Run.performed += ctx => characterRunning = 1;
inputActions.Player.Run.canceled += ctx => characterRunning = 0;
if(characterWalking != Vector2.zero)
{
    Vector3 camForward = Camera.main.transform.forward;
    Vector3 camRight = Camera.main.transform.right;
    camForward.y = 0f;
    camRight.y = 0f;
    camForward.Normalize();
    camRight.Normalize();
    Vector3 moveDir = camForward * characterWalking.y + camRight * characterWalking.x;
    Debug.Log("characterRunning value is : " + characterRunning);
    if(characterRunning > 0)
    {
        character.MovePosition(character.position + moveDir * characterRunSpeed * Time.deltaTime);
        if(moveDir != Vector3.zero)
        {
            Quaternion targetRotation = Quaternion.LookRotation(moveDir);
            character.MoveRotation(Quaternion.Slerp(character.rotation, targetRotation, 0.15f));
            playerCamera.transform.position = character.position + playerCamPos;
        }
        characterAnims.SetBool("isRunning", true);
    }
    else if(characterRunning <= 0)
    {
        character.MovePosition(character.position + moveDir * characterWalkSpeed * Time.deltaTime);
        if(moveDir != Vector3.zero)
        {
            Quaternion targetRotation = Quaternion.LookRotation(moveDir);
            character.MoveRotation(Quaternion.Slerp(character.rotation, targetRotation, 0.15f));
            playerCamera.transform.position = character.position + playerCamPos;
        }
        characterAnims.SetBool("isWalking", true);
        characterAnims.SetBool("isRunning", false);
    }
}
else
{
    characterAnims.SetBool("isWalking", false);
}
fierce compass
#
inputActions.Player.Run.performed += ctx => characterRunning = 1;
inputActions.Player.Run.canceled += ctx => characterRunning = 0;

you're doing this in fixedupdate?

fierce compass
#

that should not be in fixedupdate

#

that should be done once on initialzation, so either in awake or start

ornate star
#

This is how I have used Run in Player input file:

fierce compass
#

it should absolutely not be in FixedUpdate

#

have you tried the input debugger to see if space is being released randomly? could be a hardware issue

ornate star
#

And it was working fine there

#

Wait let me check again

#

Maybe this could be keyboard problem

#

Because this is showing space bar 3 times after left click but I hasn't stop holding space:

fierce compass
#

have you tried with different keyboards, if you have them?

ornate star
fierce compass
#

ah yeah that also works

ornate star
austere grotto
sly spruce
#

For the love of God can anyone help me with this?
I am making a custom virtual joystick, that outputs the vectors basic stuff.
And my game is using full on input system for it.
Like input action for Move and look, and some buttons.

Since i am using Unity UI Tookit for the custom Joystick for custom joystick implementation.
I want this virtual joystick to feed the data to the Input system.

The thing is the left and right joystick works but the dammm button is not working, like i am on this dead end.
And can't figured it out how to make when UI button is clicked and through the virtual gamepad it should trigger that specific button.

I have done so many things but to no vail, the button its not working.
So for the love of god please anyone who know this stuf please blessed me some answeres.

Here is my ControlUIInputBridge,

#

public class ControlsUIInputBridge : MonoBehaviour
{
    [Header("Joysticks")]
    public MovementJoyStick LeftJoyStick;
    public FloatingCameraJoystick RightJoyStick;

    [Header("Input Actions")]
    public InputActionReference MoveInActionRef;
    public InputActionReference LookInActionRef;
    public InputActionReference SprintInActionRef;
    public InputActionReference KickInActionRef;

    [Header("Virtual Gamepad Settings")]
    public float DefaultSprintThreshold = .8f;

    private Gamepad _virtualGamepad;


    void OnEnable()
    {
        if (_virtualGamepad == null)
            _virtualGamepad = InputSystem.AddDevice<Gamepad>("VirtualGamepad");

        if (LeftJoyStick != null)
            LeftJoyStick.SprintThreshold = DefaultSprintThreshold;
    }

    void OnDisable()
    {
        if (_virtualGamepad != null)
        {
            InputSystem.RemoveDevice(_virtualGamepad);
            _virtualGamepad = null;
        }
    }


    void Update()
    {
        if (_virtualGamepad == null) return;

        Vector2 leftStick = LeftJoyStick?.GetInputVector() ?? Vector2.zero;
        Vector2 rightStick = RightJoyStick?.GetInputVector() ?? Vector2.zero;

        leftStick.y = -leftStick.y;   
        rightStick.y = -rightStick.y;



        var state = new GamepadState
        {
            leftStick = leftStick,
            rightStick = rightStick,
        };

        InputSystem.QueueStateEvent(_virtualGamepad, state);
    }

}

sly spruce
#
InputSystem.QueueStateEvent(Gamepad.current, new GamepadState(GamepadButton.LeftShoulder));

Why its not doing it?

austere grotto
sly spruce
#

i need to do custom virtual joystick and need to implement some specific behaviour.
which involves pushing button

#

also usingunity ui toolkit

sly spruce
austere grotto
#

yeah that's what I would've done

sly spruce
#

man if and only they provide an easy way for this.

fallow remnant
#

I just want to control a simple UI with buttons and submenus using keyboard input/gamepad.

austere grotto
# fallow remnant I just want to control a simple UI with buttons and submenus using keyboard inpu...

This is the fourth video in our Input System series. In this video, we’ll show you how to integrate the Input System with UI Toolkit to navigate and interact with a series of buttons.

You’ll also learn how to use gamepad controls to toggle between different button collections, enabling seamless switching on and off.

More resources:

⭐ D...

▶ Play video
fallow remnant
mortal skiff
#

Is ist a good idea in the input actions file to have ona collection for movment, one for moving the camera, one for every diffrent mode the player can be? If you get what i mean

verbal remnant
# mortal skiff Is ist a good idea in the input actions file to have ona collection for movment,...

one approach that works well is to have action maps per "mode". and you'd define those by 'actions that are enabled and disabled together' for concrete gameplay/UX reasons. Its also generally advisable to have as few of these modes as possible. Often a whole bunch of things need to be enabled/disabled in those modes on entry/exit, not just input actions. You would manage them all in a fairly authoritative state machine. When you have too many modes, you can start breaking down the action maps further into groups that can combine into virtual mode-aligned maps, but you would have to manage and configure those yourself. In a setup like this you would not enable/disable action in the scripts that use them. And you would be using InputActionReferences to assign inputs for a system.

viral flicker
#

i've made an input rebind system, and i have this system where u can rebind every button in a sequence, but there's an issue where things like the triggers are recognising letting go as an input and setting triggers twice. How can i fix this?

#
  currentRebind = action.PerformInteractiveRebinding(bindingIndex)
            .WithControlsExcluding("Mouse/position")
            .WithCancelingThrough("<Keyboard>/escape")
            ...
#

this is the code im using rn

lofty warren
#

Does anyone have a JoystickButton chart for the Switch Pro controller?
I have charts for the other consoles but not that one.

dense scarab
#

hi so im trying to use unity's input system version 1.14.2 ive created the "move" action which has action type value and control type vector 2 but when i go to add the up/down/left/right bindings nothing shows up for the binding section to actually bind the key. does anyone know why. thanks

jovial kernel
dense scarab
jovial kernel
#

Has anyone run into the issue where a single key is bound in two action maps (Player, UI) and gets triggered twice in same frame?

When I press "esc" it triggers "OnShowMenu" from Player -> calls MenuManager.ShowMenu -> logic for showing menu + switches action map -> "OnCancel" is called from MenuManager because it's in the same frame as when "esc" was pressed and thus closes the menu immediately.

The mystery is that it only happens the first time. First time I have to press "esc" twice to open the menu, subsequently all "esc" presses work as expected to open and close.

My current solution is to just run "ShowMenu" in a Coroutine so that the "esc" is not read in the same frame. But this feels like a hack.
Here's my current code solution: https://paste.mod.gg/mjgxyvgyeymq/0 - does anyone have any other ways they approached this?

jovial kernel
dense scarab
#

ive also tried both but that didnt work either

oak rock
#

when reading the value of a joystick, how do i ignore the distance and just use the angle?
for instance in this image, two joysticks are being held at the same angle but one is pushed further from the center. all i care about is the angle

dense scarab
#

and if so how can i fix it

fierce compass
fierce compass
#

if so, have you tried resetting the library?

dense scarab
dense scarab
fierce compass
#

close the project, delete the Library folder at the project root, reopen unity
it'll take longer to open then usual due to having to rebuild the library

dense scarab
#

oh ok thanks ill try that now

dense scarab
fierce compass
#

oh god it's in onedrive, that's probably part of the issue

#

don't put unity projects in onedrive

#

moving it outside (and maybe resetting the library again) might work. if not then i guess yeah restarting could make sense
(though btw, you can transfer other assets as well, just make sure to transfer the meta files too)

dense scarab
#

oh ok ye i just noticed when i created the folder i accidently put it into my uni folder which is in my onedrive ye ill just restart it thanks for the help

cobalt knot
#

Ok so i have this little bug that is driving me crazy

The OnSelect() function on my buttons doesn't trigger when pressing enter when i start the game, but if I navigate once between buttons with the arrow keys then it will work

I'm using Unity Input System and the keyboarg/gamepad, the mouse is disabled on this game

Thanks

verbal remnant
verbal remnant
toxic lintel
#

Why?

verbal remnant
toxic lintel
#

Well, the round ones anyway

cobalt knot
wintry swan
#

Hello everyone, I've been dealing with this error for a while now. The error appears in the console with the following text:
Exceeded budget for maximum input event throughput per InputSystem.Update(). Discarding remaining events. Increase InputSystem.settings.maxEventBytesPerUpdate or set it to 0 to remove the limit.

To replicate this error, all I need to do is enable Play Mode in Unity Editor, tab out, and wait about 10 minutes. The error will appear with the exception in the console.

I attempted to debug this by going back a good amount of commits in git to diagnose when this issue started, and it's when I used the Package Manager to install the InputSystem (to switch away from utilizing the older InputManager). I also attempted to switch to a different Scene with very few GameObjects and scripts to see if this is a specific scene issue, and this error still appears. I just tested and replicated the steps on the executable that I built from the project, though, and the issue doesn't persist there (like animations are still playing, as opposed what's happening in the Editor's Play Mode).

Anybody have any idea what's causing this error? There's a Unity forum discussion here: https://discussions.unity.com/t/runtime-error-exceeded-budget-for-maximum-input-event-throughput-per-inputsystem-update/916983. There are very few Google searches, and ChatGPT doesn't really have a specific source in the answers that they are giving me

Edit: forgot to mention that I'm using 2022.3.31f (which I believe is LTS), and InputSystem v.1.7

fierce compass
unborn crow
# wintry swan Hello everyone, I've been dealing with this error for a while now. The error app...

I've experienced this sometimes as well when tabbing out of Unity and leaving it in play mode. I'm not sure what causes it, something to do with input events being queued up while tabbed out and then the first frame you're tabbed back in all the queued inputs exceed maxEventBytesPerUpdate and then it ignores anything over that limit
It can safely be ignored, it's more of a warning / self correcting thing I guess

uncut yacht
#

Maybe you have "Error Pause" on for the console, then everything stops in editor play mode.

wintry swan
#

Thanks for the replies, y'all. The original InputManager does not have this issue, which is why I'm puzzled why this error is happening in the first place. Coniix's explanation makes sense, but it's a little ... strange that the PlayMode completely stops and exits out (due to the exception), when the original InputManager (i.e. without the InputSystem) didn't have this issue before

#

I'll test to see if "Error Pause" is causing the issue

wintry swan
#

Yeah, didn't know about "Error Pause" being enabled, so PlayMode doesn't exit now. The error is still strange

wintry swan
#

I didn't know that I could investigate the Unity source code via Unity Editor and Visual Studio until now. This is where the error is pointing towards

    internal partial class InputManager
    {
        //...
        private unsafe void OnUpdate(InputUpdateType updateType, ref InputEventBuffer eventBuffer)
        {
            //...
            var canEarlyOut =
                // Early out if there's no events to process.
                eventBuffer.eventCount == 0
                || canFlushBuffer ||
                // If we're in the background and not supposed to process events in this update (but somehow
                // still ended up here), we're done.
                ((!gameHasFocus || gameShouldGetInputRegardlessOfFocus) &&
                    ((m_Settings.backgroundBehavior == InputSettings.BackgroundBehavior.ResetAndDisableAllDevices && updateType != InputUpdateType.Editor)
            //...
          }
         //...
            try
            {
                m_InputEventStream = new InputEventStream(ref eventBuffer, m_Settings.maxQueuedEventsPerUpdate);
                var totalEventBytesProcessed = 0U;

                InputEvent* skipEventMergingFor = null;

                // Handle events.
                while (m_InputEventStream.remainingEventCount > 0)
                {
                    if (m_Settings.maxEventBytesPerUpdate > 0 &&
                        totalEventBytesProcessed >= m_Settings.maxEventBytesPerUpdate)
                    {
                        Debug.LogError(
                            "Exceeded budget for maximum input event throughput per InputSystem.Update(). Discarding remaining events. "
                            + "Increase InputSystem.settings.maxEventBytesPerUpdate or set it to 0 to remove the limit.");
                        break;
                    }
               //...
wintry swan
#

I think I discovered what the issue was? If I leave my PS4 controller connected, it would error. But I let the game on for 20 minutes without the PS4 controller, and I haven't seen the exceeded budget exception on the console

fierce compass
#

well something like that would constantly be sending motion info wouldn't it

#

if it has that

crisp cape
#

If the controller is flat it stands to reason it wouldn't (not got a controller to know) but all inputs from controllers boil down to the binary format of 1 or 0 is active or is inactive. The idea of it being slightly active is a check after which says if it's in the 1 state how long did it take to get to that position etc. your keyboard has similar, on key press, key up etc

fierce compass
#

if it wasn't constantly sending then there wouldn't be any difference between an idle controller and a disconnected one

crisp cape
#

Even a button held down sends the same data, in the binary instance 1, it should automatically revert hence why you sometimes get input lag

fierce compass
#

also btw, analog values exist

crisp cape
#

You can edit the input lag too if you want, it's fun to mess with people

fierce compass
#

the buttons cost 1 bit, yes, but analog data costs much more

#

joysticks cost like, 64 bits each

crisp cape
wintry swan
#

to give some context to this controller, it's relatively new. I'm pretty sure that I got it when Monster Hunter Wilds came out, so some time in February

fierce compass
fierce compass
wintry swan
#

my bad lol

crisp cape
#

Honestly bravo on timing

wintry swan
#

I don't know if this matters as much, but my PC is relatively new as well, but was built as a "custom" build. I'm not sure if that gives context to the issue

fierce compass
#

yeah i don't think any of that really matters too much

wintry swan
#

so maybe my motherboard has some weird interaction with it

fierce compass
#

it's just a moderate chunk of data accumulating every frame (or perhaps more frequently with hardware polling, not sure) for a long duration

#

the data is gonna build up eventually

wintry swan
#

what i'm confused about is how everyone else isn't experiencing this issue. Surely, other ppl hooked up PS4 controllers to test and let Unity Editor sit as tabbed out. There's only about 3 google results that I can find in regards to this issue

#

I'll necro-bump that thread that I posted above tomorrow and maybe can get more context

crisp cape
#

I can hook up my Xbox 360 controller and test if you'd like

wintry swan
#

The old InputManager never had this problem

wintry swan
crisp cape
#

If you want you can dm me the script and I'll rig it up

fierce compass
wintry swan
fierce compass
#

i have a switch controller and i can say from memory that with the input debugger you can see it giving wayyy more info than keyboard or mouse

wintry swan
#

I didn't have any Script that utilizes PlayerInput or InputActions

fierce compass
#

most likely due to the several inertial sensors and joysticks, which would be like, 500B every tick, and the ticks just flow in at an insane rate compared to keyboard/mouse events

wintry swan
#

oh, I guess I should've posted this in my initial post that I'm using 2022.3.31f (which I believe is LTS), and InputSystem v.1.7

wintry swan
fierce compass
#

(but to reiterate - i don't really think this is an issue, and im not super convinced this is an error either tbh? this sounds like a warning)

wintry swan
#

Probably not an issue, but my team and I plan to eventually release this game. Unity Editor shows this with a red exception marking and not a yellow warning one, so I wanted to cover my bases just in case

fierce compass
#

it kinda has limited support, i had to install a 3rd party package to register the hardware as a controller in unity

wintry swan
#

ahh gotcha

crisp cape
#

Don't worry, if there's an issue I can find it and probably help fix it.. I broke unity a fair few times

wintry swan
#

lol believe it or not, that's super helpful to do. I've done my fair share of doing that with Qt

fierce compass
crisp cape
#

Depends on whether it's a memory leak issue and if the input even unpaused is stacked

wintry swan
fierce compass
#

it'll all be consumed the next frame so once you're tabbed back in it should be fine

#

input events aren't replayed over time

wintry swan
#

I don't know enough about Unity, so I'm not sure

crisp cape
#

Send me your input, my DMS open I'll test it now

fierce compass
#

(why not just send it here)

crisp cape
#

Not sure if it's allowed

wintry swan
#

I believe that I sent it to you, unless I needed to add you as a friend?

fierce compass
crisp cape
#

Odd I didn't get a message

fierce compass
#

it's also most likely not a memory leak since it's actively discarding excess input

wintry swan
#

a memory leak can simply be a pointer that contained an object and was not cleaned up properly. it's easier to see it in C++, but we kinda have to "trust" C#'s and Unity's garbage collection if I remember how garbage collections were done

#

I just started to look at Unity's InputSystem.cs today and was tracing the error

crisp cape
#

Don't worry, part of Unity was coded in C++ unless they went full native recently

wintry swan
#

C++ can have tons of memory leaks. Unless Unity fully replaced all their pointers with smart pointers that were implemented in C++11, we kinda have to "trust" that their raw pointers were cleaned up properly, among other things that caused memory leaks

#

But this is assuming if this is a memory leak in the first place lol. They are at least aware that this issue existed once before, through the forum post and through the issue tracker:
https://issuetracker.unity3d.com/issues/exceeded-budget-for-maximum-input-event-error-appears-when-entering-play-mode-if-setting-inputsystem-dot-settings-dot-maxeventbytesperupdate-to-more-than-0

unborn crow
#

I suppose whether or not there's a risk of memory leaks depends on how that inputqueue is handled when unity is running in the background. Is it capped at the value of maxEventBytesPerUpdate (default 5mb) or is it allowed to fill up and only truncated when the input systems Update function is called.

Based on the wording of the error it says "Exceeded budget for maximum input event throughput per InputSystem.Update()" the fact it says throughput would lead me to believe that until the InputSystem.Update happens that the input events are just piling up in the buffer which is then cleared once the max amount of inputs are processed during Update.

So I'd say there's potential of a memory leak there. There's another question of does it only behave like this in the editor or in builds also. Would be interested to see what further investigations could find on this.

You can play around with the settings if you're looking deeper into this and don't want the long wait time when tabbed out to recreate the error e.g. here the maxEventBytesPerUpdate is set to 100kb instead of 5mb to make recreation of the issue a little easier, with that I was able to tab out for a few seconds and it recreated it, with smaller values I found it happened instantly on tabbing out

    InputSystem.settings.maxEventBytesPerUpdate = 100 * 1024;
covert fern
#

Hi, I have an issue regarding Input Actions (Unity 6). I need a simple system to detect a button press (only active at start and not when button is held), button held, and button released. I am using Button Actions for Jump, Left, Right, Attack etc.

I have tried many things, even making my own system where I have three boolean variables for each input that I set manually inside a custom method for each, but that ends up becoming very cumbersome and convoluted. I can't help but think there must be an easier way to do this, seems like such a basic thing to detect these button states. Context.started, context.performed and context.canceled don't really behave the way I want, and I don't want to have to use booleans for each button and reset certain states in LateUpdate() or at the end of FixedUpdate() or anything convoluted.

I just want a simple way to detect button press states, please help 😄

thin musk
#

Hey, how can I make it so a mouse ignores player object?
I want it to act as if player doesn't exist and do the onenter/onexit on an object underneath the player.

Player has colliders, sprite renderer.
It's a 2D game.

#

I tried adding a player to IgnoreRaycast layer, but that didn't help.

crisp cape
#

You can decide what the mouse interacts with through Layers, you could in theory tell your mouse to interact with all layers BUT a layer including your player GameObject

thin musk
#

How can I do that with layers?

#
IMapElementComponent, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler

I have these to detect mouse input in my world objects.
I want them to ignore player

#

But I dont want to write if(layer == player) for all my scripts

crisp cape
#

generally

public LayerMask playerLayerMask;
Then you can do checks against it so in inspector you can allocate the playerLayerMask and tell your code if(!playerLayerMask){ Insert Code here}

thin musk
#

Is there a way to simply make my player invisible to raycast?

#

You can disable raycast on UI elements in the inspector

#

For some reason my camera had all rayacast layers selected, maybe after I added cinemachine it did that?

#

I just unchecked one of the layers and it works now

wintry swan
# unborn crow I suppose whether or not there's a risk of memory leaks depends on how that inpu...

Is it capped at the value of maxEventBytesPerUpdate (default 5mb) or is it allowed to fill up and only truncated when the input systems Update function is called.
Yeah, I haven't touched the value InputSystem.settings.maxEventsBytesPerUpdate at all within any code or scripts

You can play around with the settings if you're looking deeper into this and don't want the long wait time when tabbed out to recreate the error e.g. here the maxEventBytesPerUpdate is set to 100kb instead of 5mb to make recreation of the issue a little easier, with that I was able to tab out for a few seconds and it recreated it, with smaller values I found it happened instantly on tabbing out
Oh, good idea. Thanks for the tips!

#

I did a bit more investigation using Windows->Analysis->Input Debugger, and I came acrossed something interesting

#

The DualShock4 input is always processing due to the contrast toDisabledWhileInBackground flag to Keyboard and Mouse. But the default behavior while I'm active with Unity Editor is strange cus it's constantly always running, unlike Keyboard and Mouse. It's as if I'm swinging the Mouse constantly by default. I put up screenshots with Keyboard and Mouse for comparison (Keyboard has inputs due to me doing Alt+PrtScrn for the screenshot, Mouse has inputs due to me swinging to maximizing and moving it)

#

Huh, XboxOne controller does not have this issue

unborn crow
#

Although looking at the list of inputs in the debugger I can't see anything that would match those sensors, and when pausing the debug feed and clicking into one of the outputs everything is 0 so am not sure

#

When looking at the live memory for the controller Editor (Current) you can see some weird movement / flipping of bits but it doesn't feel like it directly reacts to movement of the controller, maybe a little but it's weird

unborn crow
#

Clicked on State -> Display Raw Memory -> Bits / Hex -> Editor (Current) from the last dropdown

wintry swan
#

ahh gotcha. thanks

void lagoon
#

Hello guys! Soooo I was using the "old" input system (using like "Input.GetKey(Keycode)" and so) and in the same script I've created the "jump" action when you press the jump key and "cancel jump" when you realease the jump key when you're jumping. Then yesterday I wanted to make the android port to the game and so I decided to switch to the new input system but when I tried the jump method it didn't work, the high was like the double as before and didn't even recognize the key when pressed or realeased, though sometimes it acted like normal, its very inconsintent.

I'll send the paste.mod link
https://paste.mod.gg/snsradyenbgd/0

austere grotto
#

Physics needs to go in FixedUpdate if you want it to be consistent

void lagoon
#

But I've tried that too and the same thing happend

#

Also, before I switched to the new inout system it worked like that, idk why now is glitching

austere grotto
faint hearth
#

Hi ! I'm making a Unity game in Unity 6 where i need to have Basically Keyboard, COntroller and Steering wheel (Using SDKs) input, but i'm not really sure how to implment it, i've already got my SDK working, i just need to make the inputsystem work

austere grotto
#

The input system has support for all those devices by default

faint hearth
#

I'm using the LogitechGSDK to supprt my driving wheel (since its the only wheel i have for now)

austere grotto
# faint hearth I'm using the LogitechGSDK to supprt my driving wheel (since its the only wheel ...

Use the Logitech Gaming SDK from Logitech Gaming on your next project. Find this integration tool & more on the Unity Asset Store.

faint hearth
#

Also, this should not be on the website

#

Its colpletly broken

#

Its not up to date

#

I had to ask supprt for a UTD one

austere grotto
#

If you have an issue with the package you should bring it up with Logitech

jovial comet
#

Does anyone know how to read the Gyroscope input from the Steam Deck in the Unity Input System?

When I check InputSystem.Gyroscope.current, there isn't one available. And I can't figure out what kind of binding to set up.

crisp cape
austere grotto
#

Oh if current is null that's a different story

digital lantern
#

Hey! Please ping me if anyone helps out, but is there a way to determine speed? Like for example, if your thumbstick is pushed slightly, the character goes slow, if it's pushed all the way at the edge, the character goes max speed

austere grotto
austere grotto
digital lantern
digital lantern
#

Why isn't this working?

#
using UnityEngine;
using AGS;
using AGS.Project;
using UnityEngine.InputSystem;
using Unity.VisualScripting;

public class PlayerInput : AGSMonoBehavior
{
    private static PlayerInput m_Instance;
    public static PlayerInput Instance
    {
        get
        {
            if (m_Instance == null)
            {
                m_Instance = FindFirstObjectByType<PlayerInput>();
                if (m_Instance == null)
                {
                    AGSDebug.Log("The player input manager is not in the scene", m_Instance, AGSLogType.WARNING);
                }
            }
            return m_Instance;
        }
    }
    public InputAction Move;
    public InputAction Look;
    public InputAction Sprint;
    public InputAction Jump;
    public InputAction Crouch;
    public InputAction Interact;
    public InputAction Pause;

    public static PlayerInput Create() => new GameObject("[Player Input Manager]").AddComponent<PlayerInput>();

    public override void Awake()
    {
        DontDestroyOnLoad(gameObject);
        Move = InputSystem.actions.FindAction("Player/Move");
        Look = InputSystem.actions.FindAction("Player/Look");
        Sprint = InputSystem.actions.FindAction("Player/Sprint");
        Jump = InputSystem.actions.FindAction("Player/Jump");
        Crouch = InputSystem.actions.FindAction("Player/Crouch");
        Interact = InputSystem.actions.FindAction("Player/Interact");

        Pause = InputSystem.actions.FindAction("UI/Pause");
    }

    public override void OnEnable()
    {
        Move.Enable();
        Look.Enable();
        Sprint.Enable();
        Jump.Enable();
        Crouch.Enable();
        Interact.Enable();

        Pause.Enable();
    }

    public override void OnDisable()
    {
        Move.Disable();
        Look.Disable();
        Sprint.Disable();
        Jump.Disable();
        Crouch.Disable();
        Interact.Disable();

        Pause.Disable();
    }
}
#

I have a Input Action mapping, but my script can't find the actions

austere grotto
#

Are you seeing an error of some kind?

#

Also your singleton logic is flawed (unrelated)

digital lantern
#

What's funny is that because of that code where it tries to find the actions, my gameobject disables itself

digital lantern
burnt dawn
queen wolf
#

Is there any accepted practice for determinig if the current controller triggers are bool type vs float types? (ie are they capable of giving a 0-1f value rather than just on and off?

fierce compass
#

within the InputSystem itself, i don't think so
ButtonControl is an InputControl<float> (inherits AxisControl) so they can both emulate each other (float to bool via pressPoint)

queen wolf
fierce compass
queen wolf
#

My code itself has some considerations that I don't think it will cover, short of being able to poll and determine what kind of trigger it is

fierce compass
#

how so?

queen wolf
#

A soft pull with a 0-1f would add to a chargup value... but if its a bool type trigger, then instead it will charge on pulled and discharge on release. Where as the soft pull will discharge on the full pull instead

fierce compass
#

huh, that soft pull thing sounds kinda unnatural to me (though i don't play many games). is that a common thing?

queen wolf
#

I'm not really prepared to go into the nature of the thing I am modeling here, I need to keep working. But that is the thing I am coding for.

#

The behaviour will be quite different for an float vs bool type trigger.

fierce compass
#

im just asking if the "soft pull" vs "hard pull" being different actions is a common thing

queen wolf
#

The thing I am making is not a common thing no, I am making this up and play testing will sort out of it works for this use case or not.

#

I just needed to know if the input system had any meta I could poll or not

#

Thanks for the answer btw, that was what I needed to know

digital lantern
lament wraith
#

can I use this type of code with the new input system?

    {
        Debug.Log($"Started dragging: {gameObject.name}");
        // Add your drag start logic here (e.g., change visual state)
    }```
burnt dawn
#

the one in project settings is so you can do InputSystem.actions

digital lantern
#

They just look empty but they are loaded?

burnt dawn
#

if they don't fill up that means they aren't found

digital lantern
#

Oh okay, why? I assigned the asset

#

I got the action map right and the action name

#
 public override void Awake()
 {
     if (Instance != null && Instance != this)
     {
         AGSDebug.Log("The player input manager already exists!");
         Destroy(gameObject);
     }
     Instance = this;
     DontDestroyOnLoad(gameObject);
     Move = InputSystem.actions.FindAction("Player/Move", true);
     Look = InputSystem.actions.FindAction("Player/Look", true);
     Sprint = InputSystem.actions.FindAction("Player/Sprint", true);
     Jump = InputSystem.actions.FindAction("Player/Jump", true);
     Crouch = InputSystem.actions.FindAction("Player/Interact", true);
     Pause = InputSystem.actions.FindAction("UI/Pause", true);
 }
burnt dawn
#

try to use FindActionMap first and then FindAction on that

digital lantern
#

Oh wait, under the input mode I had "Both"

burnt dawn
#

you can also use the debugger in your IDE to traverse the actions arrays in the maps

digital lantern
digital lantern
#

Okay, I got it working. Now, another question, and please ping me if anyone helps, but is there a way to alter processors in C#?

lament wraith
#

Turns out I just needed an Event System

urban valve
#

Cause I'm not getting any Vector2 values or button presses

#

and the Input Debug window is displaying (no asset) after Actions - Debug Menu/Debug xxx

urban valve
fierce compass
#

make sure the player settings have the input system enabled

urban valve
#

I'm using 6000.0.55f1 and package 1.14.2

urban valve
#

I tried running play focused and maximized

fierce compass
#

have you tried the input debugger?

urban valve
#

yes

fierce compass
#

and what does it show?

urban valve
fierce compass
#

so hardware input is being received

urban valve
#
using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerController : MonoBehaviour
{
    public float Speed = 2f;

    private InputAction moveAction;
    private InputAction jumpAction;

    private void Start()
    {
        Debug.Log("Hello movement");
        moveAction = InputSystem.actions.FindAction("Move");
        jumpAction = InputSystem.actions.FindAction("Jump");
    }

    void Update()
    {
        Vector2 moveValue = moveAction.ReadValue<Vector2>();
        if (moveValue != Vector2.zero) Debug.Log($"Moving {moveValue}");
        transform.Translate(Speed * Time.deltaTime * moveValue);

        if (jumpAction.IsPressed())
        {
            Debug.Log("Jump lol");
        }
    }
}
fierce compass
#

ive.. never seen those "Debug Menu" actions tbh

urban valve
#

only "Hello movement" is printed

fierce compass
#

are you getting any errors?

urban valve
#

nope

fierce compass
#

could you try logging moveAction/jumpAction

urban valve
#

seems fine

#

if it's relevant, I don't have a Player Input component anywhere

fierce compass
#

could you try checking InputSystem.actions.enabled and moveAction.enabled?
iirc, the default actions should be enabled automatically, but i can't seem to find that in the docs now.

fierce compass
#

so, that's the issue then i guess

urban valve
#

yep

fierce compass
#

could you confirm that the project-wide input actions is set to the right asset?

urban valve
#

I used the defaults

#

oh

#

so I use Entities and disabled domain reloading

#

fortunately there's a solution for that in the replies🫡

oak harbor
#

Because for the love of all that is dear to me, I can't figure out why is it being canceled first before any interaction happens, so...
I'll ask here: Why does this happen? It shouldn't work like that. Trying to separate Tap from Hold for two different actions on same button.

public void OnDash(InputAction.CallbackContext context) {
    switch (context.phase) {
        case InputActionPhase.Performed:
            if (context.duration < 0.5f) {
                Debug.Log("Tap");
            } else if (context.duration > 1f) {
                Debug.Log("Hold");
            }
                break;
        case InputActionPhase.Canceled:
            Debug.Log("Cancel");
            break;
    }
}

Edit: No, putting the cases in different order does not solve the issue.

polar cosmos
#

Is there a proper way to use the Input System without using "FindAction" ? i want to have as little to none string refs as possible.
I found that assigning them in Editor is quite tedious and that there is a "Generate C# Class" thing, that i see basically noone use, but well i cant find much help in how to use that generated file properly.
Does anyone have an tip or idea how to use it properly so i can keep my code clean ?

silk wyvern
# polar cosmos Is there a proper way to use the Input System without using "FindAction" ? i wan...

Not sure about the old system. Might work the same way.
I only know, when using the new one with the "Input Manager" ("Create -> Input Actions"), it allows to export a class of your input mappings,
which allows named access to your maps/actions.
Select the newly created "Input Actions" object in your project explorer, then in the inspector, check the box "Generate C# Class",
then hit "Apply". And always do "Save Asset" when you changes a mapping in Input Manager to update said file.
What it does internally is a different topic, but it saves you from using strings yourself. No clue if "no one uses it" ...

So

var inputAction = playerControls.FindAction("MyMapping/Jump");

becomes something like:

var inputAction = myPlayerControls.MyMapping.Jump;

myPlayerControls would be an instance of that class you define in your script and the other two objects (MyMapping and Jump) are generated with the names you used in the Input Manager for the Mapping and the Action.

oak harbor
burnt dawn
#

you should see if it happens with either of those interactions alone by themselves

#

how/where are you assigning OnDash to the action

austere grotto
#

Tap and hold are pretty much complete opposites

oak harbor
austere grotto
#

Which your code is ignoring right now

#

So you're probably seeing the cancel from the tap when you hold

#

E.g.

if (context.interaction is TapInteraction)
        {
            Debug.Log("Tap");
        }
        else if (context.interaction is HoldInteraction)
        {
            Debug.Log("Hold");
        }```
oak harbor
fluid perch
#

Hey yall. I started working on mobile factory tycoon type game. I am trying to make pan and pinch-zoom. I am using touch/position for this, but it bothers me - could I be missing something? What is the clean way to make pan, tap, pinch-zoom and two-fingers pan using input system?

verbal remnant
# fluid perch Hey yall. I started working on mobile factory tycoon type game. I am trying to m...

you use input system only as the source of the raw pointer data and implement your own 'gesture' abstraction on top. One common approach is to model it after the iOS API for gestures. Or use https://assetstore.unity.com/packages/tools/input-management/fingers-touch-gestures-for-unity-41076

Get the Fingers - Touch Gestures for Unity package from Digital Ruby (Jeff Johnson) and speed up your game development process. Find this & other Input Management options on the Unity Asset Store.

oak harbor
#

Tried to change hold time in interactions too.

#

don't know what press point is so not touching it

mellow palm
#

Hi, I want to make it so I have the same Action being possibly triggered by two bindings (press and hold)

What is the best way to do that? should I have two different Actions?

I was trying using 2 bindings under the same action but I couldnt get it to work this way

austere grotto
ornate star
#

Will there be any problem in using both old and new input system?

crisp cape
#

😮‍💨 this topic was debated.. briefly using old for testing is ok, new recommended for actual full projects, in settings you can also choose both. Do not mix them as in want ("Horizontal") and ReadValue<Vector2> at same time

fierce compass
lament wraith
#

I have a strange problem. the first time hitting the Tab key it does not pass in the .started the first one is a .canceled so it doesn't open inventory, but then it works fine after.

void lagoon
#

Hello guys!!! I have in my Input System the "UI" action map that only has "Pause" on it. Then, when I try to play the game if I start on the level scene (the only scene that has the script that pauses the game) without even selecting my character (starting here is impossible if you don't select your character first) the input works, it pauses. But if I neither start on another scene (the normal gameplay) or I go back to the menu and select my character the pause doesn't work...

#

the Input System (btw the keyboard and the gamepad has the check mark for each one)

#

and the Inspector

#

can anyone help me?? I'm very lost

chrome urchin
#

Does anyone know if there is a way to check that an input vector2 value is cancelled because the buttons have been released and not just because two buttons that cancel each other out resulting in the value being 0? I want something to happen when no movement is being input, but cancelled gets called when two opposite buttons are being pressed (e.g. left and right) and I don't want that.

#

I might just break it into 4 different actions, but that just seems really stupid. Like how is there no option for checking if the input has been released?

uncut yacht
#

You can check in code (Update) without actions but maybe you don't want that.

if (Gamepad.current.buttonEast.isPressed)

chrome urchin
#

That one also returns false when I press two opposite buttons :/

#

oh, but that's on the action, I could try it without actions yeah. It's not optimal but it might be the best solution

chrome urchin
#

I ended up adding a foreach check to the cancelled callback to make sure no button in the action is pressed

  private void OnStopMove(InputAction.CallbackContext obj)
  {
      // Move.cancelled gets called when the value is zero, so we have to check 
      // that all the buttons are released to make sure this is because we are receiving no input, 
      // rather than because we are receiving opposing inputs that cancel each other out.
      bool isPressed = false;
      foreach (var ctr in obj.action.controls)
      {
          if (ctr.IsPressed())
          {
              isPressed = true;
              break;
          }
      }

      _isSprinting &= isPressed;
  }
small trail
#

Hey, did anyone try to make MultiplayerEventSystem work with UI Toolkit? It seems there needs to be a GameObject for player root 😐

charred swallow
#

How can I make it so that when I click on a square ( each of them are their individual GameObject ), an event gets triggered?

austere grotto
#

(it will also need a BoxCollider2D, and you'll need an EventSystem in the scene and a PhysicsRaycaster2D on your camera)

charred swallow
#

it works now

#

thanks again @austere grotto

#

now I know about le IPointerClickHandler and EventSystem

#

and physics2draycaster

austere grotto
sick oar
#

Do u guys have any tips on camera controlling (pinch, pan) on Mobile to make it smoothly ? It is quite hard to test the result

#

I want the camera to have acceleration

frozen mauve
#

I'm having a weird issue where InputAction.WasPressedThisFrame returns true for 2 consecutive void update calls

#

The same happens for the performed event

#

I'm using a button type, the bindings are Spacebar and Press [Pointer]

#

This is the setup I'm using

frozen mauve
#

Fact checked statements:

  • The calls do happen on 2 consecutive frames
  • The issue occurs with at least WasPressedThisFrame, performed, and triggered
  • The same thing happens even if we use LeftButton [Mouse], it's not because it's pointer press
  • The input action is, in fact, a button type
austere grotto
frozen mauve
#

InputSetting update: Poll on dynamic update

austere grotto
frozen mauve
#
private void Update()
{
    if (InputManager.controls.Menu.Confirm.triggered || fastForwarding)
    {
        Debug.Log($"Click {Time.frameCount} {InputManager.controls.Menu.Confirm.phase}");
            
        SkipTransition();
    }

    if (InputManager.controls.Menu.Exit.WasPressedThisFrame()) fastForwarding = true;
}
austere grotto
# frozen mauve

It looks like this fastForwarding thing could also trigger that block

frozen mauve
#

I obviously checked that

austere grotto
#

I can't assume anything one way or another

frozen mauve
#

Fast forwarding had always logged false

austere grotto
#

What's inside this SkipTransition function?

frozen mauve
frozen mauve
#

If there was an exception thrown I could kind of still make the assumption that it might've blocked it from finalizing, but I've looked this over 10 times at least and like... This is most certainly not just a simple retrigger

#

Haven't disabled and re-enabled the action/asset eitger

frozen mauve
#

The last two lines of a performed event callback showed some difference in the two callbacks
However the "NotifyBeforeUpdate" version happens 1 frame after "NotifyUpdate"

UnityEngine.InputSystem.LowLevel.NativeInputRuntime/<>c__DisplayClass7_0:<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType,UnityEngineInternal.Input.NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType,intptr) (at /home/bokken/build/output/unity/unity/Modules/Input/Private/Input.cs:120)
UnityEngine.InputSystem.LowLevel.NativeInputRuntime/<>c__DisplayClass10_0:<set_onBeforeUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType)
UnityEngineInternal.Input.NativeInputSystem:NotifyBeforeUpdate (UnityEngineInternal.Input.NativeInputUpdateType) (at /home/bokken/build/output/unity/unity/Modules/Input/Private/Input.cs:105)
#

Not that I have any ideas on how to interpret this situation

frozen mauve
#

Another thing noticed: It only happens on InputActions, if I access LMB directly this won't happen

lean jasper
#

copied from general for visibility:
has anyone tried setting Interactions to VR controller buttons in the Input System? I've noticed no matter which Interaction I choose I can't get the button to 'perform'

austere grotto
#

do you happen to have any odd settings in the project, like the input system polling mode set to something different than the default?

frozen mauve
austere grotto
#

I see

frozen mauve
#

And, weirdly enough the onscreen button does not need to be bound to a related key at all

#

Because the onscreen button in question was bound to Esc, which had nothing to do with it

boreal ruin
#

Hi, I would like to know how can I do a composition of two keybinds to do an action, for example, Q + D or something like that, and it has to be pressed simultaneously

slim beacon
#

Hello, i've encountered an annoying issue with the way dualsense controller using the new input system. For some reason when i tilt the right stick to the right or the left, it flickers between gamepad and keyboard and mouse profiles. I'm confused and i have no idea what could be causing it. Any ideas?

#

Correction: connected my switch pro controller, same behaviour. I have no clue what causes it

steady girder
#

Guys how can I make sound effects !?

fierce compass
slim beacon
candid oasis
#

My computer has a problem or Gampad.current can return a saved disconnected device ?

forest raft
patent socket
#

is there a way to enable UnityEngine.InputSystem.PlayerInput for edit mode tests in Unity?

#

because atm PlayerInput is always disabled so I can't add a user so none of my tests work

#

im also struggling to get the player user to be valid

patent socket
austere grotto
patent socket
#

1.14.2

#

and im on that docs version as well

patent socket
#

god this is frustrating, been at it for like 6hrs today 😭

austere grotto
patent socket
#

can't add wait frames

#

there's nothing to say I have to use a play mode test though

austere grotto
#

shouldn't it be a playmode test?

patent socket
#

playmode tests are slow and crap

austere grotto
#

If they actually work though...

patent socket
#

we already have like 500+ unit tests running on each PR

#

they're not using playmode tests

#

Otherwise it'd be [UnityTest] right?

austere grotto
#

you just can't simulate frame updates

#

yeah I'm pretty convinced your stuff isn't working becuase it's not a playmode test.

patent socket
#

ill attempt that now

#

oh fs, that works

#

REEE why is there no "NOTE: THIS DOESN'T WORK IN EDITMODE" 😡

austere grotto
#

I basically assume anything that uses any part of the engine or any unity package needs a playmode test

#

it's only when it's my own pure logic that it can be an edit test

#

but yeah, it should be noted

patent socket
vapid estuary
#

Hey, this is sorta difficult to show evidence of, but when I build my project to test on other devices, all commands related to "GetAxisRaw" seem to stop working for some reason
So everything works fine when testing and in the built game when I'm testing on my PC, but when I go test the build on my laptop or my girlfriend's laptop, no inputs that ask for "GetAxisRaw" work, while all other inputs work fine, which is especially unfortunate given i use GetAxisRaw for player movement
I've really been scratching my head with this one, does anyone have any idea why this would happen or what I can do about it?

austere grotto
fierce compass
#

not sure if relevant, but may as well - is input handling in player settings set to Old or Both?

vapid estuary
vapid estuary
austere grotto
vapid estuary
#

also nvm input system is already on "both"

fierce compass
vapid estuary
fierce compass
#

if you aren't using inputsystem then yeah worth a shot probably

#

though fwiw, im pretty sure this channel is just for the new input system

vapid estuary
#

o oops

#

where should i ask about old input system for future reference

fierce compass
vapid estuary
#

alr

fierce compass
#

well, that last point is a given, since it's the catch-all lol

#

i'd go with #💻┃unity-talk with this one since i'd hazard a guess it's due to setup/config rather than the usage within code

fierce compass
vapid estuary
#

alright well ill just move there but right now it wont let me change to old every time the editor restarts with the changes it stays on both for some reason lol

fierce compass
#

make sure to read the prompt carefully, i recall it having some odd wording

#

let's move the discussion there yeah

quasi chasm
#

Is there an easy way to filter out touches that are captured by ui? I have an action that takes any pointer click and I dont want it to fire if I'm clicking on ui

#

really not much to the action itself

cold steppe
#

Hey y'all
I get a weird bug with my input-system using game where Dualshock/Dualsense input is "doubled". It seems it's detecting it BOTH as a playstation gamepad and a standard HID gamepad at the same time and processing each input twice.
Any idea how to fix this?

#

main issue is when playing through steam it seems to work alright, it's just broken when starting the executable without steam input

boreal ruin
#

Hey, I have a problem (the one I deleted before is corrected now !)
Now i have this but the rebind action is not available for the gamepad action, and I don't know why

#

nevermind, it was related to my previous problem with {GLOBAL} which i remove it, but the name of the action was the same, so Unity didn't understand

vocal whale
#

Hello I dont have a clear understanding with the input system just yet, im trying to recreate flappy bird and i tried to make the jump input tap only, yet when i hold the button my character still keeps jumping am i missing something in my code or something in the input system menu?

austere grotto
#

It could be either, or both

vocal whale
#

sorry about that here it is

fierce compass
# vocal whale sorry about that here it is

IsPressed() is a boolean representing if it's currently pressed, like Input.GetKey()

you'd want to detect the rising edge, the first frame it was pressed, that'd be wasPressedThisFrame()

vocal whale
fierce compass
#

yeah it'd be like GetKeyDown

quick dagger
#

Weird issue so I have this script thats supposed to take a screen position and send a ray out, telling the item that it has been selected. But for some resason after clicking once the ray REFUSES to change targets no matter what I do! Im over this issue and realllyyyyyyyyyy need help if anyone has advice :)))

#

You can see it stops updating the position consistently it just like....stops

glass yacht
#

also, your code is using events in a way that is really hard to reason about. It might be better if you changed state using your events but then just ran an Update loop so you could simply see what state you're in

patent socket
#

trying to write a test to ensure all of our actions have at least 1 event listener, any ideas how I can do that?

.performed only has a add and remove, I can't get the list of listeners from the unity input system unfortunately to Assert the count

fierce compass
patent socket
#
{
            var eventField = typeof(InputAction).GetField("m_OnPerformed",
                BindingFlags.NonPublic | BindingFlags.Instance);

            var callbackArray = eventField.GetValue(action);

            var callbacksField = callbackArray.GetType().GetField("m_Callbacks",
                BindingFlags.NonPublic | BindingFlags.Instance);

            var inlinedArray = callbacksField.GetValue(callbackArray);
            var inlinedType = inlinedArray.GetType();

            var firstValue = (Delegate)inlinedType.GetField("firstValue",
                BindingFlags.Public | BindingFlags.Instance).GetValue(inlinedArray);

            var additionalValues = (Array)inlinedType.GetField("additionalValues",
                BindingFlags.Public | BindingFlags.Instance).GetValue(inlinedArray);

            var count = 0;
            if (firstValue != null) count++;
            if (additionalValues != null) count += additionalValues.Length;

            return count;
}```

Had to do a lot of fucky reflection to get it work in the end.
brittle jewel
#

Hello.

#

I need a help check.

#

My code is not functioning my 3D model, input, I reconfigured it, several times.

fierce compass
brittle jewel
#

It was working, then it broke.

fierce compass
#

ww're gonna need some more info than that

#

!ask

cobalt mossBOT
# fierce compass !ask

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.

-# For more posting guidelines, go to #🌱┃start-here

native crater
#

I need an answer from whoever wrote this line of code

#

w h y

#

all selectables are highlighted OnPointerEnter(when you hover on them) but DropdownItems are getting selected instead

#

when I realized that's the issue i was so mad

river briar
#

What is generally the better paradigm, using the global input action map, or creating a unique input action map for each script which only includes the specific keys for that script, I.E. wasd is in its own input map that is used by the player controller.

verbal remnant