#🖱️┃input-system

1 messages · Page 16 of 1

opaque jewel
austere grotto
#

Yes just do _controls.asset to get the instance

livid sky
#

How can I set a action that only performs when the middle button is pressed?

#

I want to rotate the camera only when the middle button is pressed.

sharp ingot
#

do mouseDown and mouseUp events also work for controllers?

opaque jewel
#

The binding is targeting an action on a specific asset, no?

#

action.actionReference.asset is get only so I'm trying to figure out how to retarget the action reference to the instance without losing which action it's referencing

opaque jewel
#

Can't seem to convert from InputAction to InputActionReference

#

Not really sure how to fix this

#

Struggling to figure out how to dynamically retarget the correct action on the new instance at runtime

#

And then apply the override

azure compass
#

What should I use to make customizable inputs?

eager burrow
azure compass
#

Yup

#

Cause both old and new system don't seem to have function to rebind inputs

eager burrow
#

There's even a sample that includes prebuilt UI elements

azure compass
#

Oh, do you have any link to the sample? 🤔

eager burrow
azure compass
#

Okay thank you ☑️

eager burrow
crimson crater
#

Is there a difference between ApplyBindingOverride() and ChangeBinding() or ChangeCompositeBinding()

#

They seem to do the same thing in a different way

echo nymph
#

Hi, I seem to have an issue where visual studio isnt getting updated on new input actions I create. For example here i'm trying to use the "Look" action but vs doesn't know it exists. This isn't just for this action but for any new ones I create. I'm not sure what to do, any help would be appreciated

#

what confuses me is that visual studio knows the MovementInput exists but not the Look or any new actions

tulip tartan
tulip tartan
#

Does Jump work? Because that one IS there (as well as MovementInput of course)

#

Save is greyed out in your image though... weird

#

Try commenting out the lines where the errors are, and seeing if you can save the asset with no compile errors

echo nymph
tulip tartan
#

Here are the actions that exist:

""name"": ""Movement"",
  ""id"": ""49ba4047-1202-4255-85ed-d56e98c6e12a"",
  ""actions"": [
      {
          ""name"": ""MovementInput"",
          ""type"": ""Value"",
          ""id"": ""02213972-6abb-43ab-afd5-788b5140c351"",
          ""expectedControlType"": ""Vector2"",
          ""processors"": """",
          ""interactions"": """",
          ""initialStateCheck"": true
      },
      {
          ""name"": ""Jump"",
          ""type"": ""Button"",
          ""id"": ""e11d9f25-581f-4e2e-8af1-f7d28967b7b7"",
          ""expectedControlType"": ""Button"",
          ""processors"": """",
          ""interactions"": """",
          ""initialStateCheck"": false
      }
  ],
echo nymph
#

i see, so should i go about creating the action in the generated class

#

i honestly tho have no idea how I'd do that

#

its weird tho cause Jump saved into the script but Look isnt

#

i did the same thing for saving it into the asset both times

tulip tartan
tulip tartan
echo nymph
#

its ok, thank you for at least giving it a shot

#

do you think it could be my editor version?

tulip tartan
echo nymph
#

Unity 2021.3.7f1

#

web gl build integrated think

tulip tartan
echo nymph
#

the classes were nearly identical in names so i didnt even notice

tulip tartan
echo nymph
#

Thank you though, i probably wouldn't of found the issue if you didnt lead me to the script.

#

saved me hours lol]

valid dagger
#

Whenever I press a button it starts and gets canceled right away and I don't know why. Any ideas?

turbid cave
#

I'm trying to setup point and click movement I was following this tutorial https://youtu.be/b0AQg5ZTpac?si=JCFTYY3RY3Hc0t_V But I'm getting errors on the Awake(), OnEnable(), OnDisable(), Start(), MouseClick() Methods any help would be appreciated.

Isometric Mouse Movement in Unity Tutorial using the NEW input system.

📥 Get the Source Code 📥
https://www.patreon.com/posts/isometric-mouse-38744509

🔗 Relevant Video Links 🔗
ᐅMaking an Isometric Tilemap with Elevations and Colliders in UNITY
https://youtu.be/_TY0F7Zm6Lc

🤝 Support Me 🤝
Patreon: https://www.patreon.com/samyg
Donate: https://ko...

▶ Play video
valid dagger
#

I think it's too early for everyone.

austere grotto
austere grotto
valid dagger
austere grotto
valid dagger
#

Good to know. I'll change it later

austere grotto
#

!code

sonic sageBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

austere grotto
#

Share the full script and the full error messages

valid dagger
austere grotto
valid dagger
#
    {
        
        //public int PlayerId;
        public static InputActionMap InputActionMaps = new InputActionMap("PlayerControls");
        public static Vector2 moveInput;
        public static InputAction IA = GameObject.Find("Input").GetComponent<PlayerInput>().actions.FindAction("WSAD");

        public static void Enable()
        {
            IA.Enable();
            IA.performed += OnMovePerformed;
            IA.performed += OnMoveCanceled;
            Debug.Log("Enable");
        }

        public static void Disable()
        {
            IA.Disable();
            IA.performed -= OnMovePerformed;
            IA.performed -= OnMoveCanceled;
            Debug.Log("Disable");
        }

        private static void OnMovePerformed(InputAction.CallbackContext context)
        {
            Debug.Log("OnMovePerformed: " + context);
            Vector2 Data = context.ReadValue<Vector2>();
            Object.PlayersMainObject[0].NewPosition = Object.PlayersMainObject[0].NewPosition;
        }

        private static void OnMoveCanceled(InputAction.CallbackContext context)
        {
            Debug.Log("OnMoveCanceled");
        }



    }
#

It does detect when I press the button down but gets cancelled right away

#

I just did a test and it's getting canceled at the exact same time as when it starts.

austere grotto
#
            IA.performed += OnMovePerformed;
            IA.performed += OnMoveCanceled;```
#

of course it is

#

you've simply subscribed both of those functions to the "performed" event

#

so no, it's not getting canceled

#

your OnMoveCanceled is certainly running though

valid dagger
#

hmm

austere grotto
#

there's an IA.canceled event

valid dagger
#

I think I understand. Just not sure how to correct it.

#

ah!

#

I'll try that thanks

austere grotto
#

if you want to know when the interaction is canceled, subscribe to that

valid dagger
#

That fixed it. Is there a event for held?

#

Now I just need to figure out how to do a held/hold thing and who to get the Vector2 from press W and A at the same time.

bold imp
#

Hey guys !
I need some help setting up Input Actions for my menu, so it can be used with a controller.
my main menu and option screens are normal menus, with buttons that you highlight with your controller, and confirm using the A button.
My level-selection menu is different : there is a column with a list of levels, and a "select level" button. When using the mouse, you click on the button/name of a level, the screen shows the description of the level, and you can click the "select level" button to confirm.
When using a controller, you use up/down on the joystick to see the description of the level (as if you already clicked on the level button), and use the A button of the controller to confirm your selection (as if you had clicked on the "select level" button.
I currently use the Input Package and set up some bindings and functions so that it can work pretty much correctly, using a MenuNavUp, MenuNavvDown and MenuNavOk funtions in my script that select and confirm things.
My problem is that when you begin on the main menu, and press the A button of your controller to start the game (and get on the level-selection screen), the A button press is registered as if it happened on the level selection screen, and it behaves as if you selected the first level (which is selected by default).
I even used :

menuOkAction.started += _ => MenuOk();
to make sure only the beginning of the button press triggers the menu function, but a single button press still counts for both my Main menu and my level-selection screen.
Can anybody help me solve this problem ?

tulip tartan
west adder
bold imp
#

I added Debug.Logs on the function called by the "Start Game" button (on the main menu), and another on the MenuOk function.
The button is clicked and its function called before the MenuOk is called, which lets the function initializing the level selection fully run, turning the boolean telling that we're on the level-selection screen to true.

#

I have tried disabling/enabling the listener only in the correct screens, but since the function enabling it on the level-selection screen is called before the listener for button started is triggered, it does not help.

west adder
bold imp
#

didn't find that.
I made it work in an ugly way : I put a timer before Enabling the action on the level-selection screen, so the action can not be triggered during the first 0.1s :/

willow kestrel
#

Hello there, I struggle to understand how works the new Input System, I want to make a 2D plateformer, so to make a variable jumps I use the Input.GetButtonUp/Down . I tried to see if there is an equivalent and I dont get how to use the performed, started and cancelled state

    public void Jump()
    {
            if (m_Grounded && Input.GetButtonDown("Jump"))
        {
            // Add a vertical force to the player.
            isJumping = true;
            jumpTimeCounter = jumpTime;
            rb.velocity = Vector2.up * m_JumpForce;
        }

        if (Input.GetButton("Jump") && isJumping == true)
        {
            if(jumpTimeCounter > 0)
            {
                rb.velocity = Vector2.up * m_JumpForce;
                jumpTimeCounter -= Time.deltaTime;
            } else {
                isJumping = false;
            }
        }
        // Avoid a double jump which complete the full hop
        if (Input.GetButtonUp("Jump"))
        {
            isJumping = false;

        }
        
    }
opaque jewel
#

Anyone who has used the RebindUI - what might cause the Binding to not appear?

#

There are two bindings for this action, but neither is selectable

#

The asset is targeted, but I get an error saying it's not set to an instance of an object

#

Why would it display the action but not the binding?

austere grotto
#

COuld it be control scheme related?

opaque jewel
#

I think so, but I'm not sure how to reconcile that

#

It does work when I switch Action Maps

#

But nothing in the input action asset is telling me this action map doesn't exist

austere grotto
opaque jewel
#

Cutting and pasting the same scheme has temporarily fixed this, but I worry it may re-emerge

echo nymph
#

does anyone have a clue as to what could be causing this issue, when i add the motor.Crouch and Sprint code, it gives me this error in my input manager, when I remove the 2 lines, it fixes it.

valid dagger
#

If I want to use inputs like the keyboard with WSAD and the mouse to look around do I use the same code somehow or do I have to make separate functions for each? For instance on private static void OnMoveStarted(InputAction.CallbackContext context) would I use both keyboard and mouse code in the same function or have to make separate functions for each?

round kestrel
valid dagger
#

That part I get but these are separate actions, like WSAD for movement and the mouse for looking around.

round kestrel
#

if you're wanting to say use the mouse to look then you would create a look action. Then you add a method for move and another OnLookStarted for the look action

valid dagger
#

So I can't combine them into one function(s)? They look their own functions to work?

round kestrel
#

I would probably do something like

OnMoveStarted() - read the values from wasd
OnLookStarted() - read the values from mouse movement

OnUpdate() / OnFixedUpdate() - I would update my actual look and move here based on the values I read in OnMoveStarted() and OnLookStarted()

valid dagger
#

hmm

#

ok, separate functions then

#

I was thinking of some IF statement to check what was being used and then code.

round kestrel
#

the methods OnMoveStarted() and OnLookStarted() are listeners for an action, the action is called "move" but the action that we are listening to is the movement of the left stick or the pressing of the WASD from the image above

valid dagger
#

I think you're right after looking at my code again

#

InputAction only maps to one set of actions.

round kestrel
valid dagger
#

I think I'm good now, thank you very much.

round kestrel
#

I was wondering if someone could help me, I've created a new project and added a player game object. I have added the new input system. I have tested in the editor and everything works as expected. When I build for windows the inputs do not work.

I have tried using the ActionsAsset with the PlayerInput component and I have also tried instantiating an ActionsAsset in the player controller class to manually enable the ActionsAsset and the ActionMap. Both have worked as expected in the Unity editor but have failed to work on build.

I have checked that the "Active Input Handling" value is set to both for the player in the project settings (tried Both and New).

craggy silo
#

does anybody know what determines the order of execution if two or more monobehaviours subscribed to the same input event? Fe. which of the two scripts will execute the event handler first, and why?

austere grotto
#

if anything it might depend on the order in which they subscribed, or if in a UnityEvent, then the order in which they appear in the inspector

craggy silo
austere grotto
fervent bone
#

Good afternoon, (i'm new here). Can someone please confirm if i'm seeing this right, I dont seem to have a Player Input component, which if i'm understanding, is because its been phased out in favour of... the input manager. But within the input manager I can't set Horizontal movement to my D pad as its considered the 6th & 7th axis, so for it to work I need to have, "joystick axis" selected as the type. But when this is selected, the A/D buttons no longer function. Am I missing something here

austere grotto
#

the input manager is the old system

#

PlayerInput is a component that is part of the new input system

fervent bone
#

ok sweet. But I dont have the component available

austere grotto
#

You wouldn't

#

unless you installed the new input system package

austere grotto
fervent bone
#

i've been unable to find it

austere grotto
#

if you want to ADD the joystick stuff, make a new axis

#

with the same name

#

and set it up to use what you want

#

by default there will already actually be two "Horizontal" axes in your input manager, one for a/d and one for the joystick

fervent bone
#

what i'd like to do is have WASD available for movement, interchangably with the d pad on my controller. Is this as simple as having two horizontal axes, one for a/d, the other for the d pad?

austere grotto
#

you can also go to the second horizontal axis that's aleady there by default and change it from whatever axis it's using now to the new one

#

if you don't want the default axis, which is usually the joystick

fervent bone
#

smashing, this seems to have done what i'm after. Where do I get the new PlayerInput component from, i've had a look at my package manager and whenever I type in player under packages from the unity registry, it only comes up with a multiplayer tools package

austere grotto
austere grotto
#

switching to the new input system means redoing all of the input handling from scratch in your project

#

I would only do it if you have a good reason

fervent bone
#

ok fair play. thanks for the heads up

fervent bone
#

i'm trying to set up an if function that checks if no buttons are being pressed, which the !Input.Anykey covers, but i'd also like to do an OR !input any horizontal axis. whats the correct way of wording this/checking it

austere grotto
#

= is used to assign things

opaque jewel
#

Do you know if overriding inputs on the new input system overrides them for multiple players, or is the InputActionAsset instanced?

austere grotto
#

The asset is instanced. Each PlayerInput has its own copy

opaque jewel
#

Finally figured out how to get the wrapper working with the rebindings

#

Had to retarget the inputactionreference by using a lookup on the action in the wrapper class and then creating the reference using InputActionReference.Create to retarget it, THEN rebind/override it

#

Couple extra steps and calls but finally got there. Took about 20 forum posts Sweat

tame oracle
#

hello, i got an issue: the same code, but depending on the keybinding, it's not working

#

when does this happen please ?

tame oracle
#

public void MoveUp(InputAction.CallbackContext myContext)
{
if (myContext.ReadValue<float>() > 0)
{
ButtonUp = true;
}

#

this doesn't work for the key "W" but works for the key "D"

#

Also doesn't work for the key "A" but works for the key "S"

austere grotto
#

and how you hooked up this code to it (e.g. in the inspector? By manually subscribing to an action?)

tame oracle
#

works for Move down but not Move up

austere grotto
#

I want to see how the action is configured (the right panel)

tame oracle
austere grotto
#

Ok and the code inside all these functions?
BTW this is pretty overcomplicated

#

you could have just done a single Vector2 action

#

with a composite binding

#
if (myContext.ReadValue<float>() > 0)
{
  ButtonUp = true;
}```
This code ^ is also a bit overcomplicated. It can/should just be:
```cs
ButtonUp = myContext.ReadValueAsButton();
// or
if (myContext.ReadValueAsButton()) {
  ButtonUp = true;
}```
tame oracle
#

