Found a thread discussing it: https://forum.unity.com/threads/rebinding-keys-isnt-reflected-in-existing-controlschemes.829191/page-2
#🖱️┃input-system
1 messages · Page 16 of 1
Yes just do _controls.asset to get the instance
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.
do mouseDown and mouseUp events also work for controllers?
How do I re-reference the given action from the instance properly?
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
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
What should I use to make customizable inputs?
Wdym customizable? The player can rebind them?
There are functions for rebinding in the new one
There's even a sample that includes prebuilt UI elements
Oh, do you have any link to the sample? 🤔
If you go under samples in the package manager you should find it
Okay thank you ☑️
There's also videos using it like this one https://www.youtube.com/watch?v=qXbjyzBlduY
Is there a difference between ApplyBindingOverride() and ChangeBinding() or ChangeCompositeBinding()
They seem to do the same thing in a different way
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
Can you show the Generated C# file?
yes of course, https://pastecode.io/s/eu2jth8d
Hmm, Look doesn't exist there it looks like
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
if you're asking if jump works in game, yes it does which is strange
Ok, that actually is what I expected. Your Generated C# file DOES include Jump. So it SHOULD work.
Look doesn't exist in it, so the asset wasn't saved after creating that action, it looks like
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
}
],
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
No, saving the asset will do that for you. You shouldn't modify the generated file directly
That is weird. Not sure why, sorry
its ok, thank you for at least giving it a shot
do you think it could be my editor version?
I don't think it should be. Which version are you using?
Nah, that one doesn't have any bugs related to this afaik
i found the solution, apparently unity created a duplicate c# class which wasn't applied on the input manager, and in my script i was referencing the duplicate script and not the one assigned to the input manager, I still don't know how it got duplicated but im happy it works
the classes were nearly identical in names so i didnt even notice
Oh super weird! I wouldn't have suggested that as an issue. I'll keep that in mind if someone else has this issue. Thanks for following up!
Thank you though, i probably wouldn't of found the issue if you didnt lead me to the script.
saved me hours lol]
Whenever I press a button it starts and gets canceled right away and I don't know why. Any ideas?
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...
I think it's too early for everyone.
Why do you have a Hold interaction on it?
Sounds like you probably made some basic C# syntax errors. But without seeing the code and the error messages, can't help more than that. Your description is too vague
I assumed I needed it for press and hold until released/cancelled. I'm out driving right now but will chat about this later when I have time
That is an incorrect assumption.
Good to know. I'll change it later
!code
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.
Share the full script and the full error messages
Alright, I've removed the "Hold" and tested again but after pressing the W key it get's canceled right away.
show your code? How did you hook the action(s) up to the code?
{
//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.
um
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
there's an IA.canceled event
if you want to know when the interaction is canceled, subscribe to that
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.
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 ?
Not as far as I know. I set a held beld to true when it is started, and false when cancelled
it sounds like the issue is that you are registering a new listener for menuOkAction.started event in MenuOk(). The event invocation goes through a list of listeners so if you add one during the event "resolution", it'll be called immediatly.
I add the listener in hte Start() function of my whole menu controller, and use booleans to check where I am in my menues and how to react accordingly.
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.
I think you should be able to setup the input system to have some actions be "consumed" when processed (so you can only have one listener reacting to it). That could solve this problem (as long as you don't rely on multiple listeners later down the line).
However I don't remember where that option is
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 :/
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;
}
}
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?
COuld it be control scheme related?
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
no you'd have to look at the control scehmes associated with the actions and the bindings
Cutting and pasting the same scheme has temporarily fixed this, but I worry it may re-emerge
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.
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?
The theory would be that you create say an action that you want to map. Say move, and if you wanted to have different controls for that move you would set them up as in the image (under move there is left stick and 2d vector - one for joystick and the other for wasd)
Then in your code you would response to move which abstracts away the keyboard or joystick or whatever.
That part I get but these are separate actions, like WSAD for movement and the mouse for looking around.
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
So I can't combine them into one function(s)? They look their own functions to work?
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()
hmm
ok, separate functions then
I was thinking of some IF statement to check what was being used and then code.
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
I think you're right after looking at my code again
InputAction only maps to one set of actions.
this is more like the old input system where you check if a button is being pressed and then you decide to act based on that button press. The new input system abstracts that away and now you are a step away from that. You are no longer checking to see if the button was pressed, instead you are reacting to the button being pressed.
I think I'm good now, thank you very much.
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).
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?
you probably can't rely on any particular ordering.
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
I just tried that and it doesn't seem to be the case that it depends on the order they subscribed in, there's something else that is responsible for the order. But ultimately I decided to go for a different solution as to not depend on that anyway.
best not to depend on this, agreed
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
You have it completely backwards
the input manager is the old system
PlayerInput is a component that is part of the new input system
ok sweet. But I dont have the component available
You should leave this alone
i've been unable to find it
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
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?
yes
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
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
As I mentioned, in the input system package
I don't recommend casually doing this
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
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
== is how you compare things for equality
= is used to assign things
Do you know if overriding inputs on the new input system overrides them for multiple players, or is the InputActionAsset instanced?
The asset is instanced. Each PlayerInput has its own copy
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 
hello, i got an issue: the same code, but depending on the keybinding, it's not working
when does this happen please ?
show more details
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"
Show how you set up the action and the bindings
and how you hooked up this code to it (e.g. in the inspector? By manually subscribing to an action?)
works for Move down but not Move up
missing a lot of info there
I want to see how the action is configured (the right panel)
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;
}```
oh yes it's easier that way
i done many tries, it seems like it's working randomly (but rarely)
i'm gonna dig deeper to see
i use the ReadValue, so when the key is released, the bool becomes false
in your code it will not right now
this will do that though:
ButtonUp = myContext.ReadValueAsButton();
anyway can you show the rest of the code?
it's just that, checking if the button is pressed or not, then the boolean becomes true or false
Sounds lovely but you have an issue with the code so seeing the code will be helpful
Looks like MoveLeft is setting ButtonDown instead of ButtonLeft
right and down works, left and up do not
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 🙏
yes i was just doing left i copy paster from down (which is working"
also all of this can be replaced with ButtonLeft = myContext.ReadValueAsButton();
no need for the if statements etc
where did you put the print
also show the action and binding configurations for the ones that don't work
it inded works but still only right and down works
show the current code and current configurations
without that, I really can't help you
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
why do you have the action as "Pass Through"?
It should be set as Action Type - Button
and show the code for MoveUp
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 ?
thank you for the help btw
this is all I know ¯_(ツ)_/¯
i guess i gotta use the "listen" function for now.. thanks
You'd have to show the code
i dont think its the code because it works well on keyboard
and the jump
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()
There is some code there that is causing movement to be null, however i'm not sure how to alter it to work, ill send the code here
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
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
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/
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.
Is this chatGPT code?
I'm also not quite understanding the issue. When you rotate, it "freezes the animator" and "all animations to rotate from the hip"
In your code, you disable the animator when rotating, so... wouldn't that be why it freezes? If I'm understanding you right of course
if (isRotating)
{
animator.enabled = false; // Disable the animator while rotating
}
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
"Rotating the hips"
Do you mean rotating along the y axis? What does that mean?
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
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?
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
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
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
?
animator.SetBool("IsMoving", true);
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
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:
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?
how to change actions maps by code?
change them how
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
you mean you want to just change the current Action Map on your PlayerInput component?
thx man 
Why it doesn't work?
You need controls.Enable(); I believe
Though it might help if you explain what "doesn't work" means
The event doesn't fire.
^
Thanks, it has fixed it.
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
anyone know how to fix this
Capsile collider is disabled on the right
What does the parent object's inspector look like?
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 :/
anyone using the advanced multiplayer template I am having trouble with the new input system.
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
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
If you could, please provide a script to give others a better idea of what the issue is.
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?
Is this thread for the New input system, questions etc. or is it generalized
It's for the new input system
@tulip tartan thats good, ty
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;
}`
You'd have to actually show the part of the code that deals with run speed
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>();```
oh yes thx
`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);}`
i send it
It's because you're using Lerp incorrectly.
how can i solve this problem?
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.
You should be able to do:
if (ctx.control is Pointer p) {
p.Whatever();
}```
assuming ctx is an InputAction.CallbackContext
Didn't work...
Somebody know how to read GetKeyDown in new Unity Input System without any events, via code?
explain
Completely got skipped.
Keyboard.current[Key.A].wasPressedThisFrame
start debugging
print out what type the control was
fair enough
i want to change it here, between this and Input.GetKeyDown no different
If you want exactly like the old GetKeyDown you would use like what I said
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();
}```
can u tell me how to make its trhough generated c# script?
the same way you just get the input action from your wrapper
e.g.
myWrapper.MyActionMap.MyAction```
ure my hero ...
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?
Use https://docs.unity3d.com/Packages/com.unity.ugui@2.0/api/UnityEngine.EventSystems.EventSystem.html#UnityEngine_EventSystems_EventSystem_SetSelectedGameObject_UnityEngine_GameObject_ to set the currently selected object to one of the newly enabled objects, then it will work.
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?
Are you getting any errors?
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?
(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)
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?
Anyone know how to rebind this keys through script?
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.
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
What advantage does using EnhancedTouch give instead of using the InputActionsMenu itself?
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
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
"3D movement" is extremely vague. There are many ways something can move in 3D
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?
make sure you have an event system in the scene
make sure there are no other ui elements or other objects blocking the buttons
make sure there's no errors in console
hello i am having issues with UI buttons not detecting mouse over or clicking, can anyone help. I can share screen if its easier
I was pointing you to the messages right above you
you need to follow those same steps
Later I will send you screens cause I followed all the things you wrote
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!
- Which input action asset are you trying to modify? In what folder does it live?
- Did you make sure to save any changes to the asset?
- 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.
- 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.
I would say after saving check your version control status / diff status (e.g. git) and make sure the changes have been saved to disk
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.
I'm not sure I understand what you mean by changing the asset in code
Are you using editor scripts to change the asset or something?
Or changing it at runtime?
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
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
Each Player Input component represents an entire player
So if you have two of them, you will get weird behavior
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
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?
How are you setting the control scheme?
So you want the inventory to appear while you're holding the button, and then go away when you release it?
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
At the moment, I'm just making the default control scheme for characters as No Tap Jump
and I can confirm that it's still on No Tap from pausing the game and seeing it as such
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
What does "input system for fps" mean? The input system works the same no matter what your games camera perspective is.
@austere grotto i mean in a general aspect not just the camera
Yes there are general tutorials for the input system including the ones pinned to this channel
@austere grottoty
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".
it sounds like maybe you need to disable the input actions used for controlling the player while the level up screen is up?
Can someone please help? :c
This isn't really what control schemes are for
Control schemes are for recognizing a player as different sets of input devices
Realistically you just want an if statement
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.
Was the chatgpt nonsense necessary?
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?
could be missing event system in the scene
could be missing graphic raycaster on the canvas
could be your event camera is not assigned on that canvas
could be some other ui element blocking that one
How can i know what it is?
check each one
Yes, I can’t explain well
Please see the #📖┃code-of-conduct post and the section about how using AI generated questions or answers is against the rules.
If you can't explain it well, let someone else explain it
What were you trying to explain exactly? You just posted some AI drivel in response to nothing
!mute 1046903687680897194 3d Don't spam the server. Read #📖┃code-of-conduct as you were already advised
ezoidrake52 was muted.
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
You're trying to make input rebinding?
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
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
how to know if a key is held down through the context parameter?
Define "held down"
Is being pressed
Like it has been held down for some time before now? Or you want to run some code every frame while it's held
Every frame while its pressed
You will need to use Update or a coroutine for that
Oh so theres no method or whatever for the context
In Update you can call myAcion.IsPressed()
The function is only called when the interaction is performed, started, or canceled. The parameter can't help you to have it called every frame
Hmm yea
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
Not that I know of but in what scenario would you ever have those two components on the same object?
What purpose would that serve?
I wouldn't expect it to break.
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
the UI Input Module is for UI input
Player Input represents a single player of your game.
Do you have multiple Player Input components?
The input module goes on the event system there's no reason for it to go on a camera
The camera needs a physics raycaster
PlayerInput generally should go on your player character object
no
there isn't one its top down 2d, think mini-metro
its that style of game
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
ok so physics raycaster 2d and input module are unrelated?
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
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
It's its own separate object. It gets created automatically whenever you add a UI element to the scene
What type of interaction should the scroll wheel use?
I'd check what they use in the default input actions asset
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?
https://issuetracker.unity3d.com/issues/input-system-asset-does-not-save-when-pressing-ctrl-plus-s
Votes would be appreciated
How to reproduce: 1. Open the user's attached project 2. Open Assets/PlayerInput.inputactions 3. Add Action 4. Press CTRL+S while in...
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
And if you stay pressed on the button, log appear 1 or 2 time ?
On pressing the button ShootL appears. On releasing the button, Shoot L appears again along with ShootL Release
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
When are you calling EnableInput()?
Also how are you hooking this code up to the input asset? I don't see the listeners being added anywhere
did you initialise your event ? you have your input system and the correct trigger, but in your script did you have link between your action and your method like this?
when the game first starts, and then never again until a new game is launched
the script is inheriting from the interfaces of the new InputAsset, meaning the funcitons with "On" prefix are functions on the original input asset that are called there from unity
yes they have, the problem is in this class, as when i call a debug.log in this script with "OnMove" is see nothing, meaning the method isn't even called
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 ?
no the input never works not even at the game start, it just used to work at some point but then one day it stopped without me having changed this script
inputreader is a scriptable object, so yeah i create a object in my assets of this type and use only this instance
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
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 :
ok if you make a breakpoint at inputAsset = new InputAsset(); link visual to unity and launch it, did you trigger the breakpoint ?
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
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 ?
yes the breakpoint is triggered
i don't understand the end of you question
you can speak in french in private message if you want
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;
its all done automatically in the input asset generated script :
i'm just inheriting from the interface of this script
they won't be called automatically, not without you subscribing it
this is the generated interface for "Gameplay" :
you need to call like inputAsset.SetCallbacks(this)1 or something for that to work
hoooo first time i see this
did you watch the video i linked in the response to your post on the unity hub ? it's the way he has done it and it's what i used to and it worked just fine like this
ahhhh this is interesting i didn't know this function
You didn't see this?
YOu missed part of the video
that's from your video 😉
THANK YOU SIR I'M BLIND, my god that's embarassing
@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
What's the easiest way to detect what button binding was pressed when the action gets triggered?
For what purpose?
Are you trying to make a Vector2/2D composite here?
Because this isn't how you do it
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.
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
set up a 2d composite
not whatever this is
I've read that was an option but wanted to try and see if I can get my initial setup to work. But I think I'll try implementing the composite after this feedback lol. Thank you.
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.
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
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
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
why would the client need to read the inputs of the host?
bcs when host leaves game, i want to client is new host. this is working, but not working new host's inputs. i can't read this.
why would it matter if it's a client or a host
you always should only be reading input from your local machine
Have you read through https://doc.photonengine.com/fusion/current/manual/network-input#unity_new_input_system ?
Input definition, polling and consumption lie at the core of Fusion. Back To Top
The input struct can store as simple or as complex data as needed.
okey but new host's (this is old client) input not working. can't moving, can't jumping or anything. i want to solve this.
hello, everyone, How to trigger input system events after clicking a UI virtual button without using on-screen button or key simulation
Why the weird restrictions here?
- Why can't you use OnScreenbutton?
- Why doesn it have to trigger an input system event rather than just calling an arbitrary function?
My initial recommendation is: Use OnScreenButton
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.
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
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?
Alright, thank you for answering. Now, i get the idea that i need to handle the logic myself
is your input module set up properly?
yup in the Input Debugger the inputs are recognized correctly but that events are never called
no i mean
the input module on the event system
that wouldn't be related to the input debugger
that's my event system, it work with standard mouse input
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?
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;
}
what about click?
is there too
I only see right click? mouseState.WithButton(MouseButton.Right, aButtonPressed);
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
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);```
this is there too just before the button if
in order to update the position even if i not press any button
yeah but when you press the button won't the state be overwritten to not have any position?
it has the position is on "virtualMouse" variable
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);```
i try that
Also for the binding I would remove Mouse and VirtualMouse and add Pointer
that should cover any pointer device including the virtual mouse and a real mouse
sadly nothing changed
found it, it seems that the virtual cursor image blocks raycasts of the EventSystem
- I can't use the On-Screen Button because I'm using UI Toolkit.
- I'm working on a mobile project, but I need to debug it from the keyboard to make things easier.
Write a custom OnScreen control that proxies the UI Toolkit button interaction to it https://docs.unity3d.com/Packages/com.unity.inputsystem@1.8/manual/OnScreen.html#writing-custom-on-screen-controls
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.
what does this have to do with input handling?
seems more an issue of your aiming code
I just thought it might be the input system my bad
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.
It may be a hardware limitation of your keyboard
Or a bug in your code
Look up "n-key-rollover"
There are online tests for the keyboard limitation
What's the easiest way to detect what's the last device used?
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
do not crosspost. Once in #💻┃code-beginner was enough
Sorry
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.
Dunno if you can do this, but you could try to make it an optional parameter.
Or overload the method.
I wouldn't know how, but otherwise you'd need to construct your own CallbackContext struct
Oh boy, that's a lot of stuff I dont understand for something I thought was going to be relatively simple. I believe that remaking the method with a different name is the solution here lol
Remake it with the same name, but without the parameter. That is called an overload
public void Jump(CallbackContext ctx)
{
// do stuff
}
public void Jump()
{
//Do stuff
}
Just like unity methods that have different signatures (like Instantiate or Raycast)
Oh I didnt know you could use the same name, does overloading just a way of calling a method but in different situations? Like besides to solve this problem of calling it without the input is there any other use cases for overloading?
It is just easier I believe. Better than something like a JumpWithContext and JumpWithoutContext or have a bunch of names for the things. They all Jump, just use different data passed in
LOTS of APIs use overloading, not even just Unity. It just gives you flexibility while having a slightly shorter autocomplete list and manual
Ooh okay sounds good, I'm very much a beginner so ive been doing my best to avoid the beginner mistake of "spaghetti code" so I tried to find ways where I don't duplicate code but this seems to be the go to. Thanks!
Yeah, this often DOES mean some duplicated code.
Overloads can call each other though. So you can try to keep the parts that don't need CallbackContext in the no parameter Jump
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
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?
That I do not know. None of my personal games have cinematics lol. I hyperfocus on code too much hahaha
Fair enough, I was just thinking about how in games in dialogue you might see your character walk to some other point. I definitely need to learn to focus on the code part my brain turns to mush just trying to figure this stuff out. Thanks for your help though greatly appreciated
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?
Sounds like a corrupt Input Action Asset (which is actually just a scriptable object).
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.
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
The asset itself is actually just an implementation of ScriptableObject and the editor is just an EditorWindow utility that Unity officially authored to edit the file. It's built internally as a tree of nodes like any other asset, so if that action keeps showing up, I expect the editor probably isn't deleting the node.
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.
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
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()
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
Ah, so you don't have a "lost" Input Action, you just have an input that isn't triggering; am I understanding that?
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
Just to cover our bases, is the action enabled?
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
Sorry I had to run off to something else.
Yes, because as I've mentionned, I start the game from the Editor and do the exact same actions each time, and it works half the time
You should really share your code
We could talk for hours but without seeing the code it's hard to help
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
Sharing the code would take about 2 seconds
!code
Posting code
📃 Large Code Blocks
Use 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 format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
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.
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!
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
show your Event System inspector?
Also I believe v 1.5 is a bit outdated - see if your input system package can be updated
why DefaultInputActions2? Did you clone it?
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
Shouldn't be necessary to modify it
It didn't happen till i used this action map tho
which action map?
the defaultInputActions
you mean since you switched to the new input system?
i was trying with a custom one before and it was kiinda okay
I see
Can't update btw
Which unity version are you on
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
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.
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
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
these are the actions if anyone has any experience with this it would be hugely appreciated
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
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
i have found the issue... the other playerinput is not using keyboard. how do i manually add a device using input manager?
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
and for anyone curious this is the code I use for the gate https://hastebin.com/share/umoqedimod.bash
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
!code
Posting code
📃 Large Code Blocks
Use 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 format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
changed it
alright, I found the issue eventually by running the code in a different way, sorry for bothering y'all
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
Just as a small hint, you got a lot of code duplication in there, create functions for opening the door / playing the gatefail stuff and pass in which gate should play it
Otherwise you want to change something later and forget it on one of the doors and wonder why it doesnt work 😄
what was it?
I think I found a bug but holy hell it looks hellish to report it properly...
hi could anyone help me with why when i open vs with unity my victor2 isnt highlighting
!ide
💡 IDE Configuration
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code
• JetBrains Rider
• Other/None
Follow the setup guide
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?
usually this means you missed a step
you shouldn't be "trying all of them", just the one for the IDE you are using
Using PrimaryTouch.delta from an InputAction:
https://www.youtube.com/watch?v=GilvnvlXxCo
Equivalent use of Touch.delta from EnhancedTouch:
https://www.youtube.com/watch?v=Jg_KQVsrqyE
EDIT: Please ignore the performance in the editor. When I build the game, I get the same result but the game runs much smoother.
Where is this TouchControlBase thing coming from?
I don't see it anywhere in the docs for the input system
My understanding of EnhancedTouchSupport was that you generally read the delta in Update via https://docs.unity3d.com/Packages/com.unity.inputsystem@1.8/api/UnityEngine.InputSystem.EnhancedTouch.Touch.html#UnityEngine_InputSystem_EnhancedTouch_Touch_delta
It's an extension of MonoBehaviour that takes in a generic value type, which I use to attach to a control (which could be bool for a button), etc.
so is it something you wrote?
Yes.
I would guess the bug is somewhere in there
Can you show the code for that class too?
BTW for sharing code here:
!code
Posting code
📃 Large Code Blocks
Use 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 format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Sure, I'll use one of those.
It's unclear what's calling OnTouchMoved or where Finger is coming from here
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.
could you share it via a paste site
I can't download files on this computer (it's a work laptop)
cause none of them work
give me a minute as this is a bit to digest
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.
is that one of the steps?
still not working
no
the first 2 steps i followed
everything the same
btw is line 49 a typo?
inputDelta =Finger.currentTouch.
@blissful lotus
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!
is there like something i unchecked or sth?
did you do the last steps
Oh, I literally stopped typing there to copy to pastebin lol. Yeah.
inputDelta = Finger.currentTouch.delta; I'll edit the paste
all the last step show is this
im using vs 2022
@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.
where is that setting
which one
wait yea
I'm wondering if something with your logic isn't grabbing other Finger(s) or Touche(s) by accident
do you have the Visual Studio Editor package installed and up to date?
yea its up to date
oh fk me
you're looking at Visual Studio
thats vs
so just install the code converage and everything will work right?
they both already updated
oh is this needed?
no
follow the "If you are experiencing issues" steps here https://unity.huh.how/ide-configuration/visual-studio-configuration#if-you-are-experiencing-issues
yea did this part like alot of times
still not fix
is there a problem with here
It's not. I tested that explitly. What I can do to get a clean result is measure the initial position on touch first touch and then subtract that from the current position of the touch each frame instead of rely on delta, spin the character around like 5 times and then the result is very stable, exactly the same as using InputSystem without EnhancedTouch.
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.
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.
@austere grotto https://forum.unity.com/threads/touch-delta-switching-positive-negative.1051283/ Okay, I was able to determine that the result of delta is flipping to negative every now and then arbitrarily.
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.
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 ?
Likely, your button press is being passed along by the event system in your scene. Here is a screenshot of an EventSystem component which probably exists somewhere.
The question you should be asking is, how do you send messages to the event system in your scene? It's not really a problem related to the #🖱️┃input-system.
@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.
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.
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?
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
Can't really help without seeing details
How did you hook the input asset up to your code?
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
Have you done any debugging?
Put some log statements in here and make sure it's running
its running, the inputs are being pressed, i've tested it 😦 thats why im so stuck
How did you test it?
What debugging steps did you take
there is an on screen keyboard mapping highlight and i did the debug logs to see if the code is running
Ok so next debug the values coming in
And make sure they're making it to your character controller code
Should be pretty simple
anyone?
I wouldn't recommend using a pointer and a joystick binding on the same action
As you see they work quite differently
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
https://gdl.space/xawisireco.cs
can anyone please guide my why actions wont pick the saved jason
How can I detect when the player switches from keyboar to gamepad without PlayerInput component?
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.
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?
The UI input module is only for interacting with UI.
Use the normal input system approaches to read input outside that context.
whats difference between these:
Especially the ones that have # and number 
This is for unity new input system
Different touches
like multiple fingers ?
how can you differently touch screen on mobile 
I e. Second third fourth etc touch
Yes
Most touchscreens support multiple simultaneous touches
Independent touches
why does it start from 0 though ?
Most things in computing do
well I know that, so what your saying is that #0 means array slot 0 aka single touch whereas #1 is 2 touches ?
It's the second touch
Say you have a finger on the screen already
And touch it with a second finger
What are you trying to do
I want 2 random buttons to register any input for mobile is fine:
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
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>());
}
}
Don't you think you should share the error?
^
ohhh this part
Which is line 24?
the debug log
Looks like you don't have an action named "Movement"
have i named it the wrong thing?
I think you need to write "Player/Movement"
thats weird let me try
Why is that weird? Did you Read the docs for FindAction? It probably mentions that
im still geting the error
Did you assign the action asset to your PlayerInput component?
Did you save the code?
Did you save the input asset?
no i dont think so
im very new to this input system i think i watched a bad tutorial 😭
This is definitely an unorthodox way of using the PlayerInput component too
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!
https://gdl.space/xawisireco.cs
can anyone please guide my why actions wont pick the saved json in OnEnable
What do you mean by this? Index?
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
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..
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?
No you don't need it with PlayerInput. PlayerInput instantiates its own Input actions asset and enables the current action map on it.
thx
If a player was assigned a player root through the Multiplayer Event System is it possible for them to instead select global elements too?
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.
why do you need an RPC to do this? Do the clients not have authority over their own objects?
isn't this a pretty typical NetworkTransform kind of situation?
you may be right but Ive been tweaking it and been trying to find solutions
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 think I found the problem which is this https://forum.unity.com/threads/how-to-stop-animation-from-resetting-transform-after-animation-complete.1018729/
but I still havent found a solution to this in Unity 2022.3.7f1
!code
Posting code
📃 Large Code Blocks
Use 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 format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
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)
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)
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?
@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 :)
Where it poses problems (i.e. when the game starts), there aren't' really any special implementation.
There are just buttons and text inputs, and if the player touches anywhere, an exception is thrown.
I have those entries in my player controls, but I think they by default iirc.
Buttons? For buttons you should not need to configure any input actions I believe.
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...
Those are for mobile controls, but I believe the regular canvas buttons handle taps by default on all platforms?
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
oh, in that case I won't be able to help! Sorry!
I have not tried to do touch input yet with my Steam Deck
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.
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.
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?
You'd have to explain what you're expecting to happen and how you set things up such that you expect that thing to happen
I would like to be able to retrieve inputs from the PlayStation Move via the new input system. I tried by connecting the PS Move to my Mac and at this time it detects all the buttons and joysticks of the PS Move only when plugged in but not when the buttons are pressed.
You said it did. So back to this please
Only when I plug in the PS Move.
Why would you expect it to work when not plugged in?
Do you mean it works at first, then stops working after a bit of time?
All the buttons/joysticks of the PS Move are all detected at the same time only when plugged in and not when pressed.
I don't think Unity supports that controller
You'd have to find a plugin to support it probably
Yes, I just wanted to avoid going through another plugin, thank you for your help.
anyone found themselves in this situation before, the UI is on top of the "listen to button" button
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
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
}```
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
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
Maybe start with the starter assets FPS controller and look at how they do it?
But unless you did something weird you should be able to go diagonally pretty simply
I see, ty
Anyone had an issue where touch seems to only work on samsung devices and not anything else?
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;
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
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
Ah. Use if, not else if
That is your issue
4real? Let me test 😄
Else if will only be called if accelerateCar is false
If it's an if, it will be decoupled from that check
U are totally right. How did i not see this🥹
Thank you! Made my night 🙂
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
Ah... "the" website. Gotcha
Show some !code so we can take a look and help
Posting code
📃 Large Code Blocks
Use 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 format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
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
are all action maps enabled at once?
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
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
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
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?
Are you using your custom input actions asset in the input module?
or the default one
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.
click on your event system object
look at the inspector
check which one is assigned to the input module
im using the custom one I made yeah, now I see what you mean.

