#🖱️┃input-system
1 messages · Page 27 of 1
How are you receiving input in your scripts?
this is the part of the code that handles the movement
void Update()
{
Vector2 moveDirection = _moveActionToUse.action.ReadValue<Vector2>();
Debug.Log("Move Direction = " + moveDirection);
transform.Translate(moveDirection * 7 * Time.deltaTime);
That seems okay
[SerializeField] private InputActionReference _moveActionToUse;
initialized on top of the script
So you've got an on-screen joystick there?
yes\
I'd log moveDirection just to make sure the values are bad
I've never used the on-screen stick before, so I'm not sure what I'd poke at first
note that Collapse is on
so duplicate log entries will be hidden
that could be hiding a bunch of bogus values
Could you show the full script?
I would but it's over 1000 lines of code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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^
A tool for sharing your source code with the world!
note that the game was originally made for PC, now I'm just adding minor tweaks to make it ready for android
This doesn't really make any sense because it should mean you can't move at all - but I notice you're never doing:
_moveActionToUse.Enable();
I would expect to see that in e.g. OnEnable or Start
There's also this code:
public void OnMoveX(InputAction.CallbackContext ctxt)
{
if (dialog || Time.timeScale == 0)
{
// If in dialogue or game is paused, set movement to zero
MoveDir.x = 0;
}
else if (Time.timeScale > 0)
{
hasmoved = true;
// If not in dialogue and time is not paused, read input
Vector2 input = ctxt.ReadValue<Vector2>().normalized;
MoveDir.x = input.x;
}
}
public void OnMoveY(InputAction.CallbackContext ctxt)
{
if (dialog || Time.timeScale == 0)
{
// If in dialogue or game is paused, set movement to zero
MoveDir.y = 0;
}
else if (Time.timeScale > 0)
{
hasmoved = true;
// If not in dialogue and time is not paused, read input
Vector2 input = ctxt.ReadValue<Vector2>().normalized;
MoveDir.y = input.y;
}
}```
What's that about?
Seems like you have the remnants of some older movement code in here?
You need to enable the action
not the action reference
praetor was missing the .action field there
ok, it does no difference
oh yeah my bad - .action.Enable()
but yeah it doesn't make sense that would be the problem
I think I fixed it by borrowing the joystick from an older game, despite being with the old input system
ok now nothing works anymore
it only works when I put both here
but it gives me a warning when building for android
are you even using the new input system at all now?
Can you answer why there's seemingly this whole defunct older movement system in your script?
Namely this stuff: #🖱️┃input-system message
this is for the new input system, where I allocated keybinds for horizontal (OnMoveX) and vertical(OnMoveY) movements
Yeah why did you change that for the on screen stick though?
but now I can delete them as I have the PC project separately
because I want to port the game on android
So what?
The whole point is that you DON'T need to change anything with your input setup
you could have continued using your old code just fine
smartphones don't have keys?
the only thing you needed to change was to add the path for the on screen joystick to the input actions as bindings
You could even have had the on screen stick directly feed into the keyboard keys
and not changed anything at all
You see here - you could have just added the left stick bindings to MoveUp and MoveRight actions
and changed absolutely nothing else, and it would have worked
how would that work?
What do you mean? That's how it works
the on screen joystick pretends to be whatever control path you give it
the joystick controls a vector 2
Yes - and feeds it into a control path
show the inspector for your OnScreenStick component
moveUp and MoveRight correspond to the OnMoveX and Y
see how it says "left stick"
I'm aware
and that was working on keyboard right?
or on pc
yes
or whatever you have it set up with
all you had to do was add bindings to the MoveUp and MoveRight actions
to use the control that the stick feeds into
that's the point of on screen stick working this way - so you don't have to change anything
sorry, I still don't understand how
What part are you missing
ok
the stick feeds data into the "Left Stick [GamePad]" control
If you add a binding to your input action that reads from Left Stick [GamePad], it will read data from the on screen joystick therefore
you could have just created secondary bindings for MoveUp that read from Left Stick [Gamepad]
and it would have worked fine
You could have made composites just like you did for AD and WS to bind them e.g. to Left Stick[Gamepad] Left and Right and Up and Down
On screen stick -> Left Stick [Gamepad] -> your MoveUp action -> to the PlayerInput component -> to call OnMoveY
you mean here, instead of the keys, to just replace with the gamepad?
not even replace
click on MoveUp
add a new binding
and set up the Left Stick stuff
you can keep both
and that's it?
holy hell it actually works
thank you
now I feel dumb
it's usually like this, an extremely simple solution to a difficult problem
Eh - the input system can be confusing. But it's very flexible and pretty powerful as you can see - once you get the hang of it.
now I just need to figure out why the bounderies don't exist anymore
do you still have the input action reference code sitting around?
That should get removed.
commented
oh, so it really is that simple! I hadn't done an on-screen joystick before
that's how I imagined it working
just providing input for a binding
Yeah it's actually quite well designed
the one issue I have with it is that you need to map it to some existing control - for example keyboard keys or joystick sticks, rather than just creating e.g. a virtual control for it or something
there can be weirdness with that
Audio input (microphone frequency)
Hi, I'm having an issue with multiple ActionMaps being enabled at the same time when I don't want them to be. I'm a returning hobbyist and new to this InputSystem so I'm sure I'm just misunderstanding something but I've had no luck debugging this on my own or searching for related questions so far.
I have a very basic scene; camera, light, and some 3d objects. I have a PlayerInput component on my "player" object which references the InputActionsAsset that came with the Project. This came with two ActionMaps, Player and UI. I have added a 3rd called Throwing.
In a script that's also on my player object, I grab a reference to the PlayerInput component and log whether each ActionMap is enabled or not. I have done this in Awake(), Start(), and even Update() but every time all ActionMaps are enabled. If I grab the PlayerInput in Awake() and specifically disable the Throwing ActionMap, it will show as disabled in the Start() method. However, something is re-enabling it as I still get events from Actions defined in it.
For example if I remove all code references to the InputSystem from my scripts except for the following,
// Update is called once per frame
void Update()
{
if (_input == null)
{
_input = GetComponent<PlayerInput>();
Debug.Log($"CurrentActionMap {_input.currentActionMap}");
Debug.Log($"Player isEnabled {_input.actions.FindActionMap("Player").enabled}");
Debug.Log($"UI isEnabled {_input.actions.FindActionMap("UI").enabled}");
Debug.Log($"Throwing isEnabled {_input.actions.FindActionMap("Throwing").enabled}");
_input.actions.FindActionMap("Throwing").Disable();
Debug.Log($"Throwing isEnabled {_input.actions.FindActionMap("Throwing").enabled}");
_input.actions["Toggle"].performed += ProcessToggle;
}
}
void ProcessToggle(InputAction.CallbackContext ctx)
{
Debug.Log($"ProcessToggle Called, ActionMap.Throwing.enabled={ctx.action.actionMap.enabled}, ctx={ctx.ToString()}");
}
Then I still get the following logs
CurrentActionMap InputSystem_Actions (UnityEngine.InputSystem.InputActionAsset):Player
Player isEnabled True
UI isEnabled True
Throwing isEnabled True
Throwing isEnabled False
ProcessToggle Called, ActionMap.Throwing.enabled=True, ctx={ action=Throwing/Toggle[/Keyboard/tab] phase=Performed time=9.55633420000049 control=Key:/Keyboard/tab value=1 interaction= }
At this point I'm at a loss. My expectation was that only one ActionMap would be enabled at a time and that I could switch back and forth between them with PlayerInput.SwitchCurrentActionMap and I would not receive events or be able to read inputs for Actions defined in a disabled ActionMap. I have no other InputSystem related components on any GameObjects and in the current iteration the only code that touches the InputSystem is the snippet above. I've made sure to save everything, the scene, the InputActionAsset, my code, etc so nothing should be stale. I'm not sure what I'm missing, any advice?
Show your PlayerInput inspector settings?
sure, one sec
The only things I've touched on this was passing in the InputActionAsset and disabling autoswitch in an attempt to debug the issue
Just to follow up on my issue above, I tried creating a new InputActionAsset with two ActionMaps and a single Action in each. Disabled my existing Player, created a fresh GameObject, added a PlayerInput component, linked this new InputActionAsset, and added a new Script which is the same as my Snippet above except I register a callback for each of the two Actions across the two ActionMaps and I didn't call Disable on the map.
After all that, it works as expected. Only the ActionMap marked as Default in the PlayerInput component was enabled and only inputs from the enabled ActionMap were firing events.
I then linked my initial InputActionAsset from earlier to this test script and updated the map/action names but otherwise changed nothing else and I was able to reproduce the issue.
So it seems like whatever is causing all ActionMaps to be enabled is specific to this InputActionAsset, tho I have no idea what it is. But I'm unblocked for now at least
Is it assigned as your project-wide action asset? I bet all of its maps get turned on automatically
That's in the input system section of your project settings
Ah that sounds plausible. I'll check when I'm back home. Thanks for the suggestion
is there a way for player to edit keybinds ingame with the input system?
That was it by the way, thanks!
Yes the new input system supports runtime rebinding
hey, thanks :)
I am trying to setup a Dodge Input that would work by Double Tapping the Direction you want to dodge in. I can set up a double tap if the type is button, but this case would be Vector2, so i can't so the same. is there another way, or am i just missing something?
what about controller input?
are you asking me? if so, i am not terribly worried about controllers ATM
Seems like you need a timer that starts when the input is cancelled. If on second input, the timer does not exceed whatever buffer time you set then dash and cancel the timer. Otherwise just cancel the timer.
shoot. ok, thanks. i was hoping there would be a built in way, like the button double tap, but that will work
None I'm aware of but maybe someone more knowledgeable will correct us
good morning, learning everything about the new input system, long time wainting for this... i have something working, keyboard, gamepad, touch etc... why i should create a scheme ? its recommended? or only for games with alof of inputs?
right now for example my supports on screen touch joystick and also gamepad, when i create gamepad schemecontrol my inputs from keyboard are not longer working also if i made a build touch joystick either, so i have to change the activated control scheme?
Schemes are really only useful if you're doing local multiplayer in my opinion
Hello friends!
I'm using Input system v1.11.2
Whenever I try to add a device, I get the error: StackOverflowException
Looking at the call stack I see the repeated function call is named InsertControlBitRangeNode, deep within the internals of the Input System. None of this seems to be my code
The documentation does not help me solve this issue - all that I can find is that it appears this bug was fixed.... in 1.5 or so, something like 6 versions ago
it goes on and on and on. How can I fix this? 🙂
None of my code seems to be involved, it comes from NativeInputSystem:NotifyDeviceDiscovered so it seems like that's Unity all the way
Hey guys,
I wanted to ask for some ideas/suggestions regarding how to design the following input system:
I have a lot of player characters.
They all share some common input actions like movement, jump etc.
But each character also has unique abilities.
Now I need a system, where it's possible to customize the key bindings of the general input actions for every character.
But at the same time it should be possible to customize the input actions (general and unique abilities) for every single character if youd like.
How would you design the InputActions asset for this use case etc.?
Thank you
I have something similar in my game: each character's "abilities" are entirely provided by the modules attached to them.
I tried to cluster them into groups, like "use" or "hurt", but I wound up with tons of confusing overlap anyway
right now I'm band-aid fixing this with a radial menu to pick an ability
ok here's a dumb question, how on earth do you delete a binding or action in the Input Action Editor?? I'm trying to delete this second E [Keyboard] binding but right clicking it or pressing delete isn't doing anything.
hmm, seems like I had to run the below in code. Seems a bit strange but worked
GetComponent<PlayerInput>().actions["Mouse_RightSpecial"].ChangeBinding(1).Erase();
i would restart the editor if it was misbehaving like that
Or you could try scolding it.
i do yell at my computer from time to time
there's 2 number keys on keyboards. according to the scripting docs they're digit[N] for the numrow and numpad[N] for the numpad
maybe try those? ie, <Keyboard>/digit1, etc
Well, there is one problem, and it's that the function doesn't get called entirely, but it may just be that. I'll try that out and see how it goes
oh SwapWeapons isn't called at all?
have you tried using the input debugger to see if the input is registering?
one sec i don't remember where exactly it is
there should be a button "open input debugger" at the bottom of PlayerInput
Right. Thanks!
also this is incorrect; properties can't begin with numbers, so numrow properties are prefixed with digit, but in the paths they're just numbers directly. your existing paths are correct
0 = numrow, numpad0 = numpad
So it was showing up...
Okay, I found the solution. Thank you for helping me out!
hi everyone - Can somebody help me to get xr input to work with the new input system? - When I put on my headset (quest2) I can see in the inputs chaning in the "Open Input Debugger" Window! ( i see there that isGripPressed switched to 1 when fully pressing the grip) and so on.
But any actions I assign any of the XR stuff to are not triggered ever. (If I assign keys they trigger no problem).
My scene has the XR Interaction Manager added and a "XR Origin (VR)" - I can look around my scene no problem.
See Image, all the bindings I added do not work - except for mouse and keyboard. (none have checkmarks for a control sceme). Default Scheme is set to any on the Player Input.
Left click works fine on my mouse but only seems to trigger like 1/10 times on my laptop's touchpad left click
What's the right binding or setting for this to work accurately?
How are you handling input in your code?
Also what - if any - processors or interactions are on the Interact action?
Nothing set like that
I haven't had issues getting left click to resister on my laptop regularly either btw
[SerializeField] PlayerTrigger playerTrigger;
[SerializeField] TrashPicker trashPicker;
public void OnInteract(InputAction.CallbackContext context) {
if (context.performed) {
//oldPlayerTrigger.SphCast();
playerTrigger.TriggeredInteractable();
trashPicker.TrashInteract();
}
}
Just for fun can you add this as the first line of code in OnInteract (before the if statement)?:
Debug.Log($"OnInteract called in phase {context.phase}");```
this would help us make sure it's actually an input system problem and not a problem in the other code being invoked here
The debug messages actually stop triggering when I'm using WASD movement + touchpad left click, maybe it is hardware
Enabling "Auto-Switch" helps - but why? My Default Scheme is XR and the Inputs from XR are marked as XR. Yet they do not work without autoswitch. 😦
probably a control scheme thing
Hi, I'm trying to create a simple extension to the default Button, where holding it re-sends the OnClick event every x seconds. Detecting holding the button with a mouse is easy thanks to the IPointerUpHandler, but I can't for the love of god mirror that behavior for keyboard button button presses. There's only the ISubmitHandler, and ICancel and IDrop handlers arent it.
Is there a way to detect the "un-pressing" of the submit button similar to IPointerUpHandler?
I guess I could check each frame if the button used in OnSubmit is still pressed, somehow?
You could define it as a custom message:
https://docs.unity3d.com/Packages/com.unity.ugui@3.0/manual/MessagingSystem.html#defining-a-custom-message
then basically have a script that is listening for that key being released and sending the message
I hear you, the tricky part right now is getting to the current inputsystem's UI action map (???) to get the assigned button to listen to it, unless it's simpler than that
I need to somehow query for a specific key based on the action and I dont want it to be that hard-coded
I'm trying really hard to connect the dots here but I still don't quite see it. Does this mean that there should be some static-level access Submit keybind variable, that I could query?
Or you mean I could somehow create an additional interface, opposite of ISubmitHandler (IUnsubmitHandler?) that would do exactly what it says
The latest link I sent is a property on the InputSystemUIInputModule that you can read to get an InputActionReference that you can subscribe to
i.e. myInputModule.submit.action.canceled += MyCanceledListener;
This part is possible using the defining a custom message thing and then firing the custom message in the MyCanceledListener e.g. from the example above
but you don't need to necessarily do it that way
as it's a little overcomplicated/overkill I think
ahh, but I would still need to find a reference to the module in the scene, no way to get it statically
EventSystem.current.GetComponent<InputSystemUIInputModule>()
the current input module is available from EventSystem.currentInputModule; you'd need to downcast it to the specific type, of course
ok I think I cooked now
((InputSystemUIInputModule)EventSystem.current.currentInputModule).submit.action.performed+=<eventhere>
you want .canceled though
since you want when it's released
I mean yeah, but the idea is here
Thank you, I did not expect it to actually work lmao
oh and it does and it does perfectly well, very nice thanks again all
First time going from PlayerInput SendMessages mode to generated c# class.. How would you guys organize your input classes / send actions?
I was thinking singleton to this class with the action map asset then other scripts can sub to whatever events they need, maybe class can just handle all the events but then I feel like I'm just rewriting what the action asset does already..
I just added all 3 actions as test but might need scripts where they need either canceled or started/performed.
I'd appreciate any Input :p ..
public class PlayerInputsProcessor : MonoBehaviour
{
//my c# class generated from inputaction asset
private InputSystem_Actions actions;
private void Awake()
{
actions = new();
}
private void OnEnable()
{
actions.Enable();
actions.Player.Attack.started += OnAttackStarted;
actions.Player.Attack.performed += OnAttackPerformed;
actions.Player.Attack.canceled += OnAttackCanceled;
}```
Basically just a really dumb "instance holder" kind of singleton usually
Like you said you don't want to duplicate what the action asset already does
just providing central management and access to the instance is all you really need
And it's best to only have one instance so that rebinding and action map enabling/disabling works globally
okay good this clears up some confusion, I appreciate it !
HI, I need help
I have several types of input for my game: mouse click, spacebar, and touch screen for mobile devices. However, the issue is that my game now has UI buttons (like login, logout, and others), and I’m trying to find a way to prevent clicks on these buttons from triggering the game itself.
I found this solution everywhere:
EventSystem.current.IsPointerOverGameObject()
But the problem is that it breaks my game. I have a big tuto texte in the middle of the screen that says “Press Space or Tap the Screen”, and clicking on it prevents the game from triggering.
Do you have any ideas on how to solve this?
Thanks!
Change your code to use the event system for the ingame clicking stuff and you will get this behavior for free
Actually for that one specific problem you can just disable "Raycast Target" on your big text thing
But the overall recommended would be to switch to the event system for all your clicking as stuff
Hi, I just added the new input systems on Unity with following the quick start on the website of Unity.
The function they give to get the action is InputSystem.actions.FindAction(). But, is there not a better function to give also the action map where is the action we want to get ? Because, with the function they give, the system need to browse all the actions maps to find 1 action
InvalidOperationException: Action 'UI/Cancel[/Keyboard/escape]' must be part of an InputActionAsset in order to be able to create an InputActionReference for it
Any clue why this error is triggering? I believe this started after updating unity from 2023 OR switching to linux.
Im having a very similar problem... the properties page is empty so I cannot configure bindings and I get this error every time I click it:
Ok looks like the bug is caused by having vjoy installed.. makes the package unusable
Uninstalling vjoy and restarting fixed it
What are you doing that's triggering that
You also seem to be using a pretty old version of the input system
Well it triggers once on start and once every timme each menu is opened
You need to double check and or reset your input module
Well I noticed that it was not set on project settings so I fixed that
but it still happens
How can I reset the module?
I eventually realized that (after dealing with another bug in the package), however ironically updating to the latest version of the package introduced another bug, eventually I found a goldilocks version that appears to be mostly bug free
I can't interact with this UI with my mouse anymore, however they keyboard still works
Hey, so in the Unity Input System, mouse movement is inherently frame-based (reset each frame), while controller input provides a time-independent vector (e.g., thumbstick position). Since the Input System bundles mouse and controller inputs together by default, how can I scale controller input by deltaTime without affecting mouse input? Is there a reason Unity bundles them, and should I separate the inputs instead?
You could read absolute stick positions and synthesize your own delta time & delta position for them
I wonder why they are bundled together in the input system by default.
Since they are fundamentally incompatible.
Ease of use in 99% of use cases
You can control input systems input poll rate entirely independent of frame updates btw
How would that look here?
private void Update()
{
CameraMovement();
}
private void CameraMovement()
{
Vector2 lookInput = InputManager.Look() * LookAroundSpeed;
// Rotate player when looking left or right
transform.Rotate(Vector3.up, lookInput.x);
// Rotate camera when looking up and down while clamping the camera to not allow full rotation
_verticalRotation -= lookInput.y;
_verticalRotation = Mathf.Clamp(_verticalRotation, -maxVerticalAngle, maxVerticalAngle);
_playerCamera.transform.localEulerAngles = new Vector3(_verticalRotation, 0f, 0f);
}
I guess I'll just separate the systems. Pretty weird that they're bundled by default, but oh well.
How can I change the starter asset control of my third person character to aligned with the camera, like W goes up, E goes down, etc., and stop rotating the player with the mouse?
!ask
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #854851968446365696
I'm trying to make a custom wrapper around the input manager. Is the input manager meant to be used as a singleton waiting for events on each component that needs it? Im a bit lost on this part
InputManager is a legacy feature, what are you trying to do?
InputSystem sorry
Could you get into a little more detail and specifics? It's not clear what you're asking.
I was wandering if the InputSystem is meant to be used by first define action maps. Then have them handled by like a singleton InputManager gameobject to be used everywhere in the game or if there are better ways to make a flexible "wrapper" around it
The input system is very flexible and can be used in many different ways.
Hey so uum, I wanted to abstract a minigame system to make each minigame a seperate scene, loaded at some great distance from the main scene/level, and rendered into a raw image inside a special panel. Got the rendering alright, even keyboard input works with the setSelectedGameObject.... but....
Mouse events are not properly registered, as the minigame sub-canvas is rendered in a completely different place and put through the RendererTexture. Any ideas on how I could easily have pointer events transfered via that render texture? Or perhaps I could "capture" those events and translate them through the offset to the actual minigame-scene
Why does the game have to be far away and using RenderTexture?
Why not just use culling masks?
cause so far if I do not offset it it is influecned by the dark overlay of the "default" level scene and some of the elements are rendered over it still
as in like that
I don't really know what I'm looking at tbh
this probably has to do with playing with the stencil shader, so it can somehow ignore the default order with UI rendered last
like I want each minigame to be a seperate scene, with its own canvas and a simple camera to render into a texture
to be used to fill this blank space when u interact with some object for example
thing is I need a seperate camera just for creating the rendertexture, and a simple texture cant really react to mouse input events, so that's where the problem is currently. If I could somehow capture the global position of a mouse down/up I could offset it by the constant of that rendering camera to perhaps re-enact them... not sure if that's even possible though
and yes, I kind-of need it to not cover the entire screen, and the game is not paused in the background while it is opened, so two cameras is a must
this isn't really an input system question. More #📲┃ui-ux and you're not the first person to do something like this
well that's comforting, thanks!
And then when you have the localPoint you can use that in Camer.ViewportPointToRay for the secondary camera
you need to get a very firm grasp on what your coordinate spaces are
ideally, you'll just move between them using Transform methods or by directly constructing a Matrix4x4
no method that involves things like "add an offset" or "switch X and Y around" will work reliably
Sorry if this has been asked before, I tried searching using the search tool but couldn't find anything. I'm having an odd issue with my input module not working after a scene change. I have my EventSystem component on a DontDestroyOnLoad object, and opted to use my custom handling, so I've removed the default input module. Is this a bug?
disabling and enabling the input module fixes it, but I'm not sure where I should be implementing that. OnSceneLoaded seems to be entirely hit or miss.
Is there a good reason you are using your own input asset for the inputmodule?
Presumably some other code of yours is disabling it or something along those lines
to be used with my custom UI navigation system. I didn't like Unity's default transitioning scheme. Primarily for better controller support
I'll make a new project right now and see if it happens, 10 min
hmm can't seem to replicate it
im curious if it has to do something with how this network library im using is handling scene transitions
cause the action map just straight up disables every time a scene change happens
What other code do you have related to the action maps/actions asset?
Is the actions asset managed from a DDOL object too? What's managing it?
its on a DDOL object yeah, Im 90% sure this is related to the network library at this point
im speaking to the dev rn and he said there was a scene loading issue a couple months back and to try latest update
turns out it was related tot that
essentially it was unload scene A, load scene B, then a bug would cause it to Load scene A, Unload scene A
causing weird behaviour internally, latest pull everything works how you'd expect it
Hey guys! I have a peculiar problem. Anyone with experience with the new input system?
My problem is that two buttons triggers the same trigger even though they are mapped to two different buttons. I have checked my code, and as far as I can see, all events are separated to their respected button, but these two still trigger each other for some reason. 🤔 I am testing it with a controller.
The way I have set up the system is that I have a script that sees all inputs, and triggers respected events in my game brain(Game manager.) that other methods can subscribe too. As you see there is nothing here triggering the event except for the button I have linked with it. Still both the select button and the throw button gets called when I press one of them
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
anyways, have you tried debugging the input to make sure the buttons aren't triggering when they aren't supposed to?
Sry! New to posting here, will try to keep it in mind 😅
Well yes! It has never been a problem before, but now they both trigger
I only pressed one button once here
ah, no, with the input debugger
What's inside these methods @teal sapphire ?
it's a button at the bottom of PlayerInput
Only a event '''public void TriggerSelectPressed() { selectPressed?.Invoke(); }'''
Oh no, I haven't tried that, didn't know that was a thing tbh
ok... and that event does what? What subscribers are attached to it?
let's shortcut this and show/explain the whole chain of events here
So different actions that I want to use the button for. There are a handful of methods. I have gone trough them however and none of them trigger the other buttons. Gimme some minutes and I will try to check one more time to see if there is anything notable
Just show the ones that print those messages you showed
and where you subscribe them
{
print("Select was performed from inputs");
gameBrain.TriggerSelectPressed();
}
private void ThrowPerformed(InputAction.CallbackContext obj)
{
print("Throw was performed from inputs");
gameBrain.TriggerThrowPressed();
}
``` This is where they are written, they are subscribed to the input system like so
``` private void OnEnable()
{
controls.Player.Select.performed += SelectPerformed;
controls.Player.Select.canceled += SelectCanseled;
controls.Player.Throw.performed += ThrowPerformed;
controls.Player.Throw.canceled += ThrowCanceled;
controls.Player.MoveSelectorRight.performed += RightTriggerPerformed;
controls.Player.MoveSelectorRight.canceled += RightTriggerCanceled;
controls.Player.MoveSelectorLeft.performed += LeftTriggerPerformed;
controls.Player.MoveSelectorLeft.canceled += LeftTriggerCanceled;
controls.Player.SelectTwo.performed += NorthButtonPerformed;
controls.Player.SelectTwo.canceled += NorthButtonCanceled;
controls.Player.MenuUp.performed += menuUpPerformed;
controls.Player.MenuUp.canceled += menuUpCanceled;
controls.Player.MenuDown.performed += menuDownPerformed;
controls.Player.MenuDown.canceled += menuDownCanceled;
controls.Player.QuitTurn.performed += westButtonPerformed;
controls.Player.QuitTurn.canceled += westButtonCanceled;
controls.Player.Select.Enable();
controls.Player.Throw.Enable();
controls.Player.Movement.Enable();
controls.Player.MoveSelectorRight.Enable();
controls.Player.MoveSelectorLeft.Enable();
controls.Player.SelectTwo.Enable();
controls.Player.MenuUp.Enable();
controls.Player.MenuDown.Enable();
controls.Player.QuitTurn.Enable();
controls.Enable();
}```
yeah I know that
we're past this part
I want to know what happens in these
which you answered here
and then I wanted to know about the subscribers to those events
and where they are registered
Ok, so just to get accouple of things clear, this is a older project and I'm in the process of redesigning and cleaning up a lot of systems, many of these methods are not used atm, and the scripts calling them are not active in the scene. I can try to find post the relevant scripts I guess. But i will try to debug the inputs firstly just to see if the problem lies there.
I guess actually these are where the debug logs come from
SO maybe do a similar analysis for SelectPerformed and ThrowPerformed
Ok, so I tested it with another D-Pad, and the problem disappeared, so hardware was at fault I guess 🤷♂️
well trying the input debugger wouldve told you that
Yepp! And that was what worked! Thank you 😆 I now know how to use it
The thing is, (It seems like it at least) One of my controllers registered both as a nintendo controller and a xbox controller, where the positioning of the buttons are registered at two different places for some reason, and therefore triggering the same action at two different button clicks?? If that makes sense
that's terrifying
Yeah! It was a lower model 8BitDo, in case anyone else runs into this. Also, my other controler is also a 8BitDo, but with 2.4G and it works just fine
i printed Input.touches.Length and its 0 . if i build that for phone it doesent work too
it dont get and touches
could you convert to mp4 so it embeds in discord
how
any ideas why both player and ui actions work even though only player is set to enabled by default?
I even switch to player action map, still x key from ui map works
for some reason removing my input asset from project-wide Actions (Edit > Project Settings > Input System Package) fixed the problem
Hello, I am using Unity 2022.3.41 and the New Input System. Controller support works fine on all platforms, including SteamDeck, except for one specific issue: the D-Pad does not work at all on SteamDeck. All other controls work fine.
I have Steamworks .NET set up with the correct app ID. In Steamworks → Application → Steam Input, I set the Default Configuration to Generic Gamepad. Has anyone else encountered this issue and know how to fix it?
Someone got back to me and had experienced the same issue. Changing the action type for ‘Navigate’ from Pass-Through to Value fixed it. I don't know why, but it worked. Just replying in case others encounter the same issue.
any chance someone here knows a solution to this?
tl&dr: the error message This will cause a leak and performance issues, InputSystem.UI.Disable() has not been called. keep showing up in editor
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
can anyone help me ral quick with a little problem with the player input behavior
i got the bahavior on send messages and everything works fine with movement but my own implemented input function gives out that it wasnt found but it does what it should so very weird. when i change it to invoke unity events my implemented actions work but no movement(im trying to add controller inputs in general and switch the input.... code into the input system)
any kind of help helps :)
i got the bahavior on send messages and everything works fine with movement but my own implemented input function gives out that it wasnt found but it does what it should so very weird
Can you be more clear
What are you talking about here?
Are you getting some kind of error message in the console?
Can you share the actual full error?
yes thank you
i have it on send messages because its the first person start 3d thing from Unity to start a 3d game. i added my own little force mechanic to control a ball and it works with the right trigger on controller and left mouse button per script. but when i press it on controller i get this error MissingMethodException: Method 'InfiniteRebound.OnThrow' not found.
System.RuntimeType.InvokeMember (System.String name, System.Reflection.BindingFlags bindingFlags, System.Reflection.Binder binder, System.Object target, System.Object[] providedArgs, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParams) (at <20a025bba6874f73adca28fec451f638>:0)
UnityEngine.SetupCoroutine.InvokeMember (System.Object behaviour, System.String name, System.Object variable) (at <5a87366a6dc74b3aa0e0421cf80e3ae5>:0)
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)
basically method not found
but it works xD
like it does what in onThrow i wrote but the error is given out and i dont like errors and i wann know what is going on there :)
Show your code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
cs private PlayerInput _input; // Reference to PlayerInput component
private void Awake()
{
// Get the PlayerInput component
_input = GetComponent<PlayerInput>();
}
private void OnEnable()
{
// Subscribe to the Throw and ResetBall actions correctly
if (_input != null)
{
_input.actions["Throw"].performed += OnThrow;
_input.actions["ResetBall"].performed += OnResetBall;
}
}
private void OnDisable()
{
// Unsubscribe to avoid memory leaks
if (_input != null)
{
_input.actions["Throw"].performed -= OnThrow;
_input.actions["ResetBall"].performed -= OnResetBall;
}
}
// This method is called when the "Throw" action is triggered
public void OnThrow(InputAction.CallbackContext context)
{
ThrowController();
}
public void OnResetBall(InputAction.CallbackContext context)
{
Debug.Log("HELLLOOIMUNDERHEWATER");
ResetBall();
} ```cs
``` not '''
o im sory
public void OnThrow(InputAction.CallbackContext context)
{
ThrowController();
}```
you are using the wrong parameter type here
If you're using SendMessages mode the parameter should be InputValue
not CallbackContext
Same for your OnResetBall method
ok lemme try that...
Are you sure you're using SendMessages mode?
Ok so
private void OnEnable()
{
// Subscribe to the Throw and ResetBall actions correctly
if (_input != null)
{
_input.actions["Throw"].performed += OnThrow;
_input.actions["ResetBall"].performed += OnResetBall;
}
}
private void OnDisable()
{
// Unsubscribe to avoid memory leaks
if (_input != null)
{
_input.actions["Throw"].performed -= OnThrow;
_input.actions["ResetBall"].performed -= OnResetBall;
}
}```
[{
"resource": "/D:/Cube Smash/Assets/Scripts/Infinite Rebound.cs",
"owner": "DocumentCompilerSemantic",
"code": {
"value": "CS0123",
"target": {
"$mid": 1,
"path": "/query/roslyn.query",
"scheme": "https",
"authority": "msdn.microsoft.com",
"query": "appId=roslyn&k=k(CS0123)"
}
},
"severity": 8,
"message": "No overload for 'OnThrow' matches delegate 'Action<InputAction.CallbackContext>'",
"startLineNumber": 38,
"startColumn": 4,
"endLineNumber": 38,
"endColumn": 48
}]
I just saw this
basically you are confused
you are mixing up two different things
The OnEnable and OnDisable code you have is manually subscribing those functions to the actions
so you're not actually using the SendMessages feature at all
i dont know man
You should revert the code to how it was and change the mode to "Invoke C# events" or "Invoke Unity Events"
im using it in the different script with the movement
and leave it alone
Yeah you're just - you're confused and mixing two different things up
you're not actually using the SendMessages stuff
so turn it off
i do
trust me, you are not using it
Revert the code and change the mode
it will be good that way
cs cs
but then i cant move the player xD
when i change it
im using it in this script
Ok so - then your problem is that the starter assets code IS using SendMessages
but you added your own code which is using a different approahc
yeeeeeees
You need to change your code to actually use SendMessages then - by switching to InputValue parameters like I said before, and getting rid of all that code in OnEnable and OnDisable that subscribes to events
just like this ```cs private PlayerInput _input; // Reference to PlayerInput component
private void Awake()
{
// Get the PlayerInput component
_input = GetComponent<PlayerInput>();
}
// This method is called when the "Throw" action is triggered
public void OnThrow(InputValue value)
{
ThrowController();
}
public void OnResetBall(InputValue value)
{
Debug.Log("HELLLOOIMUNDERHEWATER");
ResetBall();
} ```
OMGGGGGGGGGGGGGGGGGGGGGG
IT WORKS
YESSSSSSSS
probably like:
public void OnResetBall(InputValue value)
{
if (value.isPressed) {
Debug.Log("HELLLOOIMUNDERHEWATER");
ResetBall();
}
} ```
SITTING AT THIS FOR 5hours
ok
btw ignore the debug thats driving me insane so im getting creative by implementing memes to check things hahahah xD
thank you so much @austere grotto
cs ```private PlayerInput _input; // Reference to PlayerInput component
private void Awake()
{
// Get the PlayerInput component
_input = GetComponent<PlayerInput>();
}
// This method is called when the "Throw" action is triggered
public void OnThrow(InputValue value)
{
if (value.isPressed)
{
ThrowController();
}
}
public void OnResetBall(InputValue value)
{
if (value.isPressed)
{
Debug.Log("HELLLOOIMUNDERHEWATER");
ResetBall();
}
} ```cs
thats howq it works
cool :)
(the cs goes inside the codeblock, like so)
ok thanks
I am having problems with this. I thought adding the multitap interaction would make it so it only triggers when double tapping. But it's doing the leap even when I only press the button once
When I use performed as a condition it always returns 0 for some reason
- should be performed not started
- multitap interaction doesn't really work with an axis control afaik
Only buttons really
You may have to write the logic yourself
Oh, I see
When I use performed it always returns 0 so the leap doesn't go either way. Like it receives the input on the started phase but not on the performed phase
Yeah, I will need to write the logic myself
Thanks
Yeah because the interaction was not designed for axis
I am trying to fix this thing. Because when I hold the left button and then press the right button 2 times while the left button is still pressed it jumps to the left. Any ideas on why that happens?
How can I make the camera rotate along with the character using the A and D keys? I'm using the third person character from the starter asset.
Anyone know why this doesn't work? I clicked with my mouse click, and it somehow didn't call. I already ensured that the problem was not with my code, because I attached another binding for this action (which was my F key), and it worked.
Input.GetMouseButton(0) works, and when I checked it on my Input debugger, it was indeed registering my left clicks.
Is there something wrong with my input system? Is "Left Button [Mouse]" not the left click?
seems like it should have worked. perhaps it is in the code
or maybe you have to select a control scheme that it is used in
did your F test have a Scheme selected @glass ginkgo ?
Scheme?
Oh, I'm using the Keyboard control scheme
Like this?
I selected it, and it didn't work either
ok. i am out of ideas then. i do not have a lot of experience with it. just started a tutorial on it
There are two mice here. What do I do?
@vagrant panther it worked flawlessly. Thank you man
you're welcome 🙂 +1 for guesses! 😁
Hehehe, I spent hours on that
Ouch
Heya, quick question regarding the "new" input system:
I'm making a car game, and want to have an input for accelrating. Simple enough.
However, I want to have input options for both gamepad and keyboard.
I already worked with the input system once, but only for a game that was only playable with a controller.
So, now that I want to utilize both keyboard and controller input, I have two questions:
- If I get the input like in the first attached image, can I still read how far down the controller trigger is pressed?
- If I want to get a value of the input of the left stick of the controller, would I also be able to put the keyboard input bindings in the same action? If so, how? (If I want A to be -1 and D to be 1)
- Yes
- Yes with a composite binding
Make sure the action type is value and the control type is axis
Which is what you have in your screenshot 👍🏻
Thanks! I'll look up what a composite binding is. 👍
I am trying to execute 2 different methods for a hold action. I bound one to canceled and one to performed
- when I tap the button the method for
canceledshould be called (works) - when I hold the button long enough it should call the method bound to
performed(works partially)
The weird thing is that, even thoughperformedgets called, thecanceledmethod gets called too (after I release the key). Why is that? Is that how it's supposed to work or is my setup faulty?
that's how it's supposed to work, apparently
i mean that kinda makes sense; how else would you know how long it's held?
I thought it's just performed if it held long enough (successful) and if it's not held long enough it's canceled. Makes a lot more sense to me
I read in some discussion that that was the first approach. It, however, changed and now canceled is always triggered, regardless if performed was triggered
Ok, how am I supposed to add that logic so that I have one method bound when the hold time was long enough (without calling the canceled)?
i mean this problem is here
how else would you know how long it's held?
which couldve been solved by adding another callback, but then that doesn't really make sense for everything
I guess I add a check in the canceled if the duration was > then the threshold?
im not sure what the elegant/intended way would be
hm... I'm looking at some comments and SlowTap might work somehow. I'll experiment. Thanks for the diagram
I'm making a simple look around script with the input system using the normal Look action (Delta pointer). I update the x with the following script;
private void Start()
{
lookAction = InputSystem.actions.FindAction("Look");
}
void Update()
{
Vector2 mouseDelta = 10f * Time.deltaTime * lookAction.ReadValue<Vector2>();
playerBody.Rotate(Vector3.up * mouseDelta.x, Space.World);
}
``` However, when I run this script the screen first follows the mouse like it should but also tries to go back to the original rotation immediately. What am I doing/using wrong?
weird, Hold is only documented to call cancelled if the duration wasn't reached.
maybe that's additive to the default interaction? no clue
Not sure because my brain isn't mathing right now, but what if you add a check to only execute those 2 lines when the value is != 0?
That's what I thought as well. I replaced the Hold with a Slow Tap without actually changing the logic and now it works like that
- button not held long enough -> canceled
- button held long enough -> on button release the performed gets called
Moving seems more smooth but it still goes back to the original rotation
Hm... sounds to me like it isn't your input then. You using cinemachine or something? what if you comment out the lines and manually change the rotation while playing? If it then still returns to the default rotation it must be something else
what's going on with Axis 4 and 5? Why would Joystick 2 Right and Down share the same axis as the triggers instead of being their own axis?
oh, they're not doing double duty, J2 U/D is just bound to random other axes?
are they perhaps the triggers? for example R2/L2 on playstation, those are analog
oh, Joystick 2 is actually a third joystick
there's a Joystick 0 😂
whoopsie. All clear now.
all the "right stick left" vs. "left stick right" may have broken my brain a bit
how can I make a local coop on 1 keyboard, but with different inputs? For example, I need the 1st player to control with WASD, and the 2nd player to control with arrows
recently i was trying to make a dynamic on screen joystick( the joystick will move to the touch position and when touch will be lifted, joystick will be disabled)...now i am using the new input system. The problem is, now when i touch the screen, the joystick moves there and works fine, but if i touch with another finger anywhere else on the screen, and then lift my first finger(which was controlling the joystick), the joystick still stays at the position of the first touch....what's wrong here?
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.
how can i fix the virtual mouse im using player input manager to spawn the cursor prefab but they both move at the same direction
I mean what are we looking at in this video? Did you duplicate it with ctrl+D?
hi guys
if i have a click to destroy function on a clickable object....button or othervise
i get 200 of these bad boys
MissingReferenceException: The object of type 'UnityEngine.GameObject' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Object+MarshalledUnityObject.TryThrowEditorNullExceptionObject (UnityEngine.Object unityObj, System.String parameterName) (at /home/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnityEngineObject.bindings.cs:815)
UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException (System.Object obj) (at /home/bokken/build/output/unity/unity/Runtime/Export/Scripting/BindingsHelpers.cs:61)
UnityEngine.GameObject.get_transform () (at <70925de717734fab9f0593c446e74c55>:0)
UnityEngine.InputSystem.UI.InputSystemUIInputModule.ProcessPointerMovement (UnityEngine.InputSystem.UI.ExtendedPointerEventData eventData, UnityEngine.GameObject currentPointerTarget) (at ./Library/PackageCache/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs:476)
UnityEngine.InputSystem.UI.InputSystemUIInputModule.ProcessPointerMovement (UnityEngine.InputSystem.UI.PointerModel& pointer, UnityEngine.InputSystem.UI.ExtendedPointerEventData eventData) (at ./Library/PackageCache/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs:402)
UnityEngine.InputSystem.UI.InputSystemUIInputModule.ProcessPointer (UnityEngine.InputSystem.UI.PointerModel& state) (at ./Library/PackageCache/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs:352)
UnityEngine.InputSystem.UI.InputSystemUIInputModule.Process () (at ./Library/PackageCache/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs:2257)
UnityEngine.EventSystems.EventSystem.Update () (at ./Library/PackageCache/com.unity.ugui/Runtime/UGUI/EventSystem/EventSystem.cs:530)
use backticks, not quotes, for a codeblock: !code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
Looks like you bound your button listener to a function or poperty on an object that gets destroyed.
You'd have to show how you set things up
i didnt even bound it to anything
ui element has a
public void OnPointerClick(PointerEventData eventData)
{
}
on it thats it
Doesn't seem relevant to your problem
What exactly is happening that triggers the error? It's just happening each frame?
Or when you move the mouse? Or Click on something? Or What
Also trying to square the code you just sent with your statement:
i have a click to destroy function
Basically, we need more context.
basically when i click on the object...it gets destroyed and for a good one or two secound i get these error messages and then they stop
but i managed to circumvent the issue by using an another solution instead of destroy
WHy does it get destroyed
you showed nothing so far that would make it get destroyed
Show your setup
already found an another way and the code is too long to paste
but basically if you want to replicate it just place a button and a script on its parent object when you call it it destroys the button itself
you will get the same errors i did
fyi, !code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
Hey so i am making a 2d 2 player ragdoll fighting game. for inputs and all, I use the unity input manager to spawn the players. I was wondering if there was a way to set the spawn point for the players when you clicked a button to join.
You mean PlayerInputManager?
I would say the best practice is to basically make the PlayerInput prefab a "stub" object that spawns in the actual player object from its own script and then you can control it however you wish
is there a way to write a custom interaction for the input system?
Yep! Have you googled it?
Yeah. For some reason i cant seem to have it appear in the dropdown menu for interactions.
Right now i am just trying to get the example in the documentation (MyWiggleInteraction) to work
Did you do this part?
InputSystem.RegisterInteraction<MyWiggleInteraction>();```
Yeah i am confused as to where this would go when it says "Now, you need to tell the Input System about your Interaction. Call this method in your initialization code:"
What does it mean by that? Again this is my first time trying to do this so I wanted to start with just the example in the documentaation
I would sort of just want to have an example from the docs I could copy/paste and just work from there in terms of figuring out how to write my own
This link that is discussed there is good?
The static constructor should work yeah
awesome thanks, @austere grotto , will try it tomorrow
If I have a composite binding for an axis input (either 1D or 2D) that I made in the GUI, how can I access each binding through code? I want to make a button prompt that shows the different buttons for each direction.
Are Joystick Buttons the same for ps controllers and xbox?
In the bindings property of the action
I'm having issues trying to setup multiple controllable objects. Each object has a PlayerInput on it. I try to assign/remove the same InputActionAsset object when I switch from one controllable object to another. My issue is that only one of the objects present act on the inputs. If I change to another, it won't respond. It does print received events in the console though. If I switch back to the first object, it can still be controlled. What am I doing wrong?
I have no idea what was wrong, but after updating my prefabs, removing objects from the scene, re-adding them as prefabs, seems to have eliminated my problems....
Each PlayerInput object should represent one human player
If you have more PlayerInputs than human players, you're doing something wrong
I'm using the RPG cameras and controllers asset from the asset store which kind of binds me to this, because their components require a PlayerInput to be on the object
I don't know what assets you're talking about but it's one PlayerInput per human player. If that doesn't work well for your game then the PlayerInput component is probably not for you
Use a different workflow
What's the intended way for having multiple controllable objects then? A static global object that has the PlayerInput component on it?
Again you can look into other workflows besides PlayerInput component
But yes that is one option
Not sure about "static global"
But certainly a centralized input handler
Persistent, if you will. Thanks though. It does seem to work fine now though, even if its not the intended method.
Hi, currently having an issue with input rebinding right now and could use some help. https://www.youtube.com/watch?v=csqVa2Vimao&t=1792s I'm using the system from this video (I'm pretty sure) and while it works for keyboard, once I try to change inputs for specifically a playstation controller, it doesn't seem to overwrite the input, but instead just add a new one.
Make a complete rebinding system using Unity's New Input System and Rebinding UI Sample. This video will show you how to implement the rebinding menu, disable and enable controls before rebinding, add constraints to the rebinding process, remove duplicate rebinding including composite actions (2D vector as an example), implement a Reset All bind...
This is what a typical input looks like, if that helps. I would love to just have gamepad as an input instead of dualshock and xbox separately but that seems to just make playstation controllers not work at all
how do you make it so when using SendMessage() with PlayerInput (new input system), that the method gets called both onpress and onrelease?
right now, it only gets called when i first press the button, and never when i release the button
its set as a button both jump and sprint
You want set as Value
Hmm I've never used SendMessages, it doesn't look like there's anything in the docs talking about canceled state with Send Messages
button is only for stuff you want specifcally ONLY onkeydown if im understanding right?
No, I use button and get canceled events
Setting action type to value will give you both .isPressed = true and isPressed = false on released
Not with SendMessage though
yeah, ill switch it. i just want to know what to use button for when using a playerInput component
Button in SendMesseges works as 1 frame only Performed
Looks like there is a OnCancel message, not sure if that's the right thing though
in events you can just get the same behavior with Started/Cancled
oh ok, switch to events would give me better control then this way, thank you nav
and nathan
Cheers turns out I dealt with a similar thing in some older crappier code of mine, so I looked at that and found I'd done that same thing
Hey i want to write a custom input interaction that basically works as Hold, but can fire multiple times. ie there are two thresholds for when "performed" is called instead of just one, to have two different "levels" of being held.
Is this even possible to do? ie after calling performed once is it possible for it to keep checking the hold time? Or is the event stuck waiting for canceled to happen?
The default interaction can call performed many times before cancel happens so it shouldn't be a problem
public void Process(ref InputInteractionContext context)
{
switch(context.phase)
{
case InputActionPhase.Waiting:
if (context.ControlIsActuated(pressPoint))
{
timePressed = context.time;
context.Started();
// Set the timeout to cancel to be the second hold threshold
context.SetTimeout(secondThreshold);
}
break;
case InputActionPhase.Started:
if (!firstPerformedFired && context.time - timePressed >= firstThreshold)
{
firstPerformedFired = true;
context.PerformedAndStayStarted();
}
if(!secondPerformedFired && (context.time - timePressed >= secondThreshold))
{
secondPerformedFired = true;
context.PerformedAndStayPerformed();
}
if (!context.ControlIsActuated(pressPoint))
{
context.Canceled();
}
break;
case InputActionPhase.Performed:
if (!context.ControlIsActuated(pressPoint))
context.Canceled();
break;
}
}
My goal is just to get Performed to fire twice. Once when it hits the first threshold,. and a second time if it is still being held at the second threshold.
My issue is i am only seeing Performed occur when the timeout is reached or if I cancel (ie, it is not automatically firing performed whenit is just being held down)
any clue on why?
Process only runs when the value changes
@austere grotto When which value changes?
the input value
although thtat doesn't make as much sense to me now that I think of it because how does the hold interaction work?
basically just one of those if statements and a PerformedAndStayPerformed
public void Process(ref InputInteractionContext context)
{
if (context.timerHasExpired)
{
context.PerformedAndStayPerformed();
return;
}
switch (context.phase)
{
case InputActionPhase.Waiting:
if (context.ControlIsActuated(pressPointOrDefault))
{
m_TimePressed = context.time;
context.Started();
context.SetTimeout(durationOrDefault);
}
break;
case InputActionPhase.Started:
// If we've reached our hold time threshold, perform the hold.
// We do this regardless of what state the control changed to.
if (context.time - m_TimePressed >= durationOrDefault)
{
context.PerformedAndStayPerformed();
}
if (!context.ControlIsActuated())
{
// Control is no longer actuated so we're done.
context.Canceled();
}
break;
case InputActionPhase.Performed:
if (!context.ControlIsActuated(pressPointOrDefault))
context.Canceled();
break;
}
}
^Thats the default one
guys, i'm having some issues with the input system in linux here. i made an input system in a project on the windows of my dual boot (windows + Linux) and when i switch to linux, the input system just don't work anymore. it shows the letters of the keyboard on windows like "( "W", "A", "S", "D" )" with the "". but in linux they don't work and when i try to add new ones, they're only "(W, A, S, D)" without the "". it seems like unity is in EN-US keyboard mode, but i use "BR-ABNT2", as i did on windows. i'm using the same version, it's the same project from my github. any ideas?
Did anyone try to use InputSystem.onEvent to block inputs through eventPtr.handled = true; ?
It works fine in-editor, but in-build only the keyboard and mouse are blocked, the gamepad actions go through regardless.
What are you trying to achieve by blocking input?
to disable all user interaction while the steam overlay is active
You could disable your actions asset or action maps instead
I did consider that, but they can be enabled/disabled based on conditions that are not themselves triggered by inputs, so it's more complex. Additionally there are various actions that are not in action assets at all. onEvent seemed kind of ideal, but that will be my fallback I guess
so, in fact, due to another bug in our build, the callback was not registered, and it seems the keyboard and mouse input is blocked by something else when the steam overlay is active (but not the gamepad input)
my bad
Don't know if it is considered in the background though when steam overlay is up
I think disabling the action map is probably the best option. If there are other things that enable and disable it, you essentially need a system that can overwrite those and enable and disable those at a master level
this is set to ignore devices, so that's fine
what i meant before is that it was our own mistake that prevented our onEvent registration from working in a build only
so the problem is resolved
thanks a lot for the help though, the device activation/deactivation would've been a great alternative
I wonder if the onEvent "hack" could cause slight issues though, for example say the user is holding a trigger on the controller and the overlay pops up, would your code think the trigger is still being held?
this is a good point 🤔 I will work on that
Any suggestions on what is going wrong here?
Buttons is not working only in build (new input system)
Is there a good reason you're using a custom input actions asset there?
yes
It's likely related to tthat
possibly you are disabling it or something along those lines
I've checked this is not working in unity
ok now it's working but I still can't press buttons
what interactions should there be here?
so, this is kind of funny; it does fix the issue you mentioned
~~however, iterating over InputSystem.devices does not work; the gamepad is not in the list of devices !
so the gamepad remains active in this case.. ~~
I guess I will combine both techniques, ignoring devices that are not in the device list with the onEvent interception, and disabling the others
it works, i had another exception.. bad day 😅 , sorry for the notification
It also doesn't work with default input actions
More likely a problem with your buttons then
First off are the buttons reacting at all to the mouse (tinting etc)?
no it's not because in unity everything works fine
Buttons only reacting on hover
that means it's not an input system problem
make a development build and check your logs
there's probably an error happening in the click handler code
Need some advice on this. So I want to use a virtual mouse for the current Mouse itself so that I can set up its bounds easily. I've tried using the virtual mouse system with the new Unity Input System module. The virtual mouse does move perfectly well with the input of the current mouse delta, however, none of the UI actions like hover or click seem to work. I have also set the raycast target for the virtual mouse image as false so there should be no issue with the raycasting. P.S : I tried replicating the virtual mouse from gamepad (video from CodeMonkey ), the only difference being it uses the Mouse for its movement, event handling.
Main goal: I want the virtual mouse to interact with the UI
Fixed it
nothing
okay how are you supposed to use the generated C# file for input actions? because I keep getting this the moment I new() an instance. even if I disable and/or dispose it in OnDisable, it seems
Where are you newing it?
in a singleton monobehavior on access
So is the error happening when you instantiate, or later? Looks like the error is coming from a finalizer?
but I think I found the issue, my UI code was referencing it, so it created a singleton in editor time
Ah yeah that lazy load stuff can bite you if you're not careful!
me: [ExecuteAlways] 😎
unity:
Destroy may not be called from edit mode! Use DestroyImmediate instead.
me: 
void OnDisable() {
if( inputs != null ) {
inputs.Disable();
if( Application.isPlaying )
inputs.Dispose();
else
DestroyImmediate( inputs.asset ); // this is all Dispose does anyway
}
instance = null;
}```

anyway hoops successfully jumped through
Any ideas as to why my controller would work in the editor but not in a build?
I'm using the new input system
- maybe control scheme problems
- maybe script execution order issues
how would I debug this?
First off check logs to make sure there's no errors
Second add some logs to make sure input is really not getting processed
Are you using control schemes?
No errors, and yes I am using control schemes
Are you doing local multiplayer?
Nope, completely singleplayer
Then there's not really a good reason to use control schemes
and they often cause trouble
control schemes are there to group input devices so the PlayerInputManager can assign sets of devices to different human players in a local multiplayer game
I just deleted the control sceme and that didn't solve anything
So it looks like it does work, you just have to disconnect and reconnect the controller a couple times for some reason
Does anyone know why unity takes like a minute to actually start using my controller?
anyone any idea why this always returns true? I have recently disabled the old input system in my project settings and since then everything is screwed because of this method always returning true 😄
// Check using the pointer ID from the new Input System
if (EventSystem.current != null && EventSystem.current.IsPointerOverGameObject(-1)) {
Debug.Log("GetIsMouseOverUI() is TRUE");
return true;
}
// Check if a UI drag operation is in progress.
if (UI_DragAndDropManager.Instance != null && UI_DragAndDropManager.Instance.IsDragging()) {
return true;
}
Debug.Log("GetIsMouseOverUI() is FALSE");
return false;
}```
funny thing is, that even switching back to the old input alongside the new one in project settings does not fix my issues. However, when hardcoding return false into my method, everything works as normal.
Anyone got any idea what I am missing here?
Well there's two places where it can return true. Have you logged yet to see which one it is?
That seems like the logical first step
yes I have, it is always the first if-statement that returns true.
Then there's an object under the pointer
I just noticed that the Physics Raycaster component on my main camera was the issue. Event Mask was set to every Layer. Changing it to only my "clickable" layers fixed it
yep
in general you can get rid of this kind of code entirely by switching all your point and click interaqctions to use the event system instead
yea I have the feeling that I reached a state now where I should centralize my input logic somewhere instead of having individual logic across multiple scripts
Hey got a question with the Hold Itneraction in unity's input system.
I am trying to (foir the time being) re-create the hold interaction in unity. The following is quite literally the code from the HoldInteraction.cs (the default one)
public void Process(ref InputInteractionContext context)
{
if (context.timerHasExpired)
{
context.PerformedAndStayPerformed();
return;
}
switch (context.phase)
{
case InputActionPhase.Waiting:
if (context.ControlIsActuated(pressPoint))
{
timePressed = context.time;
context.Started();
//context.SetTimeout(secondThreshold);
}
break;
case InputActionPhase.Started:
// If we've reached our hold time threshold, perform the hold.
// We do this regardless of what state the control changed to.
if (context.time - timePressed >= 1f)
{
context.PerformedAndStayPerformed();
}
if (!context.ControlIsActuated())
{
// Control is no longer actuated so we're done.
context.Canceled();
}
break;
case InputActionPhase.Performed:
if (context.ControlIsActuated(pressPoint))
context.Canceled();
break;
}
}
What i am noticing is that the default hold interaction doesn't actually fire performed unless its SetTimeout value has been set (ie the commented out line). Otherwise it waits for you to release the actuated button before saying it was performed. Is the Performed supposed to be fired while it is being held down or only ever when it is let go (after being held for a certain amount of time)?
My initial thought was the Performed would be fired the moment you cross the threshold. However, like i mentioned above, it only fires performed if you let go of the actuator after it has crossed the desired threshold. Is this intended?
My goal is to make an itneraction that fires Performed at different time thresholds while it is being held down still
the default hold interaction fires performed after holding for a certain amount of time
release is not required
Thats not what Ive been seeing, even with the default hold code copy and pasted into mine. It only fires performed because the timeout value has been reached
If you uncomment the timeout code it will not fire anything until you release
let me test because that doesn't match my expectations
Thanks, let me know. Its not doing what I expect either
The highlighted line is what I am refering to ^
I am also in unity 2022 if that helps
Performed works for me after holding without releasing
a.action.Enable();
a.action.performed += ctx => Debug.Log("Performed");```
Hmmm. Is there a way to edit the default Unity HoldInteraction.cs? Any time i make a change to it and save it resets it back to what it was before (hence why i just copy and pasted the code to a custom interaciton)
you would need to turn it into an embedded package
How can I do that?
And are you sure thats not just becasue the timeout value was being hit?
If you set the timeout to something really long (or comment it out), does it still work?
https://docs.unity3d.com/Manual/upm-embed.html follow the instructions for copying a unity package from the cacche
I think by default it uses the press duration as the timeout value
Well it fires after the hold time:
Yeah but what I was saying before is that I think that it "Seems" to be doing it properly becasue its actually the SetTimeout() that is being hit, and not actually the code chunk that checks if the time has passed the duration
ie this is actually never being the cause of the action going into performed
I'm not sure I understand the difference or significance of "timeout" vs "hold time" here
theres a timeout that gets triggered regardless of how long the duration is set that triggers it to go to performed
My goal is to make a mutli-stage hold that fires at multiple points as you are holding it down. I found this issue because it never acutally fires besides when the timeout in SetTimeout() gets hit
but it's using the set duration for the timeout
Yeah, but my expectation is taht it would fire without that
it won't because the Process function never actually runs except when:
- the input control actuation changes
- the timeout expires
it doesn't run every frame, for example
Do you have a reccomondation to achieve what I am trying to do then?
essentially just something that as i hold it down it will fire perfomed at multiple desired thresholds
if setting multiple timeouts simultaneoously works - do that
otherwise, set a new timeout when the first one expires
third option - just use the default interaction and do the logic in a script in Update
So whats the point of the time threshold check in the default unity code then?
To make sure enough time has passed
remember Process might run on the timeout or when you release
so if you started the interaction (phase is Started) you need to check whether the time has passed or if we released
But like i said, it never seems like it is checking if the time has passed
the context.performed never seems to call from the if(context.time - m_timePressed ... ) check
public void OnJump(InputAction.CallbackContext value)
{
if (value.started)
{
Debug .Log ( "Value started = " + value.started);
animCtrler.SetFloat("VeloMag", veloMagnitude);
isJump = true;
jumpTimer = jumpCD; // Start the jump timer
Debug.Log (jumpForce + "JumpForce");
rb_.AddForce(new Vector3(0f, jumpForce, 0f), ForceMode.VelocityChange);
Debug.Log("OnJump" + isJump);
}
}```
Everything runs except for the rb_.Addforce() , any ideas?
If everything else runs AddForce also runs
What makes you think it doesn't?
It just doesn't even when jump force is 9999
It seems to be calling the function on another script??? My player jumpforce is now 999 but it prints as my default 15
Ohh i accidentally set the input event to call the jumpscript on the prefab =.=
Whoops.
Hey all. I'm sure this has been answered somewhere, yet I couldn't find it. Was hoping someone could answer my questions, or link me to a good writeup!
- I'm wondering if there is a functional difference between using the input system through a player input script, or through C#. Any performance benefits or downsides? Any limitations?
- I'm playing around with a little prototype where the player can control different types of vehicles. For this, I need different input maps for each type of vehicle (e.g. a plane vs a car). What would be an industry standard way of doing this? Keep the player input and cycle between maps depending on vehicle? Use C# input classes, disable the player on vehicle enter, and enable a separate inputaction instance?
(Please feel free to ping me if you respond, I'd really appreciate it!)
I don't understand the first question
Are you talking about the "Player Input" component?
and I'm not sure what "through C#" would mean
maybe the "Generate C# Class" feature of an input action asset?
the player input component is almost entirely useless for someone who can code. It is useful for providing callback for input device changes and local multiplayer
Yes to both questions.
I can code just fine. Though I like the convenience / flexibility the player input component offers.
what convenience?
Was curious whether the ideal really is making a middle layer between / event bus for the generated C# class.
the ideal is using input action references
The player input component handling the subscribing of events.
Oh?
I've dabbled with those a little bit. I'm curious as to why they'd be more ideal?
As far as the inspector goes, it seemed potentially more clutter
Though I'm probably being a tad overdramatic there 😅
In what way would it solve my need for multiple different controllers? E.g. the basic player movement controller, a car input controller, a plane input controller, etc...
I was curious whether it wouldn't just be more convenient to place a player input component on the prefab, disable it by default, set it to the correct map, and bind it to the vehicle's event handlers.
And then toggle the player's and the vehicle's input component on entry/exit.
you could simply make an input action map each for those different vehicles and enable/disable those
How would they be bound to the specific vehicle's event handlers though?
E.g. if there are 3 cars.
input action references
And then enabling those on entry / disabling on exit?
the actions are part of an action map on entry/exit you toggle the action map
which toggles all the contained actions
Is the input object active regardless of being attached to e.g. a player input component?
i.e. if it exists as a file, it's active
what input object?
Apologies, wrong wording. The Input Action file.
Forgot the exact name for the file itself.
you mean the inout actions asset?
Yes.
thats just a bunch of json
its not ever active
but if you reference an input action, that action's events will be called
That's what I was wondering, yeah
If the asset exists, and I use an input action reference, it will work
yes
I don't need to instantiate anything or do any management of a persistent object.
Neat.
if you dont have the asset you also can't use action references since then there would be no actions to reference
I can see the benefit of using the input action reference, yeah.
Only have the actions you specifically need, no clutter with the player input component
yes
and no unity events
just c# events
also easy to rename, rebind and move things around
I guess I do need to manually subscribe
basically allows you to make input completely abstract
I'll play around with it a bit tomorrow. Thanks!
you always have to manually subscribe
there is no way input magically connects to your controller
Well, not with the player input component. It handles the event bindings for you.
you still need to configure what these events should call
You have to assign the event, I guess that kind of counts.
I did enjoy the code removal it brought with it, but it's a super minor thing
also unity events are about the easiest thing to break in a unity project, its best to not use them for anything thats improtant or needs to survive a refactoring
And I don't really need flexibility in the event bindings tbh
Hm, I haven't had any issues with them personally.
I do use Rider, and it has so far been pretty good at integrating with Unity for any minor refactorings.
But I'd lie if I said I had done any significant refactoring related to UnityEvents
rider cannot migrate unity events to new names
if you rename the method a unity event calls, that event is then broken
I'll have to give it a try tomorrow
and nothing warns you about it, there is no error, no warning, its just silently not working anymore
Kind of curious now
I'll rename my movement event handlers and see what happens
Will need to rework it anyway to use the input action refs
Thanks for the solid advice and discussion! Have a fantastic rest of your day!
yeah, they're spooky
InputActionReference is great. I use it for everything now.
I've not tried it but I wouldn't be surprised if it could, it is aware of the YAML and I thought it supported refactorings within .prefab, .unity, and .asset
I would expect that at some point it will be able to do it. But for now, from what I’ve seen, it doesn’t change the yaml, it only automatically adds migration attributes and those don’t work/exist for Unity events. It can’t even migrate backing fields of serialized properties automatically.
@verbal remnant question:
- Would IARs from different maps work together? Or would I need to still switch the global input actions asset between maps?
- Does the IAR approach still automatically switch between input device?
- there needs to be only one asset holding all the maps and actions. Idk what you want to switch here. Maps are just a container for actions to modify them together. Whether there are limitations caused by this that affect your game code depends on what you do with the references and how you toggle them individually, globally or via maps.
- actions dont switch between input devices, they merely trigger events based on what bindings you have configured. If you use input schemes you need to set these up correctly so that valid input-device-combinations exist.
Right, but are all maps active at the same time? This might just be a misconception based on the Player Input Component having a dropdown to select the map & device.
they are all disabled by default, you enable them in any combination you like
If you use player input to enable/disable them, that will then also affect your action references.
since in most games you will need a state machine to control inputs and other things for each of your fundamental game states/modes, you should toggle the action maps there. Whether you do that via Player Input or directly is up to you.
so i want to write a class for input to have all in one place. but i have to repeat each input with basically the same code:
public void UseSpring(InputAction.CallbackContext context)
{
if (context.action.WasPressedThisFrame())
{
EventManager.UseSpring.OnSpringEvent.Filter()?.Invoke();
}
}
public void ExitMenu(InputAction.CallbackContext context)
{
if (context.action.WasPressedThisFrame())
{
EventManager.UpdateUI.OnCloseUICall.Filter()?.Invoke();
}
}
so I thought I just work with a switch to reduce the code produced...
public enum InputVariants{
UseSpring,
ExitMenu,
}
public void CallInputAction(InputAction.CallbackContext context, InputVariants inputAction)
{
if (context.action.WasPressedThisFrame())
{
switch (inputAction)
{
case InputVariants.UseSpring:
EventManager.UseSpring.OnSpringEvent.Filter()?.Invoke();
break;
case InputVariants.ExitMenu:
EventManager.UpdateUI.OnCloseUICall.Filter()?.Invoke();
break;
default:
break;
}
}
}
problem now is....
the method doesnt show up in inspector as an event to be called:
i guess its because the player input component only accepts callback context events?
Your function no longer matches the expected signature
But you can make a wrapper function that passes in the constant if you want
Hello, I am trying to create a main menu for my game.
For some reason my buttons are not clickable.
I have done the following:
- created an event system in my scene
- My buttons are inside a canvas object, the canvas does have a raycaster
- All butons are interactable, have Raycast Target On
- The TextMeshPro component objects dont have RayCast Target On
make a debug that tells you what object you are actually clicking. its probably some kind of overlay over your scene, that blocks the raycast
I did, I see my buttons are clicked now but the OnClick doesn't work
What's the right way to handle OnMouseOver etc etc with the input system while using a cursor (for controllers)? I can't seem to find any documentation
Do I really need to do it with raycasts?
This is implying only UI components, I think I really have to raycast on update when dealing with gameobject
No, use IPointerEnterHandler
as I just discovered yesterday, you can use the event system with colliders, too!
Also worth realizing that UI doesn’t have to be on a canvas. It’s just the convenient 2D part of it.
I'm getting this error when trying to build for Linux
The type or namespace name 'Switch' does not exist in the namespace 'UnityEngine.InputSystem' (are you missing an assembly reference?)
How can I fix this? Why isn't Switch supported for Linux builds?
as long as u have a Graphic Raycaster correct?
Physics Raycaster!
Anyone able to help me with how to handle the Cancel action? I've found the documentation page, https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html#UnityEngine_InputSystem_UI_InputSystemUIInputModule_cancel, but it's not being terribly helpful.
I've got an InputAction mapped.
I've seen some references to implementing ICancelHandler, but I'm not sure where, and my attempts so far haven't been very fruitful.
I'm also running into a weird thing where the Submit button works without activating the canvas, and after running the game, I can't change the Submit button to a keyboard shortcut without closing the project and re-opening it...
Unity 2023.3.0b5 for what it's worth.
assign the input action in the create method
i think there is an error in the example code
cancelAction isn't a thing inside InputSystemUIInputModule
just says its cancel
Oh. So I just need to assign that action.
my unity game uses the player input manger for local multiplayer. The script I have calls its child objects and moves them based on controller input, but when the second controller joins in and clones the player, both players are controlled by the second controller. How can I get the script to call its children separately?
I havent used the UI yet with new input but from my understanding thats how it connects the event system cancel to that specific button/action
inputActions = new(); ((InputSystemUIInputModule)EventSystem.current.currentInputModule).cancel =
InputActionReference.Create(inputActions.UI.myCancelButton);```
im using visual scripting btw
only enable inputs if its owner
idk how you do it in VS though
in code example would be
if(!isOwner){
myinputscript.disable();
return;
}```
Ah, I don't have a cancel button. It's all just using buttons to cancel. 😄 I'm going to give a try at hooking into that event though. Thank you for pointing me down the right direction.
Maybe. 😛 We'll see if it works.
okay goodluck. Ill try to look into it myself a bit more maybe something comes up
hi everyone quick question. Does anyone know how to get unity to request permission to access the microphone on MacOS? I want players to use their voice to trigger something but cant get the microphone to access unity
from what im seeing input system is primarily designed for keyboard, mouse, gamepad, and touch input, and does not natively support speech recognition.
I would guess you just start using https://docs.unity3d.com/ScriptReference/Microphone.html
Hello everyone. Does anyone have an example of a controller for 3rd person vehicles? I want to create a game with controls similar to this Star Conflict or War Thunder Provides control of both the equipment and the turrets on it, but I found almost no necessary information
hi there
i have a USB HID gamepad (the one that Unity recognizes as Joystick) and i would like to add bindings for its buttons and both sticks but for some reason Unity doesn't recognize right stick, in the Input debugger it is shown as two separate axises
other buttons just can't be found in Joystick tab, i can add them only as binding for my gamepad specifically
is this possible to add a support of this gamepad?
Input System has no builtin support for advanced joysticks, best option is to use it as a gamepad. To get vendor specific axes and buttons you need to manually create support for that device identifier or the specific buttons/axes individually. You can do that by simply specifying the path as it is reported by the device.
i know that i can write the path to an axis or button but how about the right stick? as i said, unity reads it as two separate axises and if i want to bind it to some Look action i can't because it allows to add only binding that returns Vector2 or 4 bindings for each side but not two axises - vertical and horizontal
whats the best method of introducing an interact button for FPS? ive got movement down and just have to figure out how to frankenstein in an input
all tutorials assume youre using a different input script
Hi there! Unfortunately it seems that the new Unity Input System does not work with Steam Remote Play. Are there any future plans to add support? Thanks!
This is not a ‘ask the devs’ discord. Most people here don’t know Unity development internals or can’t share anything that’s not publicly available anyway.
I recommend submitting this through Unity's roadmap site if you want the appropriate people to see it.
I have a TextMeshPro input field for the player to enter a name. I have it working for a keyboard / PC but how do I incorporate a HUD keyboard for players using a gamepad?
make a grid of buttons representing a keyboard, hook them up to modify the input field based on what the button represents.
make unity animation stop after keyframes over
Is there an easy solution to clear a selected object when pointer clicks on empty space? All of my current input logic is on the gameobject.
I do this with a giant invisible UI image on a screen space camera canvas with a plane distance of 1000 with it's own on click logic
It basically catches all the clicks that don't hit anything else
This sounds okay. My game is using the on pointer click on gameobjects in the scene with a ground plane and scenery element though, I guess I could make them all ignore clicks.
Physics Raycaster has a layer mask on it
Anything that needs to be clickable can be in the mask
Anything else can be in other layers
Cool. I will get right on that. Thanks! 🤘
hello, i have a PlayerAction component on my player. I changed the default Scheme name to Normal, and added a Build mode. Problem is, i cannot change the action map by passing "Normal" and "Build", and when the game starts up i get this error, even when i set default action map to normal.
Your code appears to be trying to switch to an action map called Player which doesn't exist
Probably a different PlayerInput
(it's called PlayerInput not PlayerAction)
Look for other PlayerInput instances in your scene
PlayerController line 309 also has a Null reference exception
heres my input switching code if that matters. "Player" Is what the initial action map is if you do not rename anything yes. the problem with that is i removed EVERY reference to player in the inputActions asset, the PlayerInput Component, and the code.
Yeah but I think you just have another PlayerInput component in the scene somewhere
Trying to search for it, but coming up empty. i have nothing else that i remember tieing to the player, because i imported my prefab from another scene. the prefab defo doesnt have more then one input
yeah the player is the ONLY instance of PlayerInput in my scene
Fixed it btw, bug come up when modifying InputActions, and you have to delete library and reload project for it to reconize change if it comes up
Make sure you define the action correctly
Assuming this is for zooming a camera it should be:
Action Type: Value
Control Type: Axis
i want to make sim souls like game the right and mouse controlling the camera
And the mouse binding would be totally separate from your gamepad binding
Yes that would be an axis
you might want it to be 2D too
In which case you'd do:
Action Type: Value
Control Type: Vector2
It seems like right now you're trying to make this a composite or something
which is not correct
For example here's the default Look action. It's Value/Vector2 and then one of the bindings is Delta[Pointer}
Assuming you set the Camera action to Value/Vector2, sure
yes
Ive been having problems with the input system, first both players were being controlled by one gamepad and then when i set the controller values to variables and then each player to be controlled by those variables, the gamepads are controlling the opposite player, while the triggers are still controlling the original players.
you'd have to show how you set things up
I'm not sure how this intereacts with Visual Scripting. Are you using InputActions defined directly on the script?
Or are these InputActionReferences?
Or what
the script gets the input actions from each prefab and puts it into variables only accesible within the script
but somehow its swapping the joystick inputs when the new player joins in
right that's what I'm saying - "input actions from each prefab" - meaning you just defined input actions on the script itself?
And you configure them in the inspector on the script?
Usually for local multiplayer you use an Input Actions Asset and PlayerInputManager / PlayerInput components.
Otherwise you have to handle player connection / device mapping yourself
forgive me im a beginner to all of this but here
when the new player joins in the original first player is controlled by the second gamepad when the new player joins in
this video hardly shows me anything useful tbh. I'd love to see what components are on the prefab(s) and with what settings and how the actions are configured etc.
alright give me a second
Has anyone ever seen this issue?
One specific menu is spawning another menu, then this error happens and the input system no longer works.
This specific menu is the only one causing it yet it's changing menus the same way all my other menus do.
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
at UnityEngine.InputSystem.Utilities.InlinedArray`1[TValue].get_Item (System.Int32 index) [0x00018] in .\Library\PackageCache\com.unity.inputsystem@1.7.0\InputSystem\Utilities\InlinedArray.cs:68
at UnityEngine.InputSystem.UI.InputSystemUIInputModule.RemovePointerAtIndex (System.Int32 index) [0x00001] in .\Library\PackageCache\com.unity.inputsystem@1.7.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:1861
at UnityEngine.InputSystem.UI.InputSystemUIInputModule.Process () [0x000c6] in .\Library\PackageCache\com.unity.inputsystem@1.7.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:2177
at UnityEngine.EventSystems.EventSystem.Update () [0x000f6] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\EventSystem\EventSystem.cs:530 ```
Something weird in your input module. Are you also spawning in a secondary event system or something?
I'm deleting the current menu, then spawning another menu in a GameManager object.
All other menus in my game use this system. It's only ONE menu that causes this error
Yeah but what about your event system
Did you modify the input module in some way?
This isn't helpful either.
I'd love to see what components are on the prefab(s) and with what settings and how the actions are configured etc.
When I say I want to see the components I mean show the inspector
ah i see
The event system is attached to the Menu's object, which is deleted first, then the new UI object is spawned.
Here is the code:
public void NewUIScreen(string path, bool transition = false, bool freezePlayer = false)
{
if (freezePlayer)
{
Player.Freeze(true);
Player.gameObject.SetActive(false);
currentLevel.SetActive(false);
}
if (transition)
{
StartCoroutine(TransitionUI(() => NewUIScreen(path)));
return;
}
// Temp ref to old UI
DiestUI oldui = currentUI;
string oldUIPath = currentUIPath;
// Destroy old UI
if (oldui != null)
{
previousUIPath = oldUIPath;
Destroy(oldui.gameObject.transform.root.gameObject);
}
UnityEngine.Object o = UnityEngine.GameObject.Instantiate(Resources.Load(path));
DiestUI newui = o.GetComponentInChildren<DiestUI>();
if (newui == null)
{
Destroy(o);
}
else
{
// Replace current UI variables
currentUI = newui;
currentUIPath = path;
}
}```
Right so you're deleting your event system and spawning in a new one
Honestly that's very odd
normally the Event System should be a completely separate object form any UI
basically each joint is a hinge joint and the main torso has the actual script attatched too it
and you should just leave it be
the script gets the input from the gamepad and moves the children accordingly
I'm interested in the actual script components not any of this stuff which is unrelated to the input stuff
Ok now how is your actions asset set up?
The InputSystem_Actions asset
its the input manager thats causing the issue, less so the input system
it works fine for one player
sorry thats just nintendo controller buttons lol
left trigger and right trigger
so what's going wrong here exactly? parts of the gamepad are controlling the wrong character?
here let me get a video so i can better show you what the actual issue here is
hold on wrong video
i press start to add in the first player and never stop moving the stick on that player. When i press start and add the second player in, the first gamepads stick is controlling the second player, while the trigger still controls the original player.
forgive me if its a bit confusing
basically the stick movement swaps with the second player
The waving arm is the thing being controlled by the stick?
yes
What does the trigger do?
the trigger is a grab button
im basically recreating the movement of "a difficult game about climbing" if you have heard of it
Where's the part of the code that reads the MoveX and MoveY?
because this code seems to read "LookX" and "LookY"
but the input handling code is setting MoveX and MoveY
movex and movey is for the left stick, look is for the right stick
I can add the code back in for the left arm but itll still do the same thing
let me show u a better look hold on
Well the code you showed for input handling doesn't set the LookX and LookY
so it would be good to see the code that does set it
Thanks! This resolved the error. However now the new Input System is losing the gamepad as a paired device.
I'm using Input System 1.7.0, would you know why that's happening?
What do you mean by it losing the device exactly?
you can see in the code that the values for the right stick switch from reading from gamepad one, to gamepad two when the second player adds in
God I despise visual scripting lol
In the "Input Debug" you can see each user and the devices tied to their inputs. The system reads these devices no?
bro honestly it might just be a visual scripting issue
i dont blame you 😭
i thank you for at least trying
Yeah I'm not sure. this looks to me like it should work, but I don't use VS so maybe I'm missing something there.
My understanding is the Graph variable should be only within that script right?
So I'm not seeing how data could be jumping from one instance to another
My initial thought was maybe you were setting it as a global variable or something but that seems not to be the case
its not that the data is jumping from one instance, its when the second gamepad comes in the first player object starts pulling from the second gamepad instead of the first
Yes. So you're seeing this in the input debugger? It's losing it when you load the menu?
Yes. The "Gamepad" is lost when switching menus.
right that would imply that the data coming from the second object's PlayerInput is making its way to the first object's script.
I'm making a mobile game so the onscreen controls are mimicking a gamepad
Some wire is getting crossed somewhere
ah was just about to ask if you're using OnScreenControls
are they part of the object that got destroyed?
yes as they are the on screen buttons in the menu
thats true
It might be something about how the Visual Scripting "Input system event" node works
and the weirdest thing is if i dont set that graph variable in the script, both players are controlled by the same gamepad
its honestly so frustrating its insane
does anyone know a good tutorial of using new Input System with Unity 6?
which shouldn't matter btw because its just getting the player input from itself
at this point im just gonna manually set everything idk man 😭
I think one weird thing is your use of OnUpdate here
yeah thats true i should just used fixed update
If I understand things correctly you can/should wire the green arrow event directly from the Input System Event nodes into the Set Variable nodes
nah not FixedUpdate
oh true that too
well wait actually no
i dont do that because it would only activate then when the "on hold" part is true
it wouldn't give data for zero
you'd have to make a separate event for release i guess?
yep
its useful in some cases like the grab, but for just putting the raw data into a variable i do it like this
hey yall, I need some help with setting up my input system to differentiate between two actions that share one input.
For example I have action called Dash and if hold down the A/D key , it will do a dash. However I would like to also make a different action call Parry and if Hold down the S key + A/D key it will initate a parry. Current I have both set up and when ever i go to do a Parry , it will both dash and parry at the same time.
oh and i would like for only one to happen based on the input
For the player input manager's instantiation of the player prefab, how do i adjust the instantiated position?
Hey, does anyone know if CursorMode.ForceSoftware is unsupported by Input System?
It looks like it doesn't... I just found a solution to #archived-code-general message by allowing both input handlers in my project.
what is input system
Check out UnityEngine.InputSystem namespace in the docs. It replaces the legacy system under UnityEngine.Input with more managed features.
Hello, can I ask a question about how do you connect bluetooth device to windows system in unity?
I checked lots of articles and most of the ones I got were about using a mobile device to connect to a Bluetooth device.
It really discourages me.
Also I have found adabru's BleWinrtDll, is that a way or not? Lots THX
the player input system manager is genuinely such a headache
everytime a player adds in it mixes up gamepad inputs between players and its so frustrating
even though I clearly define which gamepad goes to which player here
if anyone has any idea how to fix this issue it would be so greatly appreciated
Hello, not sure if it's correct chanel for this but how can i remove microbounciness of player while moving? I've replaced boxcollider2d to cylindercollider2d to remove random stucking in the ground but now it just bounce player instead. I've tried to add 0 bounciness material but it had no effect
what do you mean by "microbounciness"?
i think this is to do with your tilemap, not your player. looks like the tilemap collision isn't consistent.
make sure that your tiles have the physics shape you expect (ie, not rounded at the corners) and add a composite collider to your tilemap and set your tilemap collider to be part of the composite.
It's less noticeable on video but if u would see to rigidbody velocity u will see unconstant y-axis spikes
I will try it later, thank u
Hmm... I have a tank game that I'd like to operate via old traditional tank controls, with the left stick of the game pad using the Y axis for the left treads, and the right stick doing the same for the right treads. I've got a Value action with type of Axis. I've tried both a Composite of Left Stick/Up and Left Stick/Down, and mapping it to the Left Stick/Y, but neither seem to register as input. The corresponding keyboard commands do. I'm currently using ReadValue to get the value in my code. I had also tried removing the keyboard commands on the off chance that they're "overriding" things by giving me an artificial 0 value. No dice...
Can you show the config of the action, the global input system device settings and the active schema config
Certainly. Here's my Input settings (currently set with the left tread doing the composite binding and the right tread mapping to Right Stick/Y).
And the code that reads it: https://pastebin.com/ez6G9ecz
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.
And I haven't created an Input System Settings Asset, so I assume it's on the default.
Do you get any gamepad input in general?
e.g. just create an action that produces a Vector2 and see if the "left stick" binding works for it
I'm at work now, so it will be a bit before I can do that. I can see the input in the debugger.
I switched to the new input system in my fps game
but the mouse axes in the new input system are MUCH more sensitive
like 12x or so
Is this not how its supposed to be done?
Well I would just have a single Vector2 action here
but this is ok too
the real question is what does your code look like
1 sec
private void DoFpsCamera()
{
float mouseX = _inputX * mouseSensitivity;
float mouseY = _inputY * mouseSensitivity;
_xRotation -= mouseY;
_xRotation = Mathf.Clamp(_xRotation, MaxUpwardRotation, MaxDownwardRotation);
transform.localRotation = Quaternion.Euler(_xRotation, 0f, 0f); //euler gets converted to quaternion
_yRotation += mouseX;
_playerBody.rotation = Quaternion.Euler(0f, _yRotation, 0f);
}