#🖱️┃input-system
1 messages · Page 53 of 1
- Set up OnScreenControls as per the link above
yes certainly
what's stopping you
So I guess all the ways lead of converting my Input System to new Input system
Hold on a second
This is the script that uses this Input Manager and here is my function
I want to attach the Left function to the left button and have the same effect like the left key on my PC keyboard
How can I do that if possible?
You can't really bind UI buttons to generating INput manager input in the old system
it's not flexible like that
you just have to call the same function from your button and from your input handling code
that's the only way
If you want something more sophisticated, you can upgrade to the new system
how would I go about using the new input system for movement? since it only fires the events OnPress and OnRelease
for movement I need it to fire every frame that it's still pressed obviously
You can simply read your action's value every frame if you want
You don't have to use events
yeah, I saw that in one of my other scripts where I did some example project with new input system
hoped there was a cleaner/more readable way
You can also use the performed event, save the value to a variable, and read that variable in Update
still you will need Update either way
but I guess it will be still readable considering single responsibility principle (as in, the component only handles input in the Update())
hmmm that might be a good idea
would I reset the direction vector upon cancelled fired?
I'm not sure if cancelled was still fired if for example performed only fires if I pressed it for like 3 seconds but I released it prematurely after 2 seconds
this behavior depends on which Interactions you put on the action
if no interactions, then you'll get started/performed immediately, and cancelled when you release it
Assuming this is a regular button control
if it's an axis, you'll get performed every time the actuation of the control changes, except when it changes to 0, when you'll get cancelled
no, I mean, if performed only fires after 3 seconds pressed (I think it was done via processors)
will canceled be fired even if I didnt press it for 3 seconds (as in, I released the key before performed could fire)
I think so. Test it
eww
brb
yeah it does
that's not good
is there a way to check if it's "valid release of button/input"? 🤔
I just wouldn't bother with the processor/interaction stuff.
Use your own game logic and the default started/canceled stuff
if released/canceled came after whatever your threshold amount of time, do your thing
otherwise don't
you mean, cache Time.time upon performed and check Time.time with the cached timestamp and see if it's beyond threshold?
sure that would work
hold on
that would still not give the desired result
with the interaction (the 5s delay thingy) performed fires after the 5s
oh well
I guess I can still work with the interaction, but just need to check specifically (as we said above) on canceled
that's why I said not to use the interaction
but what if you want such an effect
an example I could think off would be rolling/sprinting in Dark Souls
what effect
in this example you sprint if you keep it pressed for more than 1s or something
and if you're below, you do a roll
and the rest to be checked in Update() it sounds
- check if key pressed (therefore cache
pressed = 1andpressedTimestamp = Time.time) - check if
Time.time >= pressedTimestamp + 3 - if yes, do things
is there a way to get the hold time via code though? as in, access the interaction properties via code
seems to be something like this
aren't you way overcomplicating this?
You get a performed callback
you can check whether that has happened yet or not
I installed the new input system and when I open my game in Unity Remote I can't press buttons or anything
But on my PC they work any ideea why?
The current release of InputSystem doesn't support Unity Remote. There's a pending update for it so it should probably be in the next version - or if you need it right now the pull request should be public so you can grab the changes yourself. I wouldn't recommend that unless you're pretty comfortable with Input System internals, though.
Do you know the Event System info that you can see if you select the input system at runtime. It used to show the currently hovered and clicked ui elements.
Switching to the new input system seems to have removed most of that info. Is that an alternative way to debug the ui+input system interaction now?
Here's how it looks with the new input system:
Here's what I'd like to see:
Yeah it's pathetic. My best alternative has been a code snippet that calls EventSystem.RaycastAll and prints out the results. They need to improve it
I see. I've read online that there's improvement in 2021. Did you have a look at it?
Not yet
Alright. Thanks for the confirmation.
Appears to be pathetic in 2021.2
He said the thing!
am i right to assume you cant forcibly make a player leave via script?
Not sure what that has to do with the input system, but of course you can in a multiplayer game
Is there a way for the player input component to prevent cloning the input actions?
if there are more than 2 Player Input, it clones the InputAction
?
Is it possible to use input action perform when mouse button is clicked and return the Vector2 of delta from start click position to actual position without adding code?
No. Not without adding code. You will need to write code.
😦
In the first place, a mouse click and the mouse position/delta are going to necessarily be two separate Input Actions.
Yes, but I saw there was already implemented the wasd mapped to Vector2. So... I hoped for the simulation of controller stick with mouse
Do you mean like this? https://www.youtube.com/watch?v=zd75Jq37R60
Today we will use the new input system in Unity to add an on-screen joystick to our game. This works on both desktop and mobile phone devices.
Using an on-screen stick will pipe the values to a different control type, aka Gamepad stick, where we can then use an input action asset to read it's value in our script.
►📥 Video Source Code 📥
https:/...
yes
InputSystem has PlayerInputManager.JoinPlayer() and i can add a player manually. i'm wondering if there is a way using InputSystem that you can UnJoin a player
like, an external event occurs and i want to take that player out of a game lobby
Probably. But I don't recommend using the player input component in the first place. Too restrictive
thats likely because you have way more skillz than me
i was one of the few people on the planet to like HLAPI 🙂
How would you make a held interaction? I made one that sets the context to performed whenever the input is held, but that only sends it once per press. Why doesn't it repeatidly perform the action?
Because you want it HELD. Sending it continuously would always trigger it as a 'new input'
Yes. I want it to register as a new pressed event each time it checks while it's held. I don't see the problem here.
But that is not how you think of held most of the time. Then just send an event evvery frame yourself
That's what I'm trying to do. Each frame where the input is held, send an event signifying as much. I feel like I'm being a bit loose with terms here but that's the best I can explain it.
Then just do that? What's the problem?
Even though I do context.Performed() whenever the control is actuated, it only ever sends one event.
It'll only do another once I relase the control and press it again.
Exactly
For continuous sending you have 2 options
Set a bool when performed and check that bool in update and do your logic.
OR write an input interaction
I've been doing the latter. That's where I've been trying this stuff. I assumed that was the only place you'd be using stuff like context.Performed().
I'm not expert on the new input system, but if you have it set up as a 'Button' event with a hold interaction, that interaction is not meant to give you continous input, it's just meant to trigger the event after the user holds the button for a predetermined amount of time, at which point it will trigger that event depending on the phase.
For the hold interaction the perfomed phase happens right after the player holds the button for the predetermined amount of time. So it really isn't meant to work for continous held input.
If you want continous input then what Mindstyler recommended about setting a variable and checking on update can work, you can set the variable to true on "performed" and to false on "canceled" which will give you that kind of behavior.
You could also use a value action type at that point since you can set it to be a ton of different types and you can then use the InputAction.ReadValue<>() function to get the current value of whatever input action you're checking
I'm not using the hold interaction. I'm making my own. Probably should have clarified that a little better.
Got ya, so you're using the context.performed to check and then doing the interaction that way?
Does it work if you call PerformAndStayStarted() instead of Performed()? The docs for InputInteractionContext are a little thin, but from what's written elsewhere it sounds like it may only trigger the callback when the state switches from Started to Performed, and if you're just calling Performed() every frame it may never switch back to Started.
Sadly not. I'd also tried calling cancelled immediately after peformed and still no difference.
Hm. Well, there must be some way to send performed multiple times because value interactions do it, but at this point I'd have to dig throguh the code to see exactly how it happens.
Got a custom interaction that's just an if for checking the cotrol is actuated and running .peformed if it is, ye.
I'm worried it's something external that dictates the reset, given it does so properly when I release and repress.
Got ya, so if you have it set up as 'button' event, then yeah it will only trigger it once to my understanding, since it'd be the "performed" phase of that single event of pressing the button
I don't really see how it could be, since again the Default Interaction on a Value action happily sends multiple performed callbacks even though it seems like there's no external effect that would cause it to reset?
No, but that is a value action, so I have no idea how it treats those differently in this context.
I'm sorry if I'm not understanding, but if I get what you're saying then you have it set up as a button event, have you tried using a value? Since it seems like value is what you're looking for
The problem then is I'm having to poll it for a value constantly, one I don't need at that. Sorta defeats the point of a 'while held' action.
The docs seem to suggest that even a Button action with a value control bound to it should resend performed when the control value changes? That sounds wrong, though, so the docs might be misleading.
If it is a Value/Button thing, making it a Value interaction that you treat exactly like a Button action (i.e. just use performed, ignore the value) might be a workaround.
^^^ I agree with tjm yeah, I don't see an issue with using the value if it works
That's something to try. I'd still be sending a garbage value I don't need but I can live with that. I might have a look at it tomorrow. For now I've got a dumb bool that gets toggled of press and release that's checked in update.
Looking through the code I don't immediately see any reason why multiple calls to Performed() wouldn't send multiple callbacks? I guess you'd need to step through and see what it does.
The only plausible situation I can see in which it wouldn't is if it thinks the executing interaction is not the active interaction for that action. But that seems unlikely.
But I can't actually find where the active interaction is set, so who knows.
@lucid tundra Okay, based on the implementation of ProcessDefaultInteraction it seems like Process will only be called when the control value actually changes? If so then unfortunately you probably can't make an Autofire interaction from a button.
...and yeah, actually the docs for IInputInteraction.Process say that explicitly.
okay I have got to be missing something obvious cause I'm 99% certain I've done this before
I've added in every single binding in the input system for both Mouse and Keyboard and a gamepad and an xbox controller specifically just to be safe, and I double checked the input bindings by assigning them through the listening system and pressing the buttons physically on my gamepad
and it still only registers the mouse and keyboard input and not any of the gamepad inputs when I test the game
the controller debug even shows that its able to recognize the inputs happening
it just doesn't like, pass them into the game
does anyone know if there's something obvious I'm missing to add just basic controller support to the new input system
Damn. Thanks for finding that. Shame it can't be done.
you're trying to use the old input system (by calling Input.GetKey) but you have the old system disabled and the new system enabled
you need to either enable the old system (by following the directions in the error message and changing the Player Settings) or change the way you're reading input to use the new system
thx but how I can enable the old system?
Better use the new input system
I'd guess this error is not coming from your code but from your StandaloneInput module that you need to upgrade to the new input system equivalent
Might be
Hi everyone,
I'm trying to do custom binding, but actually, even when I copy/paste, the original one is working but the copy doesn't work at all, what could I possibly missing ? '-'
Why is my "User 0" using Gamepad even when i don't have my Contoller connected?
It could be that the naming of the Action is different. One is names Click and the copy is Click 1; you can't have two actions with the same name.
You need to tell the UI where is going to be getting the actions, from Click or Click 1.
Need to enable the old input system; you can have both running if you like. You can do this on the player setting
What controller you using to test the game? what are your actions map look like and are you using the Player Input component or just a generated C# script for the input actions?
So I've managed to get most of the gamepad inputs working now, I believe there was an issue with it not swapping to the controller's control scheme setup, but now I'm having a completely different issue with the input system.
I'm using Xbox controllers primarily to test and the Player Input Component. The issue now is that my controllers are registering button inputs both on Press and Release, instead of only when pressing. Everything works as expected when using the keyboard for input, it's just that when using the controller for example if I try to pick up an item, I'll pick up one item when I press the button, and another when I release it, despite the input being set to only trigger on presses, and the code also only checking when the input is performed as a failsafe. And I've replicated this on other machines with other Xbox Controllers, despite keyboards working as expected there as well.
and the input action setup isn't exactly complex I'm just using the default button, though I've tried double checking by using the Press only interaction on it as well to no change
here's what that looks like just to be sure
Just to check, when you say "Xbox controllers" you mean XBox One or XBox 360 controllers, right? Because on the remote chance you actually mean OG XBox controllers, those had analogue face buttons which could make things work differently.
lol we aren't using the Dukes
I am trying to change unity Input Manager Horizontal keybindings in script, is it possible? (old input system)
I understood that its only possible going manually in Edit > Project Settings > Input Manager
It is not possible.
thought so, thank you
Hi all, I'm attempting to make a custom InputDevice for the Input System. It's throwing an error that I think may be due to some bug in the Input System GUI itself - specifically, the lack of an icon image for a layout... I think
This is my code: https://pastebin.com/kC2MU00m
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.
When I open Unity, I get the single line of output:
Joy-Con (R) layout registered
If I try to open the Input Debugger, though, I get several errors, but the upper end of the errors/tracebacks are all the same:
ArgumentNullException: Value cannot be null.
Parameter name: layoutName
UnityEngine.InputSystem.Editor.EditorInputControlLayoutCache.GetIconForLayout (System.String layoutName) (at InputSystem/Packages/com.unity.inputsystem/InputSystem/Editor/EditorInputControlLayoutCache.cs:151)
UnityEngine.InputSystem.Editor.EditorInputControlLayoutCache.GetIconForLayout (System.String layoutName) (at InputSystem/Packages/com.unity.inputsystem/InputSystem/Editor/EditorInputControlLayoutCache.cs:176)
UnityEngine.InputSystem.Editor.InputDebuggerWindow+InputSystemTreeView.AddControlLayouts (UnityEditor.IMGUI.Controls.TreeViewItem parent, System.Int32& id) (at InputSystem/Packages/com.unity.inputsystem/InputSystem/Editor/Debugger/InputDebuggerWindow.cs:727)
UnityEngine.InputSystem.Editor.InputDebuggerWindow+InputSystemTreeView.BuildRoot () (at InputSystem/Packages/com.unity.inputsystem/InputSystem/Editor/Debugger/InputDebuggerWindow.cs:586)
UnityEditor.IMGUI.Controls.TreeView+TreeViewControlDataSource.FetchData () (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/TreeView/TreeViewControl/TreeViewControlDataSource.cs:53)
UnityEditor.IMGUI.Controls.TreeViewDataSource.ReloadData () (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/TreeView/TreeViewDataSource.cs:54)
UnityEditor.IMGUI.Controls.TreeView+TreeViewControlDataSource.ReloadData () (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/TreeView/TreeViewControl/TreeViewControlDataSource.cs:25)
UnityEditor.IMGUI.Controls.TreeViewController.ReloadData () (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/TreeView/TreeViewController.cs:298)
UnityEditor.IMGUI.Controls.TreeView.Reload () (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/TreeView/TreeViewControl/TreeViewControl.cs:114)
Does anyone know why this would be happening, and how I could fix it?
how do i get the value from an axis action?
action.ReadValue<float>()
Mouse.current is null. How do i get the mouse position?
I figured it out. I had to add the mouse as a supported device in ProjectSettings.^^
Ok, I was able to get the input working, but when I put the value in a debug log, it reads zero no matter what.
Last I checked the current release doesn't, but there's a pull request in testing that will hopefully make it into the next release.
That is so sad. thanks for the awnser
The same way you handled the Fire button?
how can I make tap and hold exclusive? so if a hold event is triggered, the tap isn't?
for the same action of course, e.g. lmb
Why not two actions
two actions is fine, but the question is the same
You basically have to delay processing your "tap" until you're sure that it wasn't a hold
<@&502884371011731486>
HD Rumble on the Joy-Cons with the Input System! https://cdn.discordapp.com/attachments/685516923903279104/917287578955300914/IMG_4883.mov
Now if only I could figure out how to get full input reports, instead of the event-based HID ones...
Hey all, I'm looking for a solution, just needing a nudge in the right direction. What is the notion/code that allows you to swtich between one Player Object with an Input System to Another?
I have a car that works, and a player that runs, and I know how I'll pair them to place the player-avatar in the car (parented to a null), but... what function is there to let us "change focus" :/
one possible approach is to have a different action map for each one. So you have a car action map and a player action map, and the car script only listens to the car map and the player script only listens to the player map, and you switch between them by switching action maps
that approach makes sense if the controls are pretty different for each one. If the controls are essentially the same, doing something else might make more sense. For example, enabling/disabling the PlayerInput component on each object depending on which one is active.
(assuming you're using PlayerInput)
So, if they are similar, then it's really just switching States, and changing the Camera's parent?
Walking to Driving State? And then map new behaviors?
yeah
I mean, there's a million different ways you could do it, so if that's intuitive for you, go for it
Thank for this, just realized (as it's a car script I aquired) that on a Tehcnicality both entities are engaged AND letting me move them untill I figure this out. Gotta find the function in VS that'll let me switch cameras.
IF I disable a script on an object before runtime, can I enable it via code if the script is sitting on there, just unchecked?
Prolly just change their Priority.
yes, you can enable a script that started disabled. Awake/OnEnable/Start will not get called until the script is enabled for the first time, though
So, better to start with it On, and then disable it right-away at runtime? (for my car in this example).
🤷♂️ I guess so if you need to initialize it early. For me, the ideal would be to be able to set to the correct state and not worry about toggling it. But its probably not worth worrying about too much either way
Anyone know how to create an input-based replay system? Or can point me in the right direction?
i am trying to control the cinemachine camera with the joystick on my controller but whenever i use joystick input the camera just spins around but it works fine when i use the mouse. its not my controller thats the issue cause the sticks work perfectly fine in every game i play
hy guys
someone can help me?
I started using PlayerInput yesterday but I've been having some problems like it regarding MissingReferenceException
protected void Awake(){
manager = GetComponent<P_Manager>();
if(playerInput != null && gameObject != null){
medoAction = playerInput.actions["medo"];
}
}
private void OnEnable(){
//works
medoAction.canceled += ctx => SimpleFreeze();
// dont works
medoAction.canceled += ctx => manager.medo.SimpleFreeze();
}
private void SimpleFreeze(){
if(manager.medo != null) manager.medo.SimpleFreeze();
}
In the example above the code that checks if "manager.medo" is null before running works but the other one doesn't, I know that "manager.medo" is never null but if it doesn't check it accuses as null I would have something I can try to avoid so many "ifs" since i know "manager" or "manager.medo" is never null?
Sorry for bad english.
i shold verify in all call or have bugs on my code?
Please post code according to the guidelines in #854851968446365696
Please also share a complete error message including the file and line number of the error, or it's hard to help
I started using PlayerInput yesterday but I've been having some problems like it regarding MissingReferenceException
protected void Awake(){
manager = GetComponent<P_Manager>();
if(playerInput != null && gameObject != null){
medoAction = playerInput.actions["medo"];
}
}
private void OnEnable(){
//works
medoAction.canceled += ctx => SimpleFreeze();
// dont works
medoAction.canceled += ctx => manager.medo.SimpleFreeze();
}
private void SimpleFreeze(){
if(manager.medo != null) manager.medo.SimpleFreeze();
}
*on "dont works" (line 21) i get Exception from MissingReferenceException
In the example above the code that checks if "manager.medo" is null before running works but the other one doesn't, I know that "manager.medo" is never null but if it doesn't check it accuses as null I would have something I can try to avoid so many "ifs" since i know "manager" or "manager.medo" is never null?
Sorry for bad english.
allright?
public void OnAttack(InputValue value)
{
OnAttackInput(value.isPressed);
}
I have this input which works fine, currently following the unity starter assets using a bool. the problem now where I want to get similar to Input.GetKeyUp , how do I achieve this?
subscribe to .canceled
where would I add that? because the new Input is confusing on the starter assets is different from tutorials I've seen on YT shows a different approach then unity fps starter assets inouts
best way to work with the new input system is to let it generate the c# class, then reference an instance in your script and subscribe to the events e.g. _myControls.Player.Fire.performed .cancelled etc
In new or old input system is there anyways to reset Keyboard values in webgl?
I don't see the generated C# class from unity starter assets that's what I'm saying
then check if the checkbox is ticked
the new input system is quite flexible and there are many different ways to use it. Any tutorial you see is only going to cover one approach of many.
Is there anyone here familiar with the inner workings of the Input System? I'd like to do manual processing on data I receive from a HID device before exposing it to the user, but I'm not sure how to go about that. I posted a thread on the Unity Forums here: https://forum.unity.com/threads/manually-processing-iinputstatetypeinfo-data-before-exposing-to-user.1208461/
At the moment the biggest issue seems to be moving data from the IInputStateTypeInfo structure to the InputDevice without exposing that data as an InputControl first
Hey, is there a way to get a keyboard input, even if the game is Minimized?
i think that unity pauses keyboard input while game is minimied, if there is a way for that it probably is on configuration, and not trough code
hi everyone, I'm using the old input manager and I was wondering...in the deadzone field, is that supposed to be a number between -1 and 1? Or is something else supposed to go in there?
how dose */{Submit} map to any buttons. On Switch the npad is not producing a valid {Submit} for the EventSystem
What are you trying to do?
How are you approaching the tap?
I'm using the generated wrapper class and an Input Reader Scriptable Object to send those signals to various scripts.
However I have one input that doesnt appear to be firing.
its the only input in its Action Map (a button to advance dialogue) but according to Debug Log messages I do have it enabled
(The SO is based off the one in the Chop-Chop Open Project, but it works fine for every other action)
Ok on checking with a debug button on all input maps, the Dialogue input map just is not responding
Anyone have any ideas?
Have you maybe set it as value instead of button?
no its set as Button :/
i figured it out. I forgot to use SetCallbacks for the action maps i added in
How to assign to InputActionReference an InputAction by code if it is not assigned by inspector?
public InputActionReference input;
protected override void Awake()
{
base.Awake();
if (input == null)
{
CustomInputActionMaps iam = new CustomInputActionMaps();
input = ;
}
input.action.Enable();
}
Does InputActionReference.Set not work?
I mean, the class only has that one method so it's most likely that or nothing.
it gives me nullref
input.Set(iam.Test.Action); like this gives error because input is null
InputActionReference.Set doesn't exist
What version are you on?
Oh, wait, I see what you mean. If input is null then you can just create a new InputActionReference at runtime and as far as I know it should work fine.
how to create a new InputActionReference?
Hi! How can I read input from a PlayerInput script? Previously I did it creating a new InputActions and reading the actions, but I dont know how to do that with the playerinput
There's many tutorials floating around on the subject, and several ways to do it
@austere grotto Well, yeah, but where :/
I have the playerinput component, I want to read from it. I dont find how
When I created the actions I did this, but i dont know how to replicate it
movement = InputManager.inputActions.Player.Movement;
InputManager.inputActions.Player.Jump.performed += DoJump;
firstPersonCamera.SetActive(true);
}
private void OnDisable() {
InputManager.inputActions.Player.Jump.performed -= DoJump;
firstPersonCamera.SetActive(false);
}```
Good place to start would be the documentation
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/api/UnityEngine.InputSystem.PlayerInput.html
Already took a look to it. Nothing
It has code examples
@austere grotto Do you know if InputActionReference needs some kind of special treatment when used in a class inheriting from NetworkBehaviour?
no
it doesn't
other than the fact that you should make sure you're only processing input on appropriate objects, such as those that the local player should have control over
Alright, because I'm not getting any input readings from a Vector2 action for moving.
Could it be because the player prefab (containing the script with serialized InputActionReference) is instantiated via NetworkManager?
I had to enable the action...
There's different ways to approach the inputs using the scripts, this is my personal approach:
public class PlayersInputs : MonoBehaviour
{
private Players_InputActions _playerInput;
private InputAction _moveAction;
private InputAction _lookAction;
private InputAction _fireAction;
private void OnEnable()
{
_playerInput = new Players_InputActions();
_playerInput.Enable();
_moveAction = _playerInput.Player.Move;
_moveAction.Enable();
_lookAction = _playerInput.Player.Look;
_lookAction.Enable();
_fireAction = _playerInput.Player.Fire;
_moveAction.Enable();
}
public Vector2 OnMove()
{
return _moveAction.ReadValue<Vector2>();
}
public Vector2 OnLook()
{
return _lookAction.ReadValue<Vector2>();
}
private void OnDisable()
{
_playerInput.Disable();
_moveAction.Disable();
_lookAction.Disable();
_fireAction.Disable();
}
}
if your using the Player Input Component this is how I do it:
private PlayerInput _playerInput;
private InputAction _moveAction;
private InputAction _lookAction;
private void Start()
{
_playerInput = GetComponent<PlayerInput>();
_moveAction = _playerInput.actions["Move"];
_lookAction = _playerInput.actions["Look"];
}
Once you have the player Input component attach to your player select the Input Actions Map of your liking.
@tidal sedge With the PlayerInput Component, that actions["name"], do you know how it behaves it the same action its in two different sets? Cannot test it yet
For example, if you have a set for moving on foot, another in a vehicle, and have Look in both
If your using the Player Input Component you can only use One Action Map and that is normally the Player one; inside the action you can have a regular "Move" and another one called "MoveOnVehicle" and just called it like actions["MoveOnVehicle"] if there not sharing any similarity on the input actions(gamepad, keyboard,etc).
But if you like to have two sets with different "Move" behavior then I suggest have two different action maps and both of them being have there own generates C# script.
Oh hey! It's Rehtse! How you doing?
@tidal sedge Yeah! I have two action maps, like you have one for the player and one for the UI. Currently I'm using the UnityEvents so I can register in each Action Map action what I want, but cannot find how would I do it without using the inspector
This is what I currently do. But dont know how to add the event from code
And below that player collapsable its the other action map with the same things
Let me dig my old scripts, I think I may know what your trying to do
@tidal sedge Sure, thanks!
@tidal sedge No reaction gifs, please.
You are looking to do something like this
Got it👍🏽 Thanks for letting me know
Oh, you use the SendMessages option, yeah, I can get a similar behaviour with the events, the problem was more about reading from another external scripts, but dont worry, I can use the event method, or your method to read in a script, and then make everyone else read from it. Thanks!
when I use the sendmessages behavior on input system how can I check if the action is "started", "performed" or "cancled"
You can't. Don't use sendMessages if you need to check that.
useless system
To check for "Started", "Performed" and / or "Canceled" you need to use Invoke Unity Events
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Components.html
there's another way
with send messages
it's stupid that it has to be done this way tho
this isn't using SendMessages though
in fact it's basically bypassing the PlayerInput component entirely
if you're gonna do that you may as well just use an InputActionReference directly
Or a direct reference to the InputActionAsset
what's the point of sendmessage then
Quick prototyping?
PlayerInput is useless in general in my opinion, unless you're specifically making a local multiplayer game
I don't use it.
i hate the new input system
I prefer these approaches myself
there's no right way to use this stupid system
i just wish they sent more information to sendmessages
then i won't have to do extra work
uh why doesn't
Keyboard.current.anyKey.wasPressedThisFrame
work in maximaze on play for me?
i see no reason for it not to work
ah nvm, it doesn't work if i enable maximaze on play during play mode
why is the description the same for 3 different interactions?
? the descriptions are different
pretty much the same
because they work the same way?
I think there should be more of an explanation as to how those differ - they sound very similar
indeed
it describes perfectly what each one does though
no
Sounds like HoldInteraction only requires the button be held, whereas SlowTap requires the button be released afterwards
yes. as is written in the docs
I'm still having trouble understanding the difference between SlowTap and Tap
The docs could do a much better job of describing why these are different
I should not have to squint at the blocks of text for an extended period of time to understand them 😛
no different than tap
you don't have to
cause you can just change the numer
correct. but then you won't have the possibility to have 2 seperate actions
what
slow tap and tap

don't complain about features you don't fully understand
can't understand them if they aren't explained
they are though
not really
Not well enough
as you can see by the fact that multiple people are having trouble understanding them 😛
it's the users that are the problem
what you need to know is written in the docs. what general knowledge you need aka what is slow tap and what is tap, is general knowledge which needn't be in the docs
slow tap is a slow tap where as a tap is a normal tap
which is faster than slow tap
i'm pretty sure the 'slow' would make that obvious
I mean honestly your explanation there makes more sense to me than the one on the Unity site
but that is general knowledge. this doesn't belong in the docs
I suppose it's general knowledge? the docs should definitely have some kind of reasoning for why there are two identical classes though still
2 identical classes?
tap and slow tap
same functionality
The descriptions are identical, with the exceptions of "and" (which is a typo), and "defaultSlowTapTime" versus "defaultTapTime"
yes. cause there is no other difference that needs to be taken into account
hell wouldn't hold work the same way?
no. cause hold doesn't wait for release
if you add a small timer to hold then it's technically a tap
of course you can also build your own logic. but that doesn't make anything that exists bad or useless
that's called bloat
and that's what i call not understanding devs. all the built in actions are frequently used by lots of devs. so why would everyone need to build their own solution if it ends up the same as every one elses anyway? that's not bloat
bloat is when there are features that are heavy and are only used by a small amount of people
I mean from what I see no one uses these interactions
there's enough info in the callback context to do these functions on your own
slow tap on pc is less often used but super often on mobile
of course. they are all built UPON the callback context. so of course there's enough info. if you hadn't that would be terrible. but 95% of the time you don't need the callback context because there's already a feature built in.
so tell me
am i doing pretty normal for my own custom binding system?
oh wait
it was supposted to be moveInput.x on the right
but ignore that
aight, added it to static
Okay it works fast
O.o
what???
Is Unity itself complaining about it, or just VS/VS Code?
I've found that at any given time there's like a 50% chance of IntelliSense working in VS Code
that's because how unity project setups / solutions work
yeah... it always seems to work fine with Python projects and such, it's only ever Unity projects I get this with 😦
ok how do i use this
this makes no sense to me except for the triggering things and i don't know if it's even right
what?
the whole input system
I can tell how to trigger events but i don't even know if it's right
well....if it's right they should do the things you want them to do
Do I put the player input component on the player?
i don't recommend using the player input component
what should I use then
let it generate the c# class and then work with that
player input is good if you aren't doing anything advanced
generating a c# class can make your code messy if you're a beginner
having to enable every single action
Would having a button remapping screen be "advanced"
haven't tried it but it doesn't seem too hard
So playerinput would be fine for it?
you don't need to enable every single action. you should only enable the ones you need.
if you need all from a specific action map, you can and should just enable the action map.
if you need all from all control schemes you can and should just enable the whole controls
there is a button remapping sample available btw
I have an project with Input System all set up. I also have an object without rigidbody and a free look camera which works just fine. BUT, as long as I try to assign a rigidbody component to my object, I lose the ability to rotate the camera. It feels just a there no input or something like this. What could have been the problem?
Setting my Rigidbody to Kinematic fixes this problem, but thats not what I need.
Ok
How can I edit an InputActions from script
for example get the next keyboard input and set a playerprefs value to it, and have a script that updates the InputActions to have that value for attack
can you share some picture?
I have use the input system with Rigidbody and never had this problem.
@tidal sedge are you still here? If yes, I am going to be on in 5 minutes. Can you take a glance at my screen share, mic is not needed.
just realized there is no voice channel over here.
Hey guys,
I tried to use the new Input System but every times i push a touch the vector is not update (it stay at 0 0 0) and if i not print the controls i don't know why my var is null
Here is my code:
public int movespeed;
private Controls controls;
private Vector2 vec;
void Awake() {
Debug.Log("Initialisation Player ...");
controls = new Controls();
Debug.Log(controls);
}
private void OnEnable() {
controls.Enable();
}
private void OnDisable() {
controls.Disable();
}
public void OnPlayerMove() {
Debug.Log(controls.Movement.PlayerMove.ReadValue<Vector2>());
vec = controls.Movement.PlayerMove.ReadValue<Vector2>();
Debug.Log(vec);
}
void FixedUpdate() {
transform.Translate(movespeed * Time.deltaTime * vec);
}```
You never subscribed to any of the input actions or anything
they are reading the value in OnPlayerMove()
Which is not being called anywhere
maybe external?
It's named as if they're expecting it to work how PlayerInput in SendMessages mode works
So I'm assuming that's the mistake being made
true......
Where i need to read the value ? In awake ?
You need to subscribe to the performed event of PlayerMove
Okey but how ?
or read it in OnUpdate()
So OnPlayerMove() is useless ?
Or use the interface method of which there's example code for here https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/ActionAssets.html
Where you do .SetCallbacks(this)
Currently it is useless yes
unity does not call OnPlayerMove() automatically. if you want to then call OnPlayerMove in OnUpdate()
There's many ways to approach this
Anyone know why UI buttons sometimes trigger two OnClick events when using the new input system?
Someone can told me what is the value of this input action
none
is it possible to set him to 1 or 0 o directly a boolean
don't know what you mean
i want to make a jump touch so i just need to know if the touch is press
then subscribe to the event
But for read the value i need to know the value
{
public int movespeed = 1;
private InputAction move;
private InputAction jump;
public PlayerInput controls;
private void FixedUpdate() {
Vector2 position = move.ReadValue<Vector2>();
transform.Translate(position * movespeed * Time.deltaTime);
Debug.Log(jump);
}
private void OnEnable() {
move = controls.actions["PlayerMove"];
jump = controls.actions["Jump"];
move.Enable();
}
private void OnDisable() {
move.Disable();
}
}```
but you don't need the value for jumping
okey so how i can detect when the touch is pressed ?
subscribe to the event
The triggered property of the action will do this (with caveats; in particular I believe it doesn't work in FixedUpdate unless you specifically set up the InputSystem to work in FixedUpdate rather than Update), but as Mindstyler says it's better to set up a callback function and subscribe to the events you care about; you're likely to have fewer problems in the long term if you do things that way.
After implementing the new InputSystem, buttons have become unclickable, they just won't interact when I put my mouse on them
does your canvas have Graphic Raycaster?
Waht's Scene Nav?
Why is your canvas etc a child of the camera?
Float 0 or 1
thnx u so much
i cant grab the InputSystem class after installing it thru the package manger, am i doing it wrong?
Theres no Inputsystem class
You have to creat a Input Action Map, generate a c# script if you wish to call it by script.
Have a look at this:
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/index.html
Is there a way to map multiple controllers to a single player? I'm trying to use both the left and right Joy-Cons to control a single player via the Player Input component, but it looks like it may only allow the player to correspond to one of them at a time
...just figured out I can just tell the control scheme it requires two copies of Joy-Con
Guys, a little quick question. Is the Input System ready to be used in production/serious projects?
yes
Hi all, I'm looking to make a 2D game right now and am looking to use the PlayerController.cs script in the InputSystem example project. Does anyone know Unity's take on using code/assets in their example projects?
Edit: This is the relevant repo https://github.com/UnityTechnologies/InputSystem_Warriors
i dont think they care
Unless it is specifically stated in the Unity tutorial that asset used is not for commercial use, it's fine. Only precedent I know of, of Unity going after a tutorial used commercially is when it was published on Steam as is as a complete game.
What version of unity your using?
2020LTS
Close Unity and restart your PC / Laptop and then try again
do it need additional package?
maybe it's cuz of i didn't install other packages
Nope
and also i disable some built-in packages like VR-AR and these kind of un-necessary packges
thanks
Thank you!
hi guys, does anybody know why the playstation controller wont work with the new input system?
Xbox controller works fine, but the PS controllers dont work..
does your controller work on other programs
yes
hi, somebody know what going wrong ? (it doesn't work,it always false)
you can't read bool from that. use events
with the player input component ?
playerInputActions.Player.Phone.triggered don't work too
.performed
ok i try
i put playerInputActions.Player.Phone.started/performed += buttonPhonePerformed; in the start method and the debug.log(context) on the buttonPhonePerformed method and it's not working :/
your input responses shouldn't have to be in update
so i put playerInputActions.Player.Phone.started/performed += buttonPhonePerformed; in update method ? 🤔
are you using the player input component?
no. did you enable the asset?
on my player gameobject yes but this script is on GameManager gameobject
yeah so i need to use the event on player input component
i believed i can trigger a simple action on gameManager script 😢
do you know how unity events work?
yes my mouvement and jump are made with the player input component
but i think i don't know all i can do with the new input system
it takes some time to learn how it works
keep looking at tutorials
you won't be able to master it in one day
he doesn't cover everything
ok thanks
Buttons tend to have a value of float, to change it, similar with what you have I share my approach in the pic.
oh thanks you ^^
you don't need the ternary. just compare to != 0
Really??👀 I’ll try that later, thank for the tip.
Hey folks!
Is anybody familiar with how the input system internals work?
I'm trying to study it for my own engine and to learn even more about game engines...
But I'm having a bit of a hard time figuring out how the event propagation happens
you could look at the git
that is what i have been doing 😅
I've learned a bit about building custom controller input stuff over the past week or so, but that's about it...
I believe the very high level flow is: InputActionState objects register to receive IInputStateChangeMonitor.NotifyControlStateChanged events from the InputManager when their bindings change value; they pass those value changes on to their interactions which call methods on the InputInteractionContext to change action phase and trigger callbacks into user code. But if you want more detail than that, or anything about the InputManager-to-bindings side, you'll have to dig through the code yourself; I don't know much more off the top of my head.
I'm mainly confused about how the composite works
So im writing a VERY simple line of code, like click the mouse and say "click" kinda stuff, but it isnt detecting any inputs at all. but the default player character controller provided by unity works just fine. Anyone know why this might be?
Example
Have you tried somerthing like
(Input.GetKey(KeyCode.Mouse0)
yeah still no response unfortunately
I am in HDRP but that shouldnt be an issue as far as i know, do other objects like UI maybe cause a disturbance to inputs? I tried looking at the input controller unity provided but they dont reference the mouse button at all so there shouldnt be anything else battling for priority
Have you imported the new Input System? I remember hearing it disables the old Input System stuff
i havent' imported anything manually but I am on the newest version of unity, is there a new way how the input system works?
Yes, the new Input System works differently from the old one. It might auto-import the package; can you go to the Package Manager and see if there's a package called "Input System" in there?
Yeah it says that it is installed to version 1.0.2, is there a way i can go back to previous version and try that?
or is there a resource I can learn about how to use the new input system in C#
- Did you attach your script to any objects in the scene?
- Are you seeing any errors in your console window?
originally it was attached to my character but i tried attaching it to just a general object in the scene and still nothing, and no no errors, but i did remake the scene in a earlier version of unity and it works so it does seem to be the new input system, is there a way to combine the two input systems or choose one over the other?
Yes you can choose your input system by selecting a setting for "Active Input Handling" in Project Settings -> Player
If you don't see any logs or errors in your console after attaching the script to an active object in the scene, I'd guess you've disabled one or more of them or are simply not looking at the correct window.
Also dumb question, but you did run the game right? Hit the play button?
yeah, both of the objects were active at the time, and yes I was in play mode.
Can you show a scxreenshot of your console window?
i might just be super unfamilier with the new input system, and yeah one sec
And yes this code is old input system code
so it's not going to work if you're using the new system, but you should at least get an error in the console
well it does seem there are a new few errors that i didnt see before which is strange
although when i changed it to the old input manager it works perfectly with no errors
yes because the code you have is "old input manager" code
hey all, I'm getting this error and I can't really figure out what's going wrong here:
can anyone help me out?
I'm using UnityEngine.InputSystem.XR
does swapping to the input system have any performance benefits if i only have a single mouse click in the game?
Currently im just using Input.GetMouseButtonDown(0)
marginally? but the new input system really is for easy complex input. not only a single action. so you probably don't need to bother
yeah thing is im wondering if theres any build size difference and performance
im guessing it wil even increase in size since the package is more complex than the barebones old input system
but im also wondering when they will just end up removing the old one so i can futureproof
hopefully soonish
eeeh hopefully not if its overall less performant
wish there were official stats on how much resources it uses compared to the old one
it's not less performant
You sure? it has quite a lot of string variables in there that seem to be used for identifying stuff
its certainly more flexible, not sure if more performant
Time.timeScale = 0f; does the input system still work ?
yes
not for me i had to update the code.
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
public class Menu : MonoBehaviour
{
[Tooltip("The menu panel")]
[SerializeField]
private GameObject _menuPanel;
public static Menu Instance { get; private set; }
private void Awake()
{
if (Instance == null)
{
Instance = this;
}
else
{
Destroy(gameObject);
}
}
public void ToggleMenu()
{
_menuPanel.SetActive(!_menuPanel.activeSelf);
if (InputSystem.settings.updateMode == InputSettings.UpdateMode.ProcessEventsInFixedUpdate)
{
InputSystem.settings.updateMode = InputSettings.UpdateMode.ProcessEventsInDynamicUpdate;
}
else
{
InputSystem.settings.updateMode = InputSettings.UpdateMode.ProcessEventsInFixedUpdate;
}
Time.timeScale = Time.timeScale == 1f ? 0f : 1f;
AudioListener.pause = !AudioListener.pause;
}
private void Reset()
{
Time.timeScale = 1f;
AudioListener.pause = false;
}
public void LoadGame()
{
Reset();
SceneManager.LoadScene(0);
}
public void QuitGame()
{
Application.Quit();
}
}```
whats the equivalent of Input.GetMouseButtonDown(0) in the new system?
you aren't supposed to get a reference to the button itself
the new system uses "actions"
they're like events
basically each button triggers a method, and what happens in that method is up to you
well im literally just using left mouse click and nothing else
you won't even need an update loop in your player class if you set it up
im ending up using Mouse.current.leftButton.wasPressedThisFrame
seems to have worked
but damn, IL2CPP build of the game now adds 9mb with the new input system...
how do u have so much more stuff for an input system
i mean old input also does the same....just more boilerplate stuff
it's geared for heafty projects
so i assume performance would also be worse then?
no
just projects that have complex controls
hmm
well, runs pretty damn nicely
still find it hilarious it uses less cpu and gpu than watching a video
@jagged wyvern should i use that input actions file to swap out of the Update methods?
the file that was created from the controller scheme?
no, you make a new instance of it, and subscribe to the methods
i mean instead of doing Mouse.current.leftButton.wasPressedThisFrame in an Update if check, i do the actions callback
yeah
do i need to manually add the input action stuff? i cant just do a new ?
never mind 😛
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem.LowLevel;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Users;
[SerializeField] PlayerInput playerInput;
public Mouse virtualMouse;
public RectTransform cursor;
void OnEnable()
{
if(virtualMouse == null)
{
virtualMouse = (Mouse)InputSystem.AddDevice("VirtualMouse");
}
else if(!virtualMouse.added)
{
InputSystem.AddDevice(virtualMouse);
}
InputUser.PerformPairingWithDevice(virtualMouse, playerInput.user); // <= doesnt work (not allowing me to put playerInput.user.
if(cursor != null)
{
Vector2 pos = cursor.anchoredPosition;
InputState.Change(virtualMouse.position, pos);
}
InputSystem.onAfterUpdate += UpdateMotion;
}
```
not on unity rn so i dont have the actual error but does anyone know why this isnt working, Thanks.
really hard to say without the error message
ill go and get it now
ill be back in 5mins
or more
idk
slow laptop
'PlayerInput' does not contain a definition for 'user' and no accessible extension method 'user' accepting a first argument of type 'PlayerInput' could be found
Did you name your input actions asset "PlayerInput" by any chance?
What version of input system are you using
Input might do it too 😛
can anyone help me?
ArgumentException: Input Button Interact is not setup.
To change the input settings use: Edit -> Settings -> Input
cant figure out what unity wants from me
i never changed the settings
1.0.2
ill see if that changes anything
Still getting the error
Cmd + click on the word PlayerInput
Or Ctrl
Where does it take you?
Did you make your own script with that name for example?
Omg I'm so dum
Thanks I figured out
I just lack iq
I'm using Unity 2020.3.1f1, by default it doen't have the options to create a input actions, when I install the new input system, the program launch this warning, I just press yes? or that will give me errors?
Press yes if you want to switch to the new system
If you have any code that uses the old system it will not work anymore and you will need to rewrite the input handling using the new system
So I'm having a issue on android with screen touches get counted as the mouse and I was wondering if it's possible to turn that off on the input menu or if I'm going to have to go thru and change code to ignore Mouse entirely while on Android or IOS
I have gui touch control but my guy just spins and shoots consistently when pushing on the gui
I don't think it can be turned off in the menu but you can set this from a script
I can't believe I couldn't find that on my own, thank you
That's what I was doing too and was starting irritate me as it's the last bug on my android builds
So I got it to work as it no longer spams firing the gun but Unity Input still recognizes that it's being moved so the guy still rotates his head on touch so I need to also see if I can have it not register touches outside of my gui
Well or just disable the mouse in all and recode the controllers to use new input names and continue to allow those to move the guy I guess. I hate to have to recode a lot of my player controller but oh well
what Control Type is associated with scrolling the mouse wheel?
int example = Input.GetAxis("MouseScrollWheel");
This will give a value from the range of -1 to 1 depending upon the mouse scroll wheel input while there is no input the value will be 0 and upon up mose scroll the value is 1 and for mouse scroll down it gives a value of -1
I think I found my answer. Vector 2 seems to work as the Control Type for a mouse scroll binding
Why doesnt the method get called?
private InputControls input;
private void Awake()
{
DontDestroyOnLoad(this);
input = new InputControls();
input.Default.LMB.performed += LMB_performed;
}```
^ for some reason i had to do input.Enable(); - does it not start enabled?
Correct
weird
hi i'm back with a UI problem x)
i have this
but it's not really selected (when i hover the button it work)
the eventSystem.setSelectedGameobject don't really work
how can i make the inputfield return the text of it?
its always returning 0, i want it to return its text as string
what's returning 0?
eh nvm
You need to select youir method from the Dynamic list instead of the Static list or it will pass the data in that field instead of the "dynamic" data from the inputfield
can someone please link me the API documentation for the new input system UnityEngine.InputSystem. I feel like an idiot for not being able to find it
Unity Remote is not currently compatible with the new Input System; you should test on the device itself.
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.2/manual/index.html (then "Scripting API" at the top).
The docs for packages can be a little difficult to find, but in general they're linked from their pages under the "Packages" section in the main Unity docs.
thank you ❤️
but my methods are only in static list
For the UI are you using the On-Button Script of the new input system?
that means your method doesn't have the correct signature (doesn't have the correct parameter(s))
Does anyone have any sample code for a simple input system? I've been looking online on how to use the input system and every time i press a wasd key with the script and action map present, my sphere never moves
they got samples in the package manager
Input System package has examples in the description which can be imported.
Anyone can tell me what i need to do to fix this? I am using the Input system. If i press play and move the mouse then once loaded, my controls go crazy. If i leave the mouse above the play button it does not do it. I assume maybe i need to disable the input up until a certain point?
i have an input action set as a button but it sets attacking to true even if the button is held
how can i set it true only once?
use a coroutine?
I've tried adding an interaction but it doesn't work
nvm cancelling is overiding the perfomed action
not sure why
is there a way to check if started happened this frame?
does started and performed happen at the same time?
Does Unity natively support phone accelerometer input?
Cool cool, maybe I download a newer version
any suggestions on preventing EnhancedTouch from triggering events when clicking UI elements? I've tried using IsPointerOverGameObject but it doesn't seem to work with OnFingerDown and throws warnings
anyone have any clues as to why my input system works fine in editor but when I build no input works at all?
can you share the code?
Use this: https://carbon.now.sh/
What are you using the Enhanced Touch for?
There's a way to check if you press a button by frame, similar to Input.GetKeyDown(). I have used it only if I have installed the new input system but the beta versions, when you called the action button you need to see if you are able to use this
wasPressedThisFrame
Yeah I will post it. It’s just standard set up using unity events though. Calling function and setting the input value.
i can't find that property inside of the callback context
🤔
interesting
With 2 keybinds attached to a single action, is it possible to reset the action when a second keybind was pressed while the first was still being held?
What currently happens:
ctx.started
press K
Nothing
depress J
Nothing
depress K
ctx.cancelled```
What I want it to do:
```press J
ctx.started
press K
ctx.cancelled
ctx.started
depress J
Nothing
depress K
ctx.cancelled```
probably not without wrriting a custom interaction
Simplest thing might be just to use two InputActions and handle the logic yourself
That's what I thought, thank you!
hey im working on my little 3D fps game
my problem is that i want to detect when i tap W and the hold it
like in minecaft if u wanna sprint : ```tap W
Hold W
You basically need a small state machine:
[start] - tap -> [waiting] - tap within 0.5s -> [sprinting] - release -> [start]
- no input within 0.5s -> [start]
Actually you might need another state there where you need to release the initial tap within a certain time too to consider it a tap
okay i guess i understand thx
tap - cs if (Input.GetMouseButton(0)) { stuff }
?
You actually need two states there
one for ButtonDown
then you get to the next state with a ButtonUp within a certian time frame
so like:
[start] -- buttonDown --> [waitforrelease] -- buttonUp within .5s --> [waiting] -- buttonDown within 0.5s --> [sprinting]
oh sry i was looking at mouse input
so i can look up and down
but i cant look sideways
anything im missing out on?
i cant seem to figure it out
Are transform.parent and transform.root different objects? or the same?
if they're the same you're just overwriting the first line with the second line
so how do i detect the buttonDown and release and the button down
Input.GetMouseButtonDown(0)
Input.GetMouseButtonUp(0)
if (Input.GetKey("up"))
{
print("up arrow key is held down");
}
if (Input.GetKey("down"))
{
print("down arrow key is held down");
}```
wait
ill send you my code
and just GetKeyUp and down?
and maybe you can see whats wrong
no that's for detecting if the up or down arrow keys on the keyboard are currently depressed
I already saw your code
the whole code
Doesn't matter
Why didn't you answer my question
I already told you the problem
i really have no clue
You should try to get a clue
Follow it closer
Make sure you put the script on the correct object(s) and organized the object hierarchy the same way they did
That code would make more sense like this:
transform.localRotation = Quaternion.AngleAxis(-_currentRotation.y, Vector3.right);
transform.parent.localRotation = Quaternion.AngleAxis(-_currentRotation.x, Vector3.up);```
ok wait wait
i deleted a line
and now i can look sideways
BUT NOT UP
BRAIN HURTS
Because #🖱️┃input-system message
do you know how i can fix that?
what does this mean You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings. UnityEngine.Input.GetKeyUp (System.String name) (at <6af207ecd21044628913f7cc589986ae>:0) CharacterController_src.WSprint () (at Assets/Scripts/Character/CharacterController_src.cs:234) CharacterController_src.Update () (at Assets/Scripts/Character/CharacterController_src.cs:89)
does that mean that i cant use Input.GetKeyUp("W") in the same script that use defaultInput.Character.Movment.performed += e => input_Movment = e.ReadValue<Vector2>(); (the input manager)
script : >https://pastebin.com/Q1iEg9uy<
Did that
still didnt work
Correct, you can't use the old input system if you have disabled the old input system
If you want to use both (I don't advice it for performance reasons), you can enable both in the project settings
I recommend simply writing all your code using the new input system instead
ok
i get this You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings. UnityEngine.EventSystems.BaseInput.GetButtonDown (System.String buttonName) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/BaseInput.cs:126) UnityEngine.EventSystems.StandaloneInputModule.ShouldActivateModule () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:229) UnityEngine.EventSystems.EventSystem.Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:358)
You need to upgrade your StandaloneInputModule to the new version
It's a component on your EventSystem
?
there will be a button on it to upgrade it
fixed it
already
Sorry in advance if I can't post from Forums here. If anyone can see this and might be able to help / has an idea of what's going on.
https://forum.unity.com/threads/adding-virtual-devices-to-another-platform-doesnt-seem-to-work.1213161/
Hi, am trying to use the new input system to control a rigidbody and its causing pain
i can get it to work with the character controller but id rather use the rigidbody
Show what you're trying, what you expect to happen, and what is happening isntead
Why are you using Input.GetAxisRaw
that's old input system
you're not using the new system at all really
Basically I wrote this before and trying to rework it, I had it working with the new input system for the character controller, but it doesnt exactly work with rigidbody
at least from what ive tried
Ok but whatever you're showing me right now you're not even using the new system yet
You're creating and enabling/disabling a generated C# class from an Input Actions asset, but you're not using it
anyway what about this isn't working, other than the fact that it's using the old input system still?
what do you expect to happen and what is happening instead
ehhh, if im not using the new one properly it makes sense
im using the new input system so i can use touch controls
You can use touch controls in the old system too, FYI
yeah ik its just i spent like 3 hours fucking around to get it to work with the new one lmao
and then I realised i needed to change to rigidbody and now im back to square 1
But you didn't really 🤔 because this is still using the old one
anyway 3 hours is nothing
No I had it working using the character controller
so it works, i just dont know how to make it work with rigidbody
nothin is happening, Im basically trying to get it to move corresponding to an onscreen analogue stick
Well this isn't going to read any onscreen analogue sticks
Yeah im realising that now lmao
You're using Input.GetAxisRaw which reads from axes defined in the input manager - it's old system stuff
You need to actually read data from your PlayerInput thing
sweet, ima just go back to scouring the internet lmao
Should be something like:
PlayerInput.<action map name>.<action name>.ReadValue<Vector2>()
to get a Vector2 for movement
hm
Assuming your action is set up as a 2D composite
but it's gonna depend how you set up your input actions asset
Okay, cheers
Hey guys. Is there any reason some layouts are not loaded on a specific build? i.e for Standalone I can't find AndroidJoystick or any of the sensors. Can I force them to be loaded? I can't see why it would be bad for them to be loaded, aren't they just JSON strings?
private void Awake()
{
inputManager.InputActions.Primary.Movement.performed += Movement;
}
private void Movement(InputAction.CallbackContext ctx)
{
ray = cameraComponent.ScreenPointToRay(Mouse.current.position.ReadValue());
if (Physics.Raycast(ray, out target))
{
motor.MoveToPoint(target.point);
}
}```
So, I'm trying to get my controls working with the new input system, but I'm having trouble getting my left mouse and right mouse to function correctly. Well, they seem to fire off once correctly, but even after fooling around with all the binding properties, I've had no luck.
And after reading around, it seems the "hold" property isn't what I'm looking for.
Well, some threads have ways to make it work by forcing it to trigger through update, but that kinda defeats the purpose of this whole new input system, no?
What are you trying to do
I've got an isometric game using left click for the primary movement. Clicking and moving is working, but when it comes to holding down the mouse buttons, I can't seem to keep getting the input working.
What are you wanting "holding" the button to do?
With my left click I'm getting the mouse position for my raycast, so holding it down should be getting a new position every interval, while holding my right click allows for camera rotation so I need to constantly get the mouse axis.
Subscribe to started and cancelled. Set a bool true in started and false in cancelled. In update, if the bool is true, you do your Raycast etc
Or just check in update if it's currently depressed
Yeah, I see some code for doing that, but like I was saying. It seems odd this isn't implemented fully into the subscription system that seems to be the ideal of this thing.
Who said events were the "ideal"
So technically I'm just doing a hacky way to implement how I had it in the old way.
Some things are suited for events, some are not
True, even then some more control on how much I want to check for the position for these controls.
Overall, I guess I'm not checking 30 if statements anymore just for singular input so that's nice.
would using custom interactions in the input system work for making combo attacks?
like having to press a -> b -> y in succession
It's not something the input system is going to do for you
The best way to make something like that is using a state machine
ah alright
e.g.:
[start] - press a -> [waiting for b] - press b -> [waiting for y] - press y -> [perform attack]
Where you go back to [start] if the wrong button is pressed at any point.
makes sense thanks
https://puu.sh/IwXfD.png
Am I not able to use the old event system with the new input system or is there something I'm not understanding here? Apparently there's quite a lot of work that needs to be done to get drag/drop and other pointer features working with the new input system, so for now I think I'd like to leave it for later.
save your project and close/reopen unity and see if the error persists?
I've reverted back to old and back to both and it's still there. It's updated in the project settings so there's that.
The Unity Input System Guide for Installation is outdated. How do I get the newer versions of the Input System package installed? I have the project with proper .NET and a newer version of Unity, but it always just shows the older version of the Input System package.
Finally found it in some random post on the 1.2.0 version where someone else had a similar issue, so nevermind.
So, same question as in #💻┃code-beginner...
My button inputs appear to be triggered twice per frame, causing boolean flips (ex: running, crouching) not to trigger correctly.
How do I prevent this?
I'd double-check that Action Type is button, because other types process multiple times for...reasons. And then verify you didn't setup an event response along with the action response. I'm still learning about the new Input System a bit, but ran into that earlier and fixed it by checking those.
Well, as you can see in the screenshot, yes I have set the action type set to button. I'm not sure how I'd end up with multiple responses other than a duplicate Player Input component, but I don't.
So, I don't think that's it.
Probably because of the Behavior being set to events, then, perhaps. It processes the different stages of events instead of a single action response, I believe. If you changed it to "Send Messages" it may adjust that to a single button event. That seems only difference between mine and yours at the moment.
i have this function when i press tab defaultInput = new DefaultInput(); defaultInput.UI.Escape.performed += e => OpenSettings();
but it doesnt work
i even put a debug log there
this is the input map
https://pastebin.com/90cNaKCb this is the script
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.
defaultInput.Enable();
in awake?
Sure
is there a limit to how many action can be in an action map cause after the fifth it stopped they stopped working
Not that I know of
Does anyone have an idea why onDeviceChange doesn't fire at runtime but when I stop playing? And at seemingly random order.
Probably because it only fires at added or removed, right?
Or how would I go about recognising which device was used latest when not using PlayerInput?
OnActionChange works, I can get the device from activeControl
How do I read a value by Invoke Unity Events?
public void Move(InputAction.CallbackContext context)
{
Debug.Log(context);
}
context.action.ReadValue<T>()
Is there any difference regarding performance in any of them?
Probably, there's a lot of info provided by Unity, manual and such
You'll find it there
Send messages require certain amount of magic under the hood to do what they do, especially for the first run. Unity Events are C# events with the editor support, so C# events are likely the fastest option, but also probably the least convenient one.
Is there a way to receive what binding was pressed, or should I be making them separate actions instead? I've a lot more hotkeys coming so I'd prefer if I could do it this way somehow.
Make separate actions is the preferred way
You can get the Control from a callback context but it's not pretty
Ah, that's unfortunate. That's like 40 extra lines of code I've got to stuff somewhere now.
Yeah, so the control method gives back an InputControl, with only the key that was pressed, so now is there a method I can get an ascii/int/string value back, or am I looking at chopping the path string into bits and getting the final part that I want?
Ok, so passing in the context menu I can use the control method which gives me a new inputControl of just the key itself which then you can use displayName to get the string value
fantastic
Actually the keyboard type remark there is concerning, eh
It's honestly going to be simpler just making separate actions tbh
Yeah, I guess I'll just subscribe them all to one event method
Not the prettiest but hey it works
anyone with an experience in making a decent input manager, using the input system?
What do you expect an "input manager" to do that the input system doesn't do already?
Hey, I would like to know your opinion about the solution they used in the open project to address player inputs, or maybe there's a better one ?
I'm trying to write some code to move my character and use animation, the animation is set and the character can move in a top-down movement way, but the animation isn't working, here's an image of the code, my animator variables are vertical, horizontal and speed, is there anyone that can explain or just show me what's wrong with the code, and really new to all of this?
Well, I don't know how you set up your animator, but if, as you said, you have a "speed" variable, you don't update its value in your code.
What code would I need to add for this?
first do you really need this variable in your animator ? could you show me a pic of it
yeah i think so, the other two variables are for movement, so the speed would be for the animation, so I think the speed variable would be good for making the animation go, I just don't know what code I need to add this in.
Heres the animator
When the speed goes up the animation should start, but it doesn't
like the speed doesn't go up, but I don't know how to add it to the code
ok so to update the speed variable you need to do like you did for Horizontal and Vertical:
animator.SetFloat("Speed",value)
you have to replace "value" with the variable that keeps track of your speed (but you don't really have one)
you could get the magnitude of your movement vector so something like that:
Vector2 movement = new Vector2(horizontal*moveSpeed, vertical*moveSpeed);
float speed = Vector2.ClampMagnitude(movement,1f).sqrMagnitude;
rg.velocity = movement
just note that clamping it is not really mandatory, depends on what you want
and then animator.SetFloat("Speed",speed)
Where would I place the code or doesn't it matter?
just replace the line 35 with what I said
The RB.velocity = part
yep
and replace it with
Vector2 movement = new Vector2(horizontal*moveSpeed, vertical*moveSpeed);
float speed = Vector2.ClampMagnitude(movement,1f).sqrMagnitude;
rg.velocity = movement;
animator.SetFloat("Speed",speed);
Like this?
almost, watch out for duplicated lines, you wrote twice animator.SetFloat(....
but not really a big deal
I don't know if I did it wrong but the game won't play and it says there is a compilor error, even after I'd erased that part
how my bad, I miss wrote .sqrmagnitude, replace it with .sqrMagnitude
Still doesn't seem to work, the part before is it supposed to be lf or if
Still says there is a compiler error?
show me it
The code or unity
the compile error
no I mean the message explaining what is the error, you can see it in the console or at the bottom of the screen
you can open the console via the window tab / general
or by pressing ctrl + shift + c
I have it open although it doesn't seem to be saying anything
show me
Make sure errors are not hidden
if they are not, you should probably restart Unity and check again
I found them now, thanks
oh yep just missing a ";" at the end of a line
Can you tell which one?
It should be highlighted in red here. If you're not getting errors underlined in red, or proper autocomplete you need to configure your IDE using the instructions in #854851968446365696
I've checked out the IDE thing in read me but it just says how to install D#
What are you talking about
Doesn't matter, it says to modify with the installation, just didn't see it
It says this error code now I've added the ;
What was the rg supposed to represent variable wise?
rb
yours is called rb, I'm used to call rigidbodies rg but in your case you called it rb so juste replace it
Thank you, it works now, been going at it for like half a day, so thank you so much
no problem
so what do i need to do with this
The input system really should have something that registers input press/release/etc. on a FixedUpdate interval
If you want to use the new input system, yes
i would definitely no recommend that. but if you need it it does support this already
new one is way more performant, easier to customize, easier to manage,....
I just need to know what's the best way to check for a press/release in FixedUpdate
The solutions I've seen rely on creating a new bool called WasPressed or something and set it false every FixedUpdate, but that doesn't seem like it should be necessary
It is necessary to set a bool in update, and reset it on use in FixedUpdate
why though? you could miss input if you use fixedupdate. also there are multiple solutions. if you want to apply this to all input then you can set a flag. otherwise you can also just check in fixedupdate like the old input system
I see
there are multiple solutions vertx
In the "Input System Package" project settings, set "Update Mode" to "Process Events in Fixed Update"?
You can do that, but that will also have knock-on effects if you want to process input in Update
Right, if you want to mix and match then things will go badly.
Really, I just wonder what's the cleanest way to incorporate the input system into a player state machine
Something like, hooking up an input action inside of a state and only run the code if it's the currently active state
Or hooking it up in the state machine and only feed the action into the state if the state uses the action for anything
You'll have different action maps and enable/disable them where they apply
good system for what you want
Yeah, that's how I've done it in the past. If the code to manage the enable/disable on entry/exit feels bloated or awkward I'd say that's on the state machine architecture, not the input system.
Wouldn't that lead to having to repeat a lot of stuff?
Say you have a dash move that works both on the air and the ground
Then wouldn't you need to make a separate dash InputAction for the idle state, the running state, and the jumping state
Well, say you have basic controls that work in any scenario, but you then jump so you enable with the basic controls with your air controls.
Lot of mix and match potential if you want to do it that way
I have action maps for a Main Menu, UI, Player. I've usually have both UI and Player active together, but they are disabled with the Main Menu are active.
I think the more common approach would be to have one dash action in its own actionmap, that is enabled in both states.
This is true, however its also possible to manually poll the input system when you like, or switch between polling modes at will (ie: if you use Time.timeScale to pause FixedUpdate)
I personally use InputSystem almost exclusively in the FixedUpdate mode, and selectively change it back to Update (or manually) as needed. Mostly just because most of my projects involve Time.timeScale and PhysX sims. varies from use case to use case.
If the game doesn't use a lot of buttons, maybe it's okay to just give the base State class a method for each of them
Then each specific state overrides one of them if it uses the button
when i try using wasd, my cube can only go in four directions and never diagonally, how should i fix my code to allow this?
i've been researching online and this is what i have so far
Show how you configured your input action
do you mean the action map?
No I mean the Move action
No
The Move action
How did you configure it
In your input actions asset
Not the code
Yes that
Honestly the issue here might be a bug with having double bindings for that composite
And/or having so many bindings in general
should i take the arrow keys out do you think?
Try making an action that only has wasd composite binding
And none of the others
See if that works
Then you'll know if that's the issue or not
nah it didn't fix it
Unfortunately I've seen a lot of bugs around multiple bindings on an action in the new input system
I'm still wondering what the benefit of the new input system is besides events
because with these multiple key presses, it feels like it's impossible
do you think I should get rid of the move event subscription and just do the input.getkeydowns?
You can just poll the action in update
You don't have to use events
The main benefits of the new system are a better, more flexible API (note I didn't say simpler), runtime rebinding support, and strong local multiplayer features.
#💻┃unity-talk message
I have problem with input systems. Both Legacy and New input systems behave the same. If WebGL loses focus, it locks last button as pressed down. And when webgl get the focus back, it never resets. Only pressing button again it comes back, as button up logic is triggered. I tried Unity 2019, 2020, 2021, legacy and new input systems. Multiple different controllers, one of them is Unity provided example. Different background behaviors, from ignore focus to reset and disable all devices. I would be really happy if someone could end my suffering 😦
In the new input system, for the binding XRController.triggerPressed, I'm observing that action.cancelled is invoked not when the trigger is released but when the trigger is fully pressed immediately after action.performed. What am I doing wrong?
hey, anyone else had a issue where the new input system does not recognize the mouse? it's a collaborator project where the same mouse worked fine on another device - simulated touchscreen is working for any reason?
Hey !
Is it good to stay that way with the new input system where it is better to stay on the old one? Personally, I am having difficulties with the new one, but I can't really decide what to do with it...
Anyone know why my UI button isn't responding to mouse clicks? I can click on things in the world by checking Mouse.current.leftButton.wasPressedThisFrame and doing a raycast, but my Unity GUI button does nothing when I mouseover or click it.
I have an EventSystem in the scene and an Input System UI Input Module as well, but they don't appear to be doing anything.
If you need complex inputs with different input mappings, the new input system is far easier to manage in the end. Though it is more advanced than beginner programming as a result.
The old input system is still a viable option if you find it easier.
My buttons are interactable, they have 'raycast target' set... the input just never makes it to them. Is there something I need to do beyond just having an instance of the Input System UI Input Module in the scene?
- GraphicRaycaster on the canvas
- Appropriate input action references set up in the input module (should happen by default but double check it)
- Nothing blocking your buttons
"GraphicRaycaster on the canvas" - boom, that's the one. Thank you
Why does the WebGL build doesnt detect input system multi-tap but it works for single clicks when it has no interaction modifiers?
Hi, having some trouble getting a reset button to work anyone have any idea how to make this work?
public void Awake()
{
controls.Playermain.Touch.performed += SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 0);
}
Did you call Enable() on controls?
like uh
void OnEnable()
{
controls.Playermain.Enable();
}
void OnDisable()
{
controls.Playermain.Disable();
}
It says it cant convert type void to system action but idk how to work with that lol
Where does it say that
Oh in the awake thing
Because that event has a delegate type that takes a CallbackContext parameter and your lambda doesn't
Yeah
Best to lead off mentioning any errors you're getting in the future
So somehow the performed callback is triggering twice. Which I could work around, except that it's acting as if it's threaded?
private void Move(InputAction.CallbackContext callbackContext)
{
if (performed == false)
{
performed = true;
}
else
{
Debug.Log("NO");
return;
}
Debug.Log("DO THING");
}
So this should prevent it from triggering twice. But in console I get DO THING showing up twice.
performed is only being set to true in this one method, just for testing purposes.
show how you subscribe/unsubscribe etc
Also what script is this attached to, and are you sure you don't have another instance in your scene?
Checking now for other instances, but the project is pretty bare bones so far
@austere grotto Just the one instance
Debug.Log(GetInstanceId())