i done many tries, it seems like it's working randomly (but rarely)

#

i'm gonna dig deeper to see

tame oracle
austere grotto
#

this will do that though:
ButtonUp = myContext.ReadValueAsButton();

#

anyway can you show the rest of the code?

tame oracle
austere grotto
tame oracle
#

it's literally just that :

#

replace "Down" with "Up" "Right" "Left"

austere grotto
tame oracle
#

right and down works, left and up do not

austere grotto
#

which explains the issue

#

which is why I wanted to see the code

#

As much as I'd like to take your word for it - it clearly has mistakes 🙏

tame oracle
#

yes i was just doing left i copy paster from down (which is working"

austere grotto
#

no need for the if statements etc

tame oracle
#

let me try

#

(even a print("test") don't works)

austere grotto
#

where did you put the print

austere grotto
tame oracle
#

it inded works but still only right and down works

austere grotto
#

show the current code and current configurations

#

without that, I really can't help you

tame oracle
#

i tryed with deferent keys Z instead of W and Q instead of A

#

a second, i'm screening

#

for Up

#

for right

#

right works and up doesn't

austere grotto
# tame oracle for Up

why do you have the action as "Pass Through"?
It should be set as Action Type - Button

#

and show the code for MoveUp

tame oracle
#

waiiiiiiiiiiiit

#

ok i get it.. it's unity USA key configuration that does that..

#

my bad

#

i will use the "listen" function to make it work... damn hell

#

not intuitive, is there a parameter to change somewhere to map the binding to my country ?

tame oracle
tame oracle
austere grotto
sly ledge
#

i dont think its the code because it works well on keyboard

#

and the jump

echo nymph
delicate nebula
# echo nymph is anyone able to help with this. thank you.

saw your message from the general channel

For InputManager line 16, maybe use a breakpoint or add some logs to check if movementAction.Crouch is null? motor shouldn't be null if motor.Jump doesn't give the same error

For InputManager line 47, can check if any code there might cause m_Wrapper or m_Wrapper.m_Movement to become null when PlayerInputs calls Get()

echo nymph
#

for some reason now none of my movementActions seem to be working

#

moto.Jump() is now null strangely, I'm not sure how but I hadn't altered any of the code

delicate nebula
#

ahh i missed seeing it earlier, but could you move
motor = GetComponent<PlayerMotor>();
to the start of Awake? need to initialize it before you start using it

tough imp
#

How do I use IXboxOneRumble with Xinput

#

The documentation isn’t very helpful

tame oracle
#

So i've trying to make a cube to change colour when ever interact with it using the change cube color code in the minute 21:25 of this video https://youtu.be/gPPGnpV1Y1c?si=pqwMiFlRkQ0oSGce but he said it needs some setting up to make it work properly but i tried alot of ways to set it up but all of them didn't work

The second video in the Lets Make a First Person Game series!
🖐In this video we are going to setup the foundations for our interaction system.

Come Join us on the Discord!
🎮 https://discord.gg/xgKpxhEyzZ

💚 Thanks for watching!

Helpful Links
https://dotnettutorials.net/lesson/template-method-design-pattern/

▶ Play video
lucid kelp
#

https://hastebin.skyra.pw/ajutokafek.csharp I currently have this, I have it so that whenever I rotate I disable the animator, I have an idle animation that prevent any rotation of the hips and such and I was hoping if there was a better solution. Currently when I rotate it freezes the animator and all animations to rotate the hip.

tulip tartan
lucid kelp
#

The freezing part yeah. But on entry it puts it to idle. I think it's the idle that's preventing me from rotating the hip

#

The freezing is just a right now fix

#

Assuming i dont freeze the animator. I can move forward and backward but the idle animation prevents me from rotating the hips

tulip tartan
#

"Rotating the hips"
Do you mean rotating along the y axis? What does that mean?

lucid kelp
#

Well without the animator the code rotates it fine left and right along the x-axis

#

I tried y-axis but it's a 3d model in a 2d setting

#

Here let me get a snip

tulip tartan
#

So, to be clear: the issue is animation? You may want to ask in #🏃┃animation then, as this channel is specifically for help with the new input system (which you DO seem to be using)

But if you remove these lines:

if(rb.velocity != UnityEngine.Vector2.zero){
  animator.SetBool("IsMoving", true);
}else{
  animator.SetBool("IsMoving", false);
}

Do you still have the problem?

lucid kelp
#

I'll try asking there yeah I am using "Input Actions"

#

Well if I remove those lines it lets the animator continue

#

But the idle animation keeps looping which for some reason prevents any rotation of the hip on the model

#

I had success when I changed the transform to the entire model but not the hip.

#

When I do try and rotate the hips while the idle animation is running it jitters super fast I'm assuming the rotation can't happen at all and just resets the hips to its original position because of the idle animation playing in a loop.

#

Freezing the animator was just a temporary fix

tulip tartan
#

Are you rotating while having velocity? Rotation isn't velocity, so if you aren't also moving, you are setting IsMoving to false, which I guess puts you in Idle?
I'm not great with animations, so I'm not sure. Sorry

lucid kelp
#

Uh isMoving is a not a part of the animator it's solely in the script to turn off the animator.

#

Yeah rotation isn't velocity. I don't know how to check the rotate() command from input actions script

#

The moving back and forth works because it's velocity and the running animation doesn't happen all the time

#

I have a paste bin pasted, on line 55, if I can check that I can add a condition in the animator to check but I don't know what value to check unlike on line 85

tulip tartan
lucid kelp
#

Oh wait

#

Ah that sorry

#

If I'm not in running animation it returns to false which puts me in idle correct

#

It's the idle animation that prevents rotation

#

Actually while running the animation for running also prevents me from rotating the hips too

#

:/

#

It's the function at line 55 that comes from the input action script that keeps clashing with the animator

#

Honestly I might just change that part altogether

graceful hemlock
#

I'm using the InputSystemUIInputModule, and I would like to interact with UI buttons even though my cursor is locked.

The StandardInputModule could be overridden like this:

using UnityEngine.EventSystems;

public class CustomInputModule : StandaloneInputModule {
    protected override MouseState GetMousePointerEventData(int id) {
        if (Cursor.lockState == CursorLockMode.Locked) {
            try {
                Cursor.lockState = CursorLockMode.Confined;
                return base.GetMousePointerEventData(id);
            } finally {
                Cursor.lockState = CursorLockMode.Locked;
            }
        }

        return base.GetMousePointerEventData(id);
    }
}```

How can I override the InputSystemUIInputModule.
#

Ah, got it, you no longer have to override anything:

sleek vale
#

Everyone, I have a question while using UI Toolkit. In UGUI, I could implement a virtual joystick using the Input System's On-Screen Stick. But now, if I'm using UI Toolkit, how can I achieve this?

hasty geyser
#

how to change actions maps by code?

austere grotto
hasty geyser
#

this is the default but in the script i want to get this player input with the default map "PunchBagTrain" to another action map but by using code

austere grotto
hasty geyser
#

yes

#

but with code not manually

surreal roost
austere grotto
#

Though it might help if you explain what "doesn't work" means

surreal roost
#

The event doesn't fire.

austere grotto
surreal roost
#

Thanks, it has fixed it.

pulsar basin
#

if i need to get vector2 from wasd each fixed update, can i do it without generating c# script from controls?
if i use PlayerInput component with UnityEvents it only trigger once
NVM - you can go without getting the v2 each time, get it when it sends it and apply it constantly, when you release buttons it sends zero vector2

tulip tartan
#

What does the parent object's inspector look like?

wraith rapids
#

Hello everyone,

I've a first scene for the players choose a color and a second scene for the players fight.
In the first Scene I use the following line of script for when a player validate the color he choosed, the following line in "SetPlayerController" function add the controller device in a _playerController dictionary :
_playerController.Add(index, controller.devices[0]);

In the second scene I use the following line to reconnect the player input with the good character :
player1 = PlayerInput.Instantiate(_playerPrefab, player.Key, playerControlScheme, -1, playerController);

But the first line is causing my issue :
if a player joins the game using the keyboard in the first scene, he can move with the keyboard and look in the direction where the mouse is pointing because in his "Player input" Component, there is on the line "devices ": Devices = Keyboard;Mouse. Then in second scene, the same player can reuse this same keyboard to play in the second scene BUT no longer with the mouse because we only gave him the controller.devices[0] and not the controller.devices[1]. And in the second scene on the "device" line there is actually only the keyboard "Devices = Keyboard" If the player, in the first scene, joins the game using the mouse, the devices line becomes Devices = Mouse;Keyboard. So in the first scene nothing changes (the player can use the keyboard and mouse). But in the second scene, this player only has Mouse in the Devices row so he can no longer move, only look at where the mouse is pointing.
I've tried :
player1 = PlayerInput.Instantiate(_playerPrefab, player.Key, playerControlScheme, -1, Keyboard.current, Mouse.current);
or
player1.SwitchCurrentControlScheme("Keyboard&Mouse", Keyboard.current, Mouse.current);

but didn't work.

In Unity Editor my control scheme has "Keyboard" and "Mouse" selected

Can Someone help me to add the Mouse.current in the devices attribute of the player if controlScheme is "Keyboard&Mouse" ?

#

The dictionnary variable is :
public static Dictionary<int, InputDevice> _playerController = new Dictionary<int,InputDevice>();

So I've tried
public static Dictionary<int, List<InputDevice>> _playerController = new Dictionary<int,List<InputDevice>>();
But it didn't solved my issue, two player are spawning one with the keyboard control and the second one with the mouse but not a single player with the two controller :/

lofty stratus
#

anyone using the advanced multiplayer template I am having trouble with the new input system.

fossil spindle
# lofty stratus anyone using the advanced multiplayer template I am having trouble with the new ...

I don't use that template but this is my best explanation of how to use the input system
https://forum.unity.com/threads/wait-theres-seriously-not-a-held-button-interaction-in-the-new-input-system.1417059/#post-9367661

fervent nymph
#

Hey I am trying to get some basics down for player controls. I am trying to get the player to be able to move foward and backwards, while also rotating witht he camera (in first person) also moving with the player

#

However I am having some trouble as the player doesnt move on inputs or rotate, and as soon as I set speed it flys off the platform

echo nymph
cloud walrus
#

Hey Guys, I'm using an Actions Asset and a PlayerInput component with Player Input Manager Workflow, When I press the button the player respawns in the position of the prefab, how could I add a specific position for each player that will join, and a waiting screen to ask them to press any button before joining?

wicked temple
#

Is this thread for the New input system, questions etc. or is it generalized

tulip tartan
wicked temple
#

@tulip tartan thats good, ty

uncut wharf
#

photon fusion host mode and new input system

player default maxSpeed is 2 and if isRunPressed(from input action new input system) is true, player maxSpeed is 9. after that, isRunPressed is false, again player maxSpeed is 2. when I use this method is not stable working. if you can look first image.

when i disable isRunSpeed and i set player default maxSpeed is a 9. this is stable. player's velocity always 9. -- i use photonfusion's NetworkCharacterControllerPrototype.--

there is my character input handler script
`void CharacterInput()
{
moveInputVector.x = characterInputActions.Controller.Movement.ReadValue<Vector2>().x;
moveInputVector.y = characterInputActions.Controller.Movement.ReadValue<Vector2>().y;

_isRunPressed = characterInputActions.Controller.Run.IsPressed();
}
public NetworkInputData GetNetworkInput()
{
NetworkInputData networkInputData = new NetworkInputData();

 // Move data
 networkInputData.movementInput = moveInputVector;
 // Run data
 networkInputData.isRunPressed = _isRunPressed;

 // Reset variable
 _isRunPressed = false;
 return networkInputData;

}`

austere grotto
#

BTW instead of all this:

moveInputVector.x = characterInputActions.Controller.Movement.ReadValue<Vector2>().x;
moveInputVector.y = characterInputActions.Controller.Movement.ReadValue<Vector2>().y;```
 You can just do:
 ```cs
moveInputVector = characterInputActions.Controller.Movement.ReadValue<Vector2>();```
uncut wharf
#

`public virtual void Move(Vector3 direction) {
var deltaTime = Runner.DeltaTime;
var previousPos = transform.position;
var moveVelocity = Velocity;

direction = direction.normalized;

if (IsGrounded && moveVelocity.y < 0) {
  moveVelocity.y = 0f;
}

moveVelocity.y += gravity * Runner.DeltaTime;

var horizontalVel = default(Vector3);
horizontalVel.x = moveVelocity.x;
horizontalVel.z = moveVelocity.z;

if (direction == default) {
  horizontalVel = Vector3.Lerp(horizontalVel, default, braking * deltaTime);
} else {
  horizontalVel      = Vector3.ClampMagnitude(horizontalVel + direction * acceleration * deltaTime, maxSpeed);
}

moveVelocity.x = horizontalVel.x;
moveVelocity.z = horizontalVel.z;

Controller.Move(moveVelocity * deltaTime);

Velocity   = (transform.position - previousPos) * Runner.Simulation.Config.TickRate;
IsGrounded = Controller.isGrounded;

Debug.Log(horizontalVel);

}`

austere grotto
uncut wharf
twin quail
#

Is there a way to check the context on a Perform callback about whether the input was sent by a Pointer-type binding (aka path is <Pointer>/*)? The context always resolves to Mouse or Touchscreen, which is fine, but I wanted to know if it would ever resolve to Pointer in some fashion.

austere grotto
#

assuming ctx is an InputAction.CallbackContext

twin quail
#

Ah, ty

#

tbh, didn't think of that

#

was going for a string route

scenic knot
#

Somebody know how to read GetKeyDown in new Unity Input System without any events, via code?

austere grotto
twin quail
austere grotto
austere grotto
#

print out what type the control was

twin quail
#

fair enough

scenic knot
austere grotto
#

for using input actions it's a bit different, and depends how you're hooking the input actions up in your code

#

one option is an input action reference, Another option is through the generated C# wrapper class

#

in any of those cases you can get an InputAction reference.

#

Once you have that you can do this:

void Update() {
  bool wasPressedThisFrame = myInputAction.WasPressedThisFrame();
}```
scenic knot
austere grotto
#

the same way you just get the input action from your wrapper

#

e.g.

myWrapper.MyActionMap.MyAction```
scenic knot
#

OU thank u very much =D

scenic knot
#

ure my hero ...

river coyote
#

hi, i have been trying to sort out a problem for way to long and have no idea why nothing covers this online, but ive got ui navigation working for a menu but when i click play to disable the buttons and enable a NEW set of buttons with their own separate navigation. it doesnt detect any arrow keys or controller movement to start the navigation and even when i click back to the first menu (that had navigation working) it now just doesnt detect anything either. does anyone know a way to switch navigations?

edgy lantern
#

Using Unity 2022.3.9, InputSystem 1.7.0, on M1 mac, PS4 Controller connected via bluetooth. the following code does nothing except display the log:
Debug.Log("Vibe On"); Gamepad.current.SetMotorSpeeds(1f, 1f); (Gamepad.current as DualShock4GamepadHID).SetLightBarColor(Color.green);
What's wrong with my setup?

austere grotto
#

Are you getting any errors?

idle grotto
#

I have a very dumb but also very fundamental question about the new input system. This scene features a selection system that allows me to move/rotate/scale gameobjects. Right now the two handles (rotating/scaling) both listen to player inputs, as does the selection system as a whole. Now ofc all three listeners fire when I click, which means that I have to implement weird checks to make sure that not all three objects do what they should do when clicked. This is ugly and probably not how the system was intended.

So the question is: What is the proper architecture to make sure only the right listener responds to input events?

I considered implementing something like an IInputListener interface, that an Input Manager checks for with raycasting and then enables/disables the component that should listen to inputs. Do you have better architectures in mind?

idle grotto
#

(Small addition: using an IInputListener interface is really dumb too because then I can't easily reference my InputHandler that fires the events to register to)

lost valley
#

Hi, i need to detect if the last input was on a keyboard or a gamepad, i'm trying to use the "PlayerInput.onControlsChanged" event to detect if the currentControlScheme is either "Keyboard" or "Gamepad", however after i press any input on my gamepad it sends a duplicate and goes back to the keyboard scheme, does anyone know why?

scenic knot
#

Anyone know how to rebind this keys through script?

edgy lantern
# austere grotto Are you getting any errors?

None. I have a debug in Start that shows the DS4HID controller is connected, and I have a test button input that properly works. Also, when I use macOS’s Bluetooth Settings to “identify” the controller, it vibrates and the light bar changes color.

lost valley
#

damn each time i use this input system i find more bugs

#

PlayerInput.onControlsChanged is invoking the event with a Gamepad and Keyboard input at the same time

#

and now i get this random error while i changed nothing

stoic ermine
#

What advantage does using EnhancedTouch give instead of using the InputActionsMenu itself?

austere grotto
# stoic ermine What advantage does using EnhancedTouch give instead of using the InputActionsMe...

From https://docs.unity3d.com/Packages/com.unity.inputsystem@1.8/api/UnityEngine.InputSystem.EnhancedTouch.EnhancedTouchSupport.html:

Enhanced touch support provides automatic finger tracking and touch history recording. It is an API designed for polling, i.e. for querying touch state directly in methods such as MonoBehaviour.Update. Enhanced touch support cannot be used in combination with InputActions though both can be used side-by-side.

#

So i'd say "automatic finger tracking and touch history recording" are the main benefits

mellow stream
#

Hey guys!
Does someone have a good tutorial for 3D movement? I watched several and in most of them it is either too complicated or doesn't work like it should be 😄
The ones with the cinemachines should be the best ones I guess

austere grotto
#

"3D movement" is extremely vague. There are many ways something can move in 3D

naive wedge
#

Hi guys,i am using unity 2023.2 and i am noticing that with my mouse if i click over the buttons there is no action

#

Is there a way to fix this problem?

austere grotto
#

make sure there are no other ui elements or other objects blocking the buttons

#

make sure there's no errors in console

upper ledge
#

hello i am having issues with UI buttons not detecting mouse over or clicking, can anyone help. I can share screen if its easier

austere grotto
#

I was pointing you to the messages right above you

#

you need to follow those same steps

naive wedge
edgy snow
#

Hey all, so I've inherited a project and I'm struggling to make changes to the input system. There are multiple schemes (this is a VR project), i.e. input action asset(s), the inputs then trigger Unity Events under Player Input > Behavior "Invoke Unity Events". So far so good, however, I can't work out how to change the events under the Player Input's "Events" area that actually stays associated to the relevant Input Action Asset. Whenever I toggle to another input action asset then back, the event I'd just added would be unsaved when I toggle back. Any tips or point to material would be appreciated, thank you!

austere grotto
edgy snow
#
  1. They're custom input action assets, they live within a folder in assets > project > data > input > actions. One input is for when using the Quest controller normally, another is for when the controller is in an unusual orientation while mounted to a physical hardware peripheral.
  2. Yes I made sure they are saved and the effect can be seen under PlayerInput as the new actions are now visible under the "Events" section.
austere grotto
edgy snow
#

They do in the form of the prefab having been changed in git. (as the playerinput resides inside a prefab), though the issue araises when I change the input asset in code (or in editor), the newly added action in the input action asset no longer has the event, it'd almost make sense if all the events are wiped if you're not suppose to be able to hotswap them like this, however, all the ones I inherited retain their events during the swap, but not the new event on the new action I'd just added to these two schemes. 😦 Sorry this is kinda confusing, I'll come back another time wth a video. Though looking at this further I suspect refactoring this entire thing may be my best course forward.

austere grotto
#

Are you using editor scripts to change the asset or something?

#

Or changing it at runtime?

inland quail
#

Hey! I have a script that manages player input that I then pass to other scripts. The Player Input action sits on the GameManagers as well as the script that reads all input. Issue I am having is, the Keybaord works fine but the controller stopped working once I moved the scrip and the Player Input component to a New GameObject

#

Everything looks fine and as mentioned, they keyboard works fine

#

I just lost Gamepad support

inland quail
#

Update:
Found the issue. This happenes if you have more than one player Input component in the scene. I wrote a script to print the names of the GameObjects that hold the component. Deleted the second and problem solved

supple crow
#

Each Player Input component represents an entire player

#

So if you have two of them, you will get weird behavior

inland quail
#

I have 2 action maps.
Player and UI. When I hold down the inventory button to display the inventory UI I want to switch to the UI action map so that I can navigate through the UI. Issue I am having is, won't the switching from Player Action map to UI WHILE holding down the Inventory button disable the action ?

#

So Hold InventoryShow Button in Player action map
switch to UI action map to navigate though inventory
Switching disables Player action map and the isPressed of the inventoryShow

next crescent
#

I have a fighting game I am creating where I am trying to give players the option to have tap jump on or off (being able to press up arrow to jump). I'm trying to use control schemes but it doesn't appear to work. I have one called Tap Jump and one called No Tap Jump, where Tap Jump has 2 additional keys for jumping. In practice, no matter which control scheme, the characters always have tap jump. How would I fix this?

supple crow
#

How are you setting the control scheme?

supple crow
#

Sounds like the "show inventory" action belongs in a different map.

#

Player Input will only let you have one active map at a time if you tell it to auto-switch, but there's no reason you can't just enable several at once

#

So you'd have "Gameplay", "UI", and "Meta", maybe

#

"meta" would include things like opening the main menu

next crescent
#

and I can confirm that it's still on No Tap from pausing the game and seeing it as such

wicked temple
#

Is there a good tutorial thats somewhat upto date that can teach me Input system for fps and character controller? i cant seem to find one and its been a week now

austere grotto
wicked temple
#

@austere grotto i mean in a general aspect not just the camera

austere grotto
#

Yes there are general tutorials for the input system including the ones pinned to this channel

wicked temple
#

@austere grottoty

bold imp
#

Hello everyone !
I have a question about handling input, and it may be more of a design question than a coding question :
In my game, the player can use a controller instead of mouse/keyboard to play. when they do (and I test it using a Xbox controller), they use the joystick to move, and the A/B buttons to cast spells.
the joystick and spell buttons are also used in the menus, including the pause menu and the level-up menu.
Initially, I made it so that, in game, pressing the A button would cast the first spell once, and that you would spam the button to spam the spell. It felt weird for a few spells that are meant to be spammed a few times per seconds when needed, so I changed it so that the first spell is spammed (cooldown permitting) as long as the A button is pressed.
The problem is that the A button also is the "validate" button for the level up menu, which can cause this situation :
The character levels-up. the player chooses a new spell and validates their choice by pressing the A button.
The level-up menu disappear, and the A-button is still pressed for a fraction of a second, but it's enough for the game to see it pressed, so the character casts their spell.
Do you guys know what to do to avoid that ?
If I don't find any other solution, I think I'll simply go back to "press once to cast once, holding down the button does nothing special".

ornate saffron
next crescent
austere grotto
#

Control schemes are for recognizing a player as different sets of input devices

#

Realistically you just want an if statement

languid bobcat
#

Unity's Input system allows players to input their actions, such as pressing keys or moving the mouse. Enabling the "Use Physical Keys" option in the Input Manager settings maps the KeyCode to the actual physical keys on the keyboard, while not enabling it will map to different keys based on the layout and platform. Starting from version 2022.1, the "Use Physical Keys" option is enabled by default.

To read input from a controller or joystick, use the Input.GetAxis function, which reads the axes set up in the Conventional Game Input. The default axes are "Horizontal" and "Vertical", which are mapped to the joystick, A, W, S, D keys, and arrow keys. Other axes are "Mouse X" and "Mouse Y", and "Fire1", "Fire2", and "Fire3", which are usually mapped to Ctrl, Alt, Cmd keys and three mouse or joystick buttons.

For movement behavior, use Input.GetAxis, which provides smoothed and configurable input that can be mapped to a keyboard, joystick, or mouse. For actions like shooting or jumping, use Input.GetButton.

Input flags are not reset until the Update function is called, so input calls should be made in the Update loop of the script. The KeyCode list provides options for keyboard keys, mouse buttons, and joystick buttons.

Overall, Unity's Input system allows players to input their actions, using functions like Input.GetAxis and Input.GetButton.

austere grotto
#

Was the chatgpt nonsense necessary?

naive wedge
#

Hi guys,as you can see with my VR i can not use the sliders in a scene but in the others it works properly,do you have an idea why?

austere grotto
naive wedge
#

How can i know what it is?

austere grotto
#

check each one

languid bobcat
tulip tartan
austere grotto
zinc stump
sonic sageBOT
#

dynoSuccess ezoidrake52 was muted.

fallow spade
#

sorry if this has been asked a lot but I'm trying to make a key config system for my game, but im not sure how to read what key was pressed after checking if any key was pressed

fallow spade
#

the issue is im not using input actions, ive made my own scripts to handle inputs

#

but i cant find a way to use input system to get the last key that was hit

austere grotto
#

I recommend working with the framework instead of against it

#

You could listen to the keyboard I guess but that won't cover other devices

hasty geyser
#

how to know if a key is held down through the context parameter?

austere grotto
hasty geyser
#

Is being pressed

austere grotto
#

Like it has been held down for some time before now? Or you want to run some code every frame while it's held

austere grotto
#

You will need to use Update or a coroutine for that

hasty geyser
#

Oh so theres no method or whatever for the context

austere grotto
#

In Update you can call myAcion.IsPressed()

austere grotto
hasty geyser
#

Hmm yea

remote hornet
#

Having both player input and input system ui input module on the same gameobject is causing things to break for me, is this a known issue

austere grotto
#

What purpose would that serve?

supple crow
#

I wouldn't expect it to break.

remote hornet
# austere grotto What purpose would that serve?

Both are on my camera, the inputsystenuiinputmodule is for world interactions, and the player input is for controlling the top down camera, I still find input system very confusing so this might be completely the wrong way to do it

supple crow
#

the UI Input Module is for UI input

#

Player Input represents a single player of your game.

#

Do you have multiple Player Input components?

austere grotto
#

The camera needs a physics raycaster

#

PlayerInput generally should go on your player character object

remote hornet
remote hornet
#

its that style of game

austere grotto
# remote hornet there isn't one its top down 2d, think mini-metro

The player character doesn't need to be a physical object in the game but you can and should have one central object that counts as "the player" I guess it could be on the camera but it's probably better to have a little more abstraction than that.

Anyway there's definitely no reason to have the input module on it

remote hornet
#

ok so physics raycaster 2d and input module are unrelated?

austere grotto
#

I wouldn't say they're unrelated, they're both related to the UI event system

#

But they don't belong on the same object

#

The input module goes on the event system object and in fact should be there automatically when you create an event system

#

The raycaster goes on the camera

remote hornet
#

why should the event system be a different object?

#

what should the event system component be on, is it its own gameobject or is it supposed to be a ui canvas or smth

austere grotto
remote hornet
#

What type of interaction should the scroll wheel use?

austere grotto
#

I'd check what they use in the default input actions asset

remote hornet
#

they don't add any interractions with it, but I think I've found a workaround

#

I have a new question though, on keyboard the camera is controlled by clicking and dragging, but on controller there is no need to click, as you can just use right stick, is there a way to express this to input system or do I need to implement it in code?

vernal iron
crimson schooner
#

I'm having an issue where input context is firing twice whenever a controller's bumpers a pressed. Any other button on the controller functions normally

#

The "Context.started" sections are triggered both when released and canceled

#

I think this probably has something to do with mapping the input actions to bumpers which probably get read as something that isn't a binary button input

#

But I'm not sure

#

Pressing both the L and R buttons once each results in this with the above code

near grotto
#

And if you stay pressed on the button, log appear 1 or 2 time ?

crimson schooner
ionic zephyr
#

Hello, i have an issue with the new input system, i posted about it on the unity forum but nobody answered could you guys take a look at it please ? :https://forum.unity.com/threads/generated-input-action-class-randomly-stopped-sending-callbacks.1506035/#post-9408860

austere grotto
#

Also how are you hooking this code up to the input asset? I don't see the listeners being added anywhere

near grotto
ionic zephyr
ionic zephyr
ionic zephyr
near grotto
#

you use a InputReader Instance, Instance is no't destroyed ?

#

and you speak about input working when the game start, do you do a action just after this who brock the input system or he brock alone ?

ionic zephyr
ionic zephyr
near grotto
#

normaly you use a "PlayerActionAsset()" who stock every binding, did you have or your script something like "playerActionAsset = new PlayerActionAsset();" and if yes, in your PlayerActionAsset did you have all your binding ?

#

if all of this is yes, try to use breakpoint on your visual studio and check step by step

ionic zephyr
#

well i have this :
public static InputReader Instance { get; private set; }
private InputAsset inputAsset;

public void EnableInput()
{
    if (inputAsset == null)
    {
        inputAsset = new InputAsset();
        SetGameplay();
    }
}
#

and the InputAsset is autogenerated from unity

#

with this :

near grotto
#

ok if you make a breakpoint at inputAsset = new InputAsset(); link visual to unity and launch it, did you trigger the breakpoint ?

ionic zephyr
#

well i can just write a debug no ? yeah it triggers, and Debug.Log(inputAsset) does not print Null, so that means an instance is made

near grotto
#

breakpoint if good for make a step by step debug*, you can follow the solution execution and see all data, if you want to debug is more useful, but if you want to do a Debug.Log you can

#

so now your inputAsset.Gameplay.Enable(); is now functionnal, but did action on the Gameplay input as link to method ?

ionic zephyr
#

yes the breakpoint is triggered

ionic zephyr
ionic zephyr
near grotto
#

did you have something like : inputAsset.Gameplay.MyActionInMyInputSystem.started += MyMethod;

#

cause curently i see your inputAsset.Gameplay but i don't see your action linked to method

#

like my screen, Player is your Gameplay but Player have action on it, your gameplay have normaly action to, this action need to be linked to method in your script with something like: inputAsset.Gameplay.MyActionInMyInputSystem.started += MyMethod;

ionic zephyr
#

its all done automatically in the input asset generated script :

#

i'm just inheriting from the interface of this script

austere grotto
ionic zephyr
#

this is the generated interface for "Gameplay" :

austere grotto
near grotto
ionic zephyr
ionic zephyr
austere grotto
#

YOu missed part of the video

#

that's from your video 😉

ionic zephyr
#

@austere grotto i'm sorry to ping you but i have another problem related to input now. When i start the game everything works fine every input is tracked except for the mouse actions, and in the input profiler there is only very few frames being captured and then nothing happens any more

#

this is the only events i got

#

compared to the ones when i press the keys on the keyboard :

#

i already restarted the editor, maybe i should restart computer aswell

tame oracle
#

What's the easiest way to detect what button binding was pressed when the action gets triggered?

austere grotto
#

Are you trying to make a Vector2/2D composite here?

#

Because this isn't how you do it

tame oracle
# austere grotto For what purpose?

Just trying to move a rigid body using WASD. Wanna trigger a event if W is pressed, a event if A is pressed, etc. So I'm trying to determine what button was pressed given my current setup or if there is a better way to do it.

tulip tartan
#

What event would be triggered, like the input event? And simply for movement?

You should just set up a composite here and have wasd inside that. Then you read the Vector2 and apply that to your movement

austere grotto
#

not whatever this is

tame oracle
austere grotto
#

the composite will be 1000% easier

#

it's what it was made for

#

even if you got this to work there's no way to make it work well with rebinding, no way to make it work with multiple keybinds, etc.

vocal garden
#

Hello, how to implement double tap/double click using input system? Do you need separate actions? Or separate interaction? I tried using separate action the single tap getting fired if i press double tap

uncut wharf
#

Hello,

I'm working on Photon Fusion host mode and host migration. Currently, I'm using the "new input system" in the project I'm working on, but it's not working as I want. When the host leaves the game, I can't read the inputs of the new host as a client. It works as I want when I switch from the "new input system" to the "old input system" by completely closing the game. How can I fix this?
i want to using new input system

austere grotto
#

but beware - if you want to not do a single click action when double clicking, this doesn't help you that much

#

in that case you'll want to code it yourself.

#

you basically want a small state machine:
after one click enter the "waiting for second click" state
in that state one of two things will happen:

  • another click comes and you can do the double click thing
  • enough time elapses and you do the single click thing.
#

In either case you go back to the default state

austere grotto
uncut wharf
austere grotto
#

you always should only be reading input from your local machine

uncut wharf
sleek vale
#

hello, everyone, How to trigger input system events after clicking a UI virtual button without using on-screen button or key simulation

austere grotto
#

My initial recommendation is: Use OnScreenButton

toxic junco
#

Hey folks, just wondering if anyone knows how to simulate keyboard presses with the new input system? I'm writing playmode tests and I've got a weird case where when I manually press keys a bug occurs but when i create tests that call the movement methods directly the bug doesn't occur.

supple crow
#

not sure about your original question, but,

#

how are you receiving input? if you're using something that takes UnityEngine.InputSystem.CallbackContext, are you checking that the context is in the right state?

#

e.g. that context.performed is true

#

just guessing wildly here that you're getting problems with multiple inputs

primal sonnet
#

Henlo, I've made a virtual mouse with the new input system but the events handler from interfaces like IDragHandler, IBeginDragHandler, IEndDragHandler, IPointerClickHandler seems don't work, anyone had the same issue?

vocal garden
austere grotto
primal sonnet
#

yup in the Input Debugger the inputs are recognized correctly but that events are never called

austere grotto
#

no i mean

#

the input module on the event system

#

that wouldn't be related to the input debugger

primal sonnet
#

that's my event system, it work with standard mouse input

austere grotto
#

how did you set up UI/Point and how is the virtual mouse configured?

#

Basically does UI/Point have the correct bindings/control scheme set up to recognize whatever the virtual mouse is set up as?

primal sonnet
#

that's the input map

#

and this is the code that update the position

private void UpdateMotion()
   {
        if (virtualMouse == null || Gamepad.current == null) return;

        Vector2 deltaValue = Gamepad.current.rightStick.ReadValue();
        deltaValue *= cursorSpeed * Time.deltaTime;


        Vector2 currentPosition = virtualMouse.position.ReadValue();
        Vector2 newPosition = currentPosition + deltaValue;

        newPosition.x = Mathf.Clamp(newPosition.x, padding, Screen.width - padding);
        newPosition.y = Mathf.Clamp(newPosition.y, padding, Screen.height - padding);

        InputState.Change(virtualMouse.position, newPosition);
        InputState.Change(virtualMouse.delta, deltaValue);

        bool aButtonPressed = Gamepad.current.aButton.IsPressed();
        if (previousMouseState != aButtonPressed)
        {
            virtualMouse.CopyState<MouseState>(out var mouseState);
            mouseState.WithButton(MouseButton.Right, aButtonPressed);
            InputState.Change(virtualMouse, mouseState);
            previousMouseState = aButtonPressed;
        }

        AnchorCursor(newPosition);
    }



private void AnchorCursor(Vector2 position)
    {
        Vector2 anchoredPosition;

        RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRectTransform, position, canvas.renderMode == RenderMode.ScreenSpaceOverlay ? null : mainCam, out anchoredPosition);

        cursorTransform.anchoredPosition = anchoredPosition;
    }
austere grotto
primal sonnet
#

is there too

austere grotto
#

I only see right click? mouseState.WithButton(MouseButton.Right, aButtonPressed);

primal sonnet
#

yup, that is what I need

#

actually in my OnPointerDown "listener" i check if is the button pressed is left or right

#

but that is never called

austere grotto
#

shouldn't mouseState track the position as well as the click stuff?

#

Basically I would expect InputState.Change(virtualMouse, mouseState); to cover everything

#

rather than having these separate calls:

InputState.Change(virtualMouse.position, newPosition);```
primal sonnet
#

this is there too just before the button if

#

in order to update the position even if i not press any button

austere grotto
#

yeah but when you press the button won't the state be overwritten to not have any position?

primal sonnet
#

it has the position is on "virtualMouse" variable

austere grotto
#

I would expect soething like this:

mouseState.position = newPosition;
mouseState.delta = deltaValue;

if (previousMouseState != aButtonPressed) {
  mouseState.WithButton(MouseButton.Right, aButtonPressed);
}

// change all the state together
InputState.Change(virtualMouse, mouseState);```
primal sonnet
#

i try that

austere grotto
#

that should cover any pointer device including the virtual mouse and a real mouse

primal sonnet
#

sadly nothing changed

#

found it, it seems that the virtual cursor image blocks raycasts of the EventSystem

austere grotto
#

ah yeah - disable it

#

the "raycast target"

primal sonnet
#

yup yup

#

thank you

sleek vale
delicate folio
#

hey I'm having a problem with my cinemachine virtual cameras, where when I switch between virtual cameras, the camera goes to the last aimed position. I am using Input Actions.

austere grotto
#

seems more an issue of your aiming code

delicate folio
#

I just thought it might be the input system my bad

spare epoch
#

Is there a bug with the arrow keys and spacebar inputs at the same time? My movement can use WASD and arrow keys; both work fine. Dash uses spacebar. Everything works, except specifically on the arrow keys if I press up and right at the same time spacebar inputs dont get registered.

austere grotto
#

Or a bug in your code

#

Look up "n-key-rollover"

#

There are online tests for the keyboard limitation

next crown
#

What's the easiest way to detect what's the last device used?

lean obsidian
#

Hi sorry I created the particles for the effect of the weapons that string of code I have to inseries to be able to give the input that every time I shoot it starts the effect

wintry hawk
#

Hey, does anyone know how to call a method that uses the parameters InputAction.Callbackcontext, so for example i have that parameter on my jump method, but I want to call that method without actually getting the input for it.

tulip tartan
wintry hawk
tulip tartan
#
public void Jump(CallbackContext ctx)
{
  // do stuff
}

public void Jump()
{
  //Do stuff
}
#

Just like unity methods that have different signatures (like Instantiate or Raycast)

wintry hawk
tulip tartan
#

LOTS of APIs use overloading, not even just Unity. It just gives you flexibility while having a slightly shorter autocomplete list and manual

wintry hawk
tulip tartan
#
public void Jump(CallbackContext ctx)
{
  //Set up stuff, modifying class data
  Jump();
}

public void Jump()
{
  //Do the jump from class data
}
#

So jump would go based off whatever the variable is set to, which could have a default. BUT, if you get a callback, you would modify those values. Or set a bool to read from separate values, or whatever you want

wintry hawk
#

This sounds pretty useful actually, so you can set multiple activation conditions, whether or not you get the callback or not? Is this how people usually make in game cinematics in timeline?

tulip tartan
wintry hawk
oblique moon
#

Hello guys, in about half the times I start my game in editor, the New Input System has an Action of Action Type : Value and Control Type: Vector2 that is simply not doing anything.
Basically I bind a function to its Performed and it's never called.
This is random and I can't figure out why and there is no debugging available I think.
Anyone experienced anything similar please?

blissful lotus
#

I haven't experimented much with it, but can you create a new asset and open both in parallel, then copy your actions over? Maybe remake the maps by hand if you can, then copy/paste the actions one map at a time.

#

Probably there is a loose GUID in the asset file that the editor isn't deleting, but it keeps a reference.

oblique moon
#

Interesting, we use the option to generate a C# class, maybe I could take a look at that generated file

#

What is strange to me is that it works half the time

blissful lotus
#

Knowing this, it might be possible to make a deep copy of the asset through the InputActions class in memory resulting in a whole new tree, but I'm just speculating. If you can find the GUID of the rogue Action, you could probably open the asset in notepad and search for it.

oblique moon
#

I think I have the ID in question yes

#

We're talking about this ID, right? RotateObject is the Action that is sometimes not triggering its Performed at all

blissful lotus
#

Yeah, something like that. I haven't looked into the asset in a while, so I don't know how many references would point to a single Action. I'd back up the file and do some extra checking to see if there are any other references to the Action before calling it a day.

#

The editors aren't always that robust. Case in point: I just opened Shader Graph and the Multiply node is throwing a null reference exception, as in the graph node itself,. It's just a dependency of URP - I hadn't used Shader Graph at all in this project to date.NullReferenceException: Object reference not set to an instance of an object UnityEditor.ShaderGraph.Drawing.GraphEditorView.AddEdge (UnityEditor.Graphing.IEdge edge, System.Boolean useVisualNodeMap, System.Boolean updateNodePorts, System.Collections.Generic.Dictionary`2[TKey,TValue] lookupTable) (at ./Library/PackageCache/com.unity.shadergraph@14.0.9/Editor/Drawing/Views/GraphEditorView.cs:1249) UnityEditor.ShaderGraph.Drawing.GraphEditorView.HandleGraphChanges (System.Boolean wasUndoRedoPerformed) (at ./Library/PackageCache/com.unity.shadergraph@14.0.9/Editor/Drawing/Views/GraphEditorView.cs:816) UnityEditor.ShaderGraph.Drawing.MaterialGraphEditWindow.Update () (at ./Library/PackageCache/com.unity.shadergraph@14.0.9/Editor/Drawing/MaterialGraphEditWindow.cs:372) UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

oblique moon
#

But in all of that I'm struggling to understand what you mean by the Asset, because my InputActions asset (the one that can be edited through that Unity EditorWindow) is essentially copy pasted directly into the generated InputActions.cs script (my screenshot was from there), so the GUIDs match

blissful lotus
oblique moon
#

Yes, sorry maybe I wasn't clear enough

#

Everything's here and binds properly, but the Action itself is never called half of the time I start my game

#

And since this comes from Unity I have no idea how to go at debugging this

blissful lotus
#

Just to cover our bases, is the action enabled?

tough imp
#

Does the PS3 Controller still work in Unity?

#

My game works perfectly fine with the Xbox X controller and PS4 controller, but not my ps3 controller

oblique moon
austere grotto
#

We could talk for hours but without seeing the code it's hard to help

oblique moon
#

Thing is, it might be a lot of small things adding up to the actual problem. I was more looking for general pointers as to where to look when such problems occur and if maybe someone had already experienced something similar.
Sharing the code through Discord would take way too long I believe. But thank you for your time

austere grotto
#

!code

sonic sageBOT
austere grotto
#

use a paste site

#

dump your script in it

#

dump the link here

#

as for general pointers:

  • make sure you enabled the instance of the actions asset you created
  • make sure you subscribed properly
  • make sure you don't have a control scheme issue.
oblique moon
#

What I meant was that it's most likely not the script trying to use the Event that's the problem. Because it subscribes to the event properly, it enables the Instance and it works perfectly.
Then, some other times, I start the game and do the exact same thing, and it doesn't work.
In my experience, when behaviors are random like this, the problem rarely lies within the simple endpoint script.
Thank you for your help!

next crown
#

I get all these errors everytime i move my mouse/click since i swapped from eventsystem to Input system UI script, using the default action maps. I get to 999+ errors almost immediately

#

It doesn't happen with gamepad buttons

austere grotto
#

Also I believe v 1.5 is a bit outdated - see if your input system package can be updated

next crown
austere grotto
#

why DefaultInputActions2? Did you clone it?

next crown
#

yeah, i tried and clone it to alter it to fix the issue

#

it was already happening tho

#

i just took away the pen inputs

austere grotto
#

Shouldn't be necessary to modify it

next crown
#

cause i have a tablet plugged and maybe it bugged it

#

it wasn't it tho

next crown
austere grotto
#

which action map?

next crown
#

the defaultInputActions

austere grotto
#

you mean since you switched to the new input system?

next crown
#

i was trying with a custom one before and it was kiinda okay

austere grotto
#

I see

next crown
#

Can't update btw

austere grotto
#

Which unity version are you on

next crown
#

2021.3.26f1

#

do you have any ideas?

austere grotto
#

I'd maybe try just reassigning the default actions to it and restarting unity

#

it;s also weird because that error seems to be a single error but the stack trace lines are being split as individual logs for some reason

earnest dock
#

Not exactly scripting related, but:
I am having a issue wherein my Player Object no longer get Inputs from the Input System (using the new one).
My Player has a Player Input Component Attached, and the same prefab works perfectly well in other scenes.
It worked previously in this scene before I did some CanvasWork.
(One of these Canvas has a Player Input as well, but the canvas is disabled at the time I am having the problem)
How would I go about debuging this?

EDIT: dis/enabling components narrowed the problem down to the the Canvas with Player Input on it
EDIT2: ok, read the docs again, and that cleared up the issue. Every Player Input is a seperate player, with seperate controlls, removed the input, will have to see if it still works as I think it should
EDIT3: as expected, my canvas now just does not respond to my inputs
EDIT4: fixed the issue by moving the script that was doing the actual Canvas stuff into the actual player object, so that it gets the events.

hazy river
#

having trouble with new input system, basically i have two "player" gameobjects using the same inputactions but with different control schemes (both keyboard). problem is only one of them works, the other doesn't seem to be getting any inputs but also giving out no errors. https://pastebin.com/VDZQrg8h can give more information if needed

#

these are the actions if anyone has any experience with this it would be hugely appreciated

dusk aspen
#

guys how do I save the new input I saved in InputAction

https://gdl.space/ohasuheyeb.cs

I have successfully changed the input from W to I but it wont change it in the InputAction file

finite shale
#

Hi, does someone know how I can read only English names from this function? GetBindingDisplayString() When I use the DEU keyboard it show me DEU names for keys

hazy river
vapid fern
#

Hey y'all, having a small (or maybe big?) issue with my code that I can not understand at all.
So whenever I press E or any other key that I have set up to be the "Interact" button I get this error (see image) BUT only when it's one of the given objects you can interact with. So f.e. picking up keys works, pressing buttons, picking up the gun perfectly, but whenever I try to open a gate with the key I previously picked up before I get the erorr shown in the first image, and the second image shows how I make the given button perform the interact function

sonic sageBOT
vapid fern
#

changed it

#

alright, I found the issue eventually by running the code in a different way, sorry for bothering y'all

oblique moon
#

Hello guys, in the New Input System anyone has ever experienced an ActionType: Value not getting to its Performed state for some reason, in what seems to be a random pattern... Restarting the game through editor sometimes work, sometimes doesn't. It's random despite seemingly similar game path to reach the problem.
Both times, the ActionMap is enabled, the Action is enabled, everything else "seems" fine so far where I've looked

still trout
#

Otherwise you want to change something later and forget it on one of the doors and wonder why it doesnt work 😄

oblique moon
#

I think I found a bug but holy hell it looks hellish to report it properly...

twin lynx
#

hi could anyone help me with why when i open vs with unity my victor2 isnt highlighting

sonic sageBOT
timber robin
#

Follow the setup guide

twin lynx
#

alright ill give it a try

#

i have tried all of them still not highlighting my vector2

blissful lotus
#

Hey guys, I have an issue where the value of Touch.delta for any touch that comes from the EnhancedTouch system seems erratic/jittery, but the same delta from PrimaryTouch is much smoother. Consider the following (working) script:

The TouchControlBase.Finger member is provided by the EnhancedTouch API and isn't processed in any way. Does anyone know what is going on here? I've attached an entire script for context, but commented "ISSUE IS HERE" in caps at the relevant part.

#

What I would like to do is usethe EnhancedInput system, but I don't understand why the deltas are so different from standard InputAction results. Does anybody know what's up?

austere grotto
#

you shouldn't be "trying all of them", just the one for the IDE you are using

blissful lotus
austere grotto
#

I don't see it anywhere in the docs for the input system

blissful lotus
austere grotto
#

so is it something you wrote?

blissful lotus
#

Yes.

austere grotto
#

I would guess the bug is somewhere in there

#

Can you show the code for that class too?

austere grotto
#

BTW for sharing code here:
!code

sonic sageBOT
blissful lotus
#

Sure, I'll use one of those.

austere grotto
#

It's unclear what's calling OnTouchMoved or where Finger is coming from here

blissful lotus
#

It comes from TouchInputManager, which is the second file that I attached. Finger is an instance of UnityEngine.InputSystem.EnhancedTouch.Finger which is fetched automatically by Touch.onFingerMoved.

austere grotto
#

could you share it via a paste site

#

I can't download files on this computer (it's a work laptop)

twin lynx
austere grotto
#

give me a minute as this is a bit to digest

blissful lotus
#

The only difference between the two videos that I posted are in the third paste, after the line commented // ISSUE IS HERE. The result of Finger.currentTouch.delta seems to be firing more often than once per frame, and seems to be more erratic, the larger the touch radius is. PrimaryTouchDelta.ReadValue<Vector2> is a much smaller number and seems to do more processing or something.

twin lynx
#

i even delete the whole settings folder

#

and relaunch it

austere grotto
twin lynx
#

still not working

twin lynx
#

the first 2 steps i followed

#

everything the same

austere grotto
#

btw is line 49 a typo?
inputDelta =Finger.currentTouch.
@blissful lotus

blissful lotus
# austere grotto give me a minute as this is a bit to digest

Yeah, a lot of that boilerplate just relies on the value being set to inputDelta in OnTouchMoved(). The value that doesn't use EnhancedTouch works as expected, but other controls rely on it, so I would like to understand the difference happening here. Thanks for taking a look, btw!

twin lynx
#

is there like something i unchecked or sth?

austere grotto
blissful lotus
#

inputDelta = Finger.currentTouch.delta; I'll edit the paste

twin lynx
#

im using vs 2022

austere grotto
twin lynx
#

oh

#

alright ill give it a try now

blissful lotus
#

@austere grotto I've managed to isolate that the value of Finger.currentTouch.delta gets messier the more I fat-finger the touchscreen, scaling with Finger.currentTouch.radius, but InputAction.ReadValue<> on the same frame gives a more tame result.

twin lynx
#

where is that setting

austere grotto
#

which one

twin lynx
#

wait yea

austere grotto
twin lynx
#

i tried this already

#

still not working

austere grotto
austere grotto
#

the package in the Unity Editor

austere grotto
#

nope

#

Go to the package manager inside Unity

twin lynx
#

theres no package manager

austere grotto
twin lynx
#

oh fk me

austere grotto
#

you're looking at Visual Studio

twin lynx
#

thats vs

twin lynx
austere grotto
#

code coverage?

#

No you need to install/update the visual studio editor package

twin lynx
#

oh is this needed?

austere grotto
twin lynx
#

still not fix

#

is there a problem with here

blissful lotus
#

Also, the behaviour isn't affected by other controls using EnhancedTouch with exclusive access to their own Finger object. Tapping the screen elsewhere doesn't add jitter, only the radius of the affected touch.

twin lynx
#

oh wait

#

nvm

#

still the same

blissful lotus
#

Also, substituting all these logic with discrete touch inputs in the InputActions asset gives a good result. The only wildcard is why EnhancedTouch is giving delta values that scale with it's own radius.

blissful lotus
twin lynx
#

its fix

blissful lotus
#

To anyone interested, I solved my touchscreen issue using the following extra code.

    {
        // Just ask the F***ing device for the right value
        return Touchscreen.current.touches[finger.index].delta.value;
    }```
Thanks @austere grotto for checking it out earlier.  EnhancedTouch.Touch has a habit of confusing the order of frames in it's history and sometimes reports the delta as the negative of what it should be.  I tried negating it manually in those cases and got a partial solution, but ultimately I got lucky that the active Touchscreen's touch ID is the same as EnhanceTouch's active finger ID.
lone python
#

Please how can i create this button effect using a keyboard button instead of the mouse?

#

I found do to it with a coroutine but is there an easier way to do it ?

blissful lotus
#

@lone python This isn't really the right place to ask. Try one of the #code- channels, maybe? The event system isn't the same as the "new input system", which is what this channel is specifically about.

blissful lotus
#

While not an answer, do you know any way to search for samples in the profiler? I was going to compare my project with yours but I'm not sure how to find that entry.

#

I want to find DeferredResolutionOfBindings(). I am also using the new input system.

#

Ah, I actually don't have any calls to that.

#

Well, I'm using mainly touch controls which don't come from inputactions, so I can try to test if I can get that method to appear.

#

That doesn't sound right, but also I have a lot of abstraction between EnhancedTouch and all input-related things, so I might also be substantially different from a typical implementation that my result is also thrown off.

#

Can you share that component?

#

I do wonder if maybe you're polling the input system in things that maybe shouldn't be handling control of that.

#

If your gameobject is sending messages every frame, that is fundamentally terrible. (...are you?)

#

You should tell the door when it is relevant, not ask every door to go see if it's their turn.

#

I'm making some assumptions without seeing your code, just to be clear.

#

Okay, is PlayerInput on the same gameobject as SecurityDoorBreakOpen? Is that gameobject representative of a player or a door?

#

Does the PlayerInput script reference the input system to check for button presses?

#

Rather than play 20 questions, can you show me a piece of code that calls any derivative of InputSystem?

#

Ultimately, the call will start there.

#

We know you have a lot of overhead, so maybe let's do a project-wide search for that namespace.

#

Or use a paste site and just show your code more than 1 line at a time.

next crown
#

I'm making a cursor like feature and I need it to work for both mouse and gamepad axis movement. Both mouse input and gamepad axis inputs are in the same action like unity says to do, but I'd need different code depending on the action. I'll explain further: for mouse input, i can get the absolute value (previewAsset.transform.position = Camera.main.ScreenToWorldPoint(ctx.ReadValue<Vector2>());) But for gamepad input this wouldn't work. It should be at least additive previewAsset.transform.position += ctx.ReadValue<Vector2>(); How can i have different logic for the same action?

tranquil pivot
#

hi guys, im trying to compare two projects and their input systems, one is a fresh project with an imported 2d controller and another is a semi fresh project with the same imported 2 controller

the fresh project input system works fines, character can jump around etc

in my semi fresh only left and right input works and the jump doesnt

im trying to compare the differences between the two projects so i can make it work in the semi fresh but there are none from what i can tell, is there anyone that has some tips for me? where I can look? thanks!

not sure how else to describe it sorry, but i am really stuck

austere grotto
#

How did you hook the input asset up to your code?

tranquil pivot
# austere grotto Can't really help without seeing details
namespace TarodevController
{
    public class PlayerInput : MonoBehaviour
    {
#if ENABLE_INPUT_SYSTEM
        private PlayerInputActions _actions;
        private InputAction _move, _jump, _dash;

        private void Awake()
        {
            _actions = new PlayerInputActions();
            _move = _actions.Player.Move;
            _jump = _actions.Player.Jump;
            _dash = _actions.Player.Dash;
        }

        private void OnEnable() => _actions.Enable();

        private void OnDisable() => _actions.Disable();

        public FrameInput Gather()
        {
            return new FrameInput
            {
                JumpDown = _jump.WasPressedThisFrame(),
                JumpHeld = _jump.IsPressed(),
                DashDown = _dash.WasPressedThisFrame(),
                Move = _move.ReadValue<Vector2>()
            };
        }
#else
    public FrameInput Gather()
        {
            return new FrameInput
            {
                JumpDown = Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.C),
                JumpHeld = Input.GetKey(KeyCode.Space) || Input.GetKey(KeyCode.C),
                DashDown = Input.GetKeyDown(KeyCode.X) || Input.GetMouseButtonDown(1),
                Move = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"))
            };
        }
#endif
    }

    public struct FrameInput
    {
        public Vector2 Move;
        public bool JumpDown;
        public bool JumpHeld;
        public bool DashDown;
    }
}

its from a package so it comes with everything and it works in a fresh project but not my semi fresh one.. i say semi fresh cause i've literally created a scene and imported some packages and that's it

austere grotto
#

Put some log statements in here and make sure it's running

tranquil pivot
#

its running, the inputs are being pressed, i've tested it 😦 thats why im so stuck

austere grotto
#

What debugging steps did you take

tranquil pivot
#

there is an on screen keyboard mapping highlight and i did the debug logs to see if the code is running

austere grotto
#

And make sure they're making it to your character controller code

#

Should be pretty simple

austere grotto
#

As you see they work quite differently

gleaming hill
#

hey, has anyone ever had a problem where their game seems to eat keypresses - specific problem I'm having is folk playing my game are unable to use their discord mute keybind, once they tab out it works, tab back in and it gets eaten again. my game doesn't use the key as a binding so not sure what's going on

dusk aspen
wooden shadow
#

How can I detect when the player switches from keyboar to gamepad without PlayerInput component?

supple crow
#

How are you using the PlayerInput component to do that right now?

#

You can subscribe to InputUser.onChange.

#

it passes you an InputUser that you can get the current control scheme from

#

(you also get an InputUserChange argument that tells you what kind of event this is. one kind of event is the control scheme change.

gusty bridge
#

I am trying to wrap my head around the new input system but I have having difficulty doing so... I have scripts that check if a button is triggered and they ONLY work if they are in my Input System UI Input Module. Is there a way to use new Action Assets without having them needing to be in the Input System UI Input Module?

austere grotto
timid granite
#

whats difference between these:

#

Especially the ones that have # and number ThinkSpin
This is for unity new input system

timid granite
#

how can you differently touch screen on mobile ThinkSpin

austere grotto
#

I e. Second third fourth etc touch

austere grotto
austere grotto
#

Independent touches

timid granite
#

why does it start from 0 though ?

austere grotto
#

Most things in computing do

timid granite
#

well I know that, so what your saying is that #0 means array slot 0 aka single touch whereas #1 is 2 touches ?

austere grotto
#

It's the second touch

#

Say you have a finger on the screen already

#

And touch it with a second finger

timid granite
#

oh I see

#

that makes what I wanna do slightly more complicated I guess

austere grotto
#

What are you trying to do

timid granite
#

so I can use same code:

#

as I have been using it so far

#

I know I can make drag and drop and then clicking to differentiate which would be probably best for this type of input anyway

#

but for now its not feature I want to add so was looking for quickest simplest solution

flint vessel
#

hi guys, why is this code giving me an error?

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

public class PlayerMovement : MonoBehaviour
{
    PlayerInput playerInput;
    InputAction moveAction;

    void Start()
    {
        playerInput = GetComponent<PlayerInput>();
        moveAction = playerInput.actions.FindAction("Movement");
    }

    void Update()
    {
        ReadMovement();
    }

    void ReadMovement()
    {
        Debug.Log(moveAction.ReadValue<Vector2>());
    }
}
austere grotto
flint vessel
austere grotto
#

Open the console

flint vessel
austere grotto
#

Click on one

#

Read the full error

flint vessel
#

ohhh this part

austere grotto
#

Which is line 24?

flint vessel
#

the debug log

austere grotto
#

Looks like you don't have an action named "Movement"

flint vessel
#

have i named it the wrong thing?

austere grotto
#

I think you need to write "Player/Movement"

flint vessel
#

thats weird let me try

austere grotto
#

Why is that weird? Did you Read the docs for FindAction? It probably mentions that

flint vessel
#

im still geting the error

austere grotto
#

Did you assign the action asset to your PlayerInput component?

#

Did you save the code?

#

Did you save the input asset?

flint vessel
#

im very new to this input system i think i watched a bad tutorial 😭

austere grotto
#

This is definitely an unorthodox way of using the PlayerInput component too

flint vessel
#

ill follow a new tutorial

#

thank you for lettin me know

undone notch
#

hi everyone, I have a question about the InputAction.ApplyBindingOverride method.
Why using this method with a classic keybind (like jumping) doesn't keep the original key (so only the override triggers the input)
and when using this with a composite keybind (like moving) it keeps the original key working with the new binding?

I basically go like this, maybe i'm doing something wrong:

action.ApplyBindingOverride("<Keyboard>/o", "Keyboard", action.bindings.First(a => a.name.Equals("Up", StringComparison.InvariantCultureIgnoreCase)).path);

(note: I am using the third parameter "path" because I wanna override only one part of the composite, and the "action" is from the InputActionAsset with FindAction("Move"))

edit: I'm just extremely stupid the last thing doesn't check for the group so it was getting my gamepad binding and replace this one ^^
but I'll keep my message if anyone has a better solution than the way I get the third argument ^^ thank you!

dusk aspen
dusk aspen
#

how will Access W,S,A,D in move actinos

#

actions

#

like what will their index be

austere grotto
upper ledge
#

Hello. I have an issue where, after making some changes to my game and rebuilding. The application now loads on monitor 2 instead of 1. Any ideas?

#

not sure if this is the correct channel

still trout
#

Hey, how do i get actions from a paired user (via var user = InputUser.PerformPairingWithDevice(...)) ? On the general InputSystem you can just do actions.FindAction() and add a listener, not doable with a user tho..

formal girder
#

for the new Input System do I need the controls.Enable() and .Disable() when using the PlayerInput Component? Do I need it for every workflow or is it only necessary when using special workflows?

austere grotto
still trout
#

If a player was assigned a player root through the Multiplayer Event System is it possible for them to instead select global elements too?

lucid kelp
#

https://hastebin.skyra.pw/azidefegag.csharp Hi This is the code that helps my character focus its aim on the mouse cursor but clients currently dont have access to the mouse to rotate their own torso and only the host cant do it. The torso transformation doesn't commit to the network as well. Im stumped.

austere grotto
#

isn't this a pretty typical NetworkTransform kind of situation?

lucid kelp
#

so you may be right

#

but I needed to do this for the animator so I thought this would be the same which is just me fumbling with components and scripts

#

but I still havent found a solution to this in Unity 2022.3.7f1

kindred finch
#

!code

sonic sageBOT
pale rock
#

I'm having an issue here, a friend of mine with a Steam Deck tried to play my game (which uses the new input system), but can't use the touch screen.
He gets a lot of GetPointerTouchInfo failed: Call not implemented. and GetPointerTouchInfoHistory failed to determine number of touch events: Call not implemented. errors.
I don't have a Deck with me, and I don't find a lot of info on this subject, except other unsolved similar errors.
I'm unsure what's the correct way to integrate touch controls for my game (which should only emulate the mouse)

verbal remnant
# pale rock I'm having an issue here, a friend of mine with a Steam Deck tried to play my ga...

new input system is know to be cantankerous when it comes to touch, you can use the old system and https://assetstore.unity.com/packages/tools/input-management/fingers-touch-gestures-for-unity-41076 (free version exists)

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.

pale rock
#

I don't really want to go back to the old system, now, it's really integrated into the game.

#

Should I not support the Steam Deck? Is that my choice? Go back to the old stuff or ignore the Deck altogether?

ivory jacinth
#

@pale rock do you have any snippet of code of how the interactions are implemented? Without seeing your code it will be pretty hard to advise anything :)

pale rock
ivory jacinth
ivory jacinth
# pale rock Where it poses problems (i.e. when the game starts), there aren't' really any sp...

How do you handle the click on the button? Do you have any code for that? I have a short video about how to do it without any code: https://www.youtube.com/watch?v=NqrJHj9xlqY

In this short tutorial we will explore how to fast and easily handle touch input in your mobile game. I am currently working on a mobile game and I couldn't believe Unity made it so easy for use. Mobile controls can be added literally within minutes! I hope you enjoy the tutorial :). Love you!

00:00 What and how?
00:35 Setup
01:10 Mobile Stick...

▶ Play video
#

Those are for mobile controls, but I believe the regular canvas buttons handle taps by default on all platforms?

pale rock
#

I don't use a script for buttons, they're handled with UnityEvents

#

Same for my text box, it's a TMPro InputField

#

That's why I'm confused, I really was expecting everything to already work, as I use standard stuff

ivory jacinth
#

oh, in that case I won't be able to help! Sorry!

supple crow
#

By default, touching the screen seems to emulate mouse input, though

#

(which makes my view spin like crazy in-game)

#

I can touch ui elements to click on them, notably

#

So, perhaps the answer is to not even try to receive touch input in the first place.

pale rock
#

What's odd is that I don't try to do anything.
The word "touch" does not appear once in all my code for instance.

#

I have to get my hands on a Deck then, and try to remove things until it works.

twin python
#

Hello ! I use the new input system. When I plug my Playstation 3 Move into my Mac with the input detector open, it detects all inputs from the PS Move but when I press it nothing happens. Does anyone know a solution to this problem?

austere grotto
twin python
austere grotto
#

What?

#

Does it detect the buttons or not?

austere grotto
twin python
austere grotto
#

Why would you expect it to work when not plugged in?

twin python
#

At the moment when I plug it, idk how to explain.

#

I do not speak english very well

tulip tartan
twin python
austere grotto
#

I don't think Unity supports that controller

#

You'd have to find a plugin to support it probably

twin python
#

Yes, I just wanted to avoid going through another plugin, thank you for your help.

burnt mulch
#

anyone found themselves in this situation before, the UI is on top of the "listen to button" button

supple crow
#

There's something wrong with the UI layout in the current version, yeah

#

Is there a nice way to reference an input action map?

#

similar to InputActionReference

#

I'm currently just picking an arbitrary action from the map and then getting its map

jovial glen
#

Hello! I am using unity xr interaction toolkit and working with a quest2, is there ANY way to check how the input is being called? i have a xrorigin(the player) and a xr manager, i want something to happen upon pressing the right trigger(in documentation its called Axis1D.PrimaryIndexTrigger) but i cant seem to reference/find it at all

#

so for example:

if(input.getbuttondown.name of the controller button){
// code logic
}```
muted stirrup
#

I was using this at one point to rotate my camera but now in a similar setup this fails to update back to a Vector3.zero when the mouse is not moving at all

    void MoveCamera(InputAction.CallbackContext context) {
        Vector2 cameraVector = context.ReadValue<Vector2>();
        cameraObject.transform.localEulerAngles += new Vector3(cameraVector.y * -1, cameraVector.x, 0) * 0.1f
    }
#

Which cause the camera to keep rotating at a small speed constantly. I have debugged the value from insie of this MoveCamera() method that is subscribed to on Awake

#

SOLVED: The action in my action map was somehow changed from a 'Pass Through' type to a 'Value' type and was breaking the mouse delta

tired stirrup
#

What is the actual correct way to make an FPS camera controller and player movement system? I have a capsule and basic XY mouse detection to look around but the WASD feels bad since it switches left/right immediately and you can't go diagonal

austere grotto
#

But unless you did something weird you should be able to go diagonally pretty simply

tired stirrup
#

I see, ty

fair pier
#

Anyone had an issue where touch seems to only work on samsung devices and not anything else?

deep rivet
#

How can the Input System run two user inputs at the same time?
Like i want to be able to drive and jump at the same time 🙂
Right now when i click at jump, the jump gets executed right after the object finishes running.
The object is a Rigidbody2D (no player) and my mappings are as following:

        actions.FindActionMap("gameplay").FindAction("accelerate").started += ctx => StartAccelerate(ctx);
        actions.FindActionMap("gameplay").FindAction("accelerate").canceled += ctx => EndAccelerate(ctx);
        actions.FindActionMap("gameplay").FindAction("jump").performed += OnJump;
tulip tartan
#

Do you actually do the physics in those methods or in FixedUpdate? You should capture input in the callback methods and USE the input in FixedUpdate

deep rivet
#

The physics are done within the FixedUpdate Method.
Looks currently like:

    void FixedUpdate()
    {
        if (accelerateCar)
        {
            frontTire.AddTorque(-4);
            backTire.AddTorque(-4);
        }
        else if (jumpCar && !isJumping)
        {
            carBody.AddForce(Vector3.up * jumpPower);
            jumpCar = false;            
        }
    }
#

In the Methods i am just setting a boolean

tulip tartan
#

That is your issue

deep rivet
#

4real? Let me test 😄

tulip tartan
#

Else if will only be called if accelerateCar is false

#

If it's an if, it will be decoupled from that check

deep rivet
#

U are totally right. How did i not see this🥹
Thank you! Made my night 🙂

brittle jewel
#

how do I get my character in the game screen to move toward places and act?

#

I had setup a scripting and it does not continue yet

#

I did the "spacesuit" character script

#

from the website

tulip tartan
#

Ah... "the" website. Gotcha

Show some !code so we can take a look and help

sonic sageBOT
echo nymph
#

Im having an issue where my bool wont switch unless I use the input twice. I have it so 1 is my AR and 2 is my shotgun and when i switch to the other the bool changes, im doing this so i can adjust how much damage the gun does based on which weapon is selected. I'm not sure exactly why the bool requires 2 inputs to update but if anyone knows lmk. (also ik my programming is messy not optimized, this is a test project )

#

ill provide more info or full scripts if needed

ivory bane
#

are all action maps enabled at once?

errant echo
#

im having some issues with the code here when trying out the new input system

#

My player input is set to send messages

#

I use a up down left right binding for the WASD input which is for move

#

The jump has no isse rn

#

The problem I have rn is that despite getting value

#

the rb.velocity doesnt move my player at all

#

Someone pointed out that it could be because the values jump from 0 to not 0 so the physics ngine doesnt have time to update the rigid body before it resets back to 0

#

Does anyone have any input on this?

#

Im wondering if its because the new input system only detects the button when its pressed

#

But I have been told that adding interactions is not necessary fro what Im trying to do

austere grotto
# errant echo

None of this has anything to do with the input system really

#

you just have a bug in your movement code

#
rb.velocity = inputValue.Get<Vector2>() * movespeed;```
Since you're doing this every frame (or at least any time the joystick slightly moves), any velocity you got from your AddForce call will be overwritten
ivory bane
#

whenever I have my player input component active, the game no longer recieves input, is there something im missing? Like I have an event system that takes input from the new input UI component. But whenever I enable the player input component (on my player to control them not the UI) it stops input to the event system. Does anyone have a guess why?

austere grotto
#

or the default one

ivory bane
#

I assume the default one since I don't know what the custom one is. I'm using invoke unity events to control the character.

austere grotto
#

look at the inspector

#

check which one is assigned to the input module

ivory bane
#

im using the custom one I made yeah, now I see what you mean.

austere grotto
#

the PlayerInput component enables and disables different action maps as needed

#

it has a concept of "current action map"

#

Is there a good reason you need to put your custom asset in the input module?