#🖱️┃input-system
1 messages · Page 1 of 1 (latest)
presumably you have code doing that
nope no code nothing at all i think the sliders are just broken
When I first created my Player Input component, It tried to fix the event system according to current input action asset(GameControls) and reset every option in the UI Input Module, The screenshot shows the correct values / default values, If they all contains "None" your events won't work that was because I haven't configured UI controls in my input action asset.
So in short, it brokes when you press Fix UI Input modelu button because your action input asset is lack of UI controls or you haven't configured the UI controls from UI Input Module component.
my component looks correct so probably have some other issue 😦 thank you for the response!
Well they don't do that normally. Maybe show a video of what you mean?
is there a way to use left control + some key as a bind on itch without activating other control commands(like closing the window or highlighting everything)?
the mouse isnt exactly on the right position but i think u can get the idea
check which image you have assigned to the Fill Rect of each slider
etc
make sure they're not referring to each other's
BTW this seems like a #📲┃ui-ux problem not #🖱️┃input-system
I have an HID device that I added a custom input class for the input system. I'm running into an issue only in build mode strangely where the input action for the button is triggering as performed when I plug in the device and cancelled when I unplug it. Also, sometimes when I start the application it triggers performed even though I didn't press anything. Not sure what's going on here
Actually it is happening it editor too
To be clear the button is not pressed and Initial State Check is disabled
I think I know what's causing it, it seems to receive an HID value when connected that's different from button press. The bit it uses for the button is also included in the connected value bits.
I'm unsure how to just read the button presses but and not have it read it when it is set for the connected value
that was it thank you c:
ya thats my bad lmao sorry about that
I basically need a way to tell the input system to only use the specific bit when the remaining bits in the byte are all zeros. Is this even possible?
the bit manipulation you are talking about it possible yes
I don't know how to hook custom devices/device handling into the input system though
I think I solved it using a custom processor. Instead of using the type "BIT", I'm using the type "BYTE". With the custom processor I check the float representation to see if it is equal to 0.003921569 (00000001 in binary) and if it is I set the value to 1 otherwise I set it to 0. There has to be a better way I just can't find it right now, but this is working.
BitConverter can convert float to its byte representation which would let you check things in a more sane way than using that magic number, but yeh
Yeah I thought of doing that first, but that would also allocate memory every time the button is pressed and released.
Can you get the value as an int instead of a float/
I don't think so, I can try real quick though. I think button controls force float
it might cast it and round down to 0
I think you can just interpret as int in unsafe code but if what you have is working consistently I guess don't worry about it 😛
how do i turn of keyboard and mouse in the new input system to just test out my gamepad and touch with mouse on the computer?
this doesnt fix it, its doesnt mean i only get gampad
how do i disable keyboard and mouse in new input system?
How do I get the key name of a mapped binding but considering the keyboard layout? So if movement is wasd and the player uses azerty, I need to return zqsd. I really can't figure it out
i'm trying to figure out the input system and i have the following questions:
Am I able to add custom events that aren't coupled to keypresses or mouse clicks. ie could I programatically call it from script1 and recieve the event on script2 and use it like a custom event system?
How would I work with multiple keys like ctrl + P without triggering each, do i just use dumb filtering logic to check if both are pressed?
- No just use C# events for that
- You can create a binding with a modifier button
thanks
well im assuming that you have just InputSystem.Switch when you should have UnityEngine.InputSystem.Switch
The API is unavailable on Linux, I'm just confused why
ohh alright
Hey all, anyone know the equivalent to Input.getmouseposition using the new input system?
I'm watching this vid that uses Input.getmouseposition and my project is using the new input system, jsut need to know how to get the mouse position in pixel coordinates
(WAS WRONG) I Might be wrong, but I think mouse position stuff has nothing to do with the new input system, it’s not really normal player input
I got the typical using old input system message
And it was only after adding the code that used the old input system syntax
So everything works fine?
No I'm getting an error
have you tried googling it???
the first result yielded Mouse.current.position
....
Is that not the viewport position
As in (0,0), to (1,1) not (0,0) to (screen.xpixels, screen.ypixels)
Also
a workaround is to multiply it by the current resolution
have you tried not being a jerk?
it was a genuine question
there are a lot of people here who will not google a question first
What happened here that fast lol
Assuming that I wouldn't google something before coming to a Discord server for my problem
so would multiplying the x and y components by Screen.width and Screen.height and rounding the answer work?
Perhaps?
the docs entry for Input.mouseposition states:
The bottom-left of the screen or window is at (0, 0). The top-right of the screen or window is at (Screen.width, Screen.height)
so it should work
don't take what I said personally. sorry if it came off condescending
I need to sleep
I mean the three question marks kinda made it sound a sort of way lol
Its all good tho no hard feelings
Hi guys, anyone else had a problem with the new input system? > I've remade the input with the new system. Works fine in the editor but it doesnt on the build ...
Any ideas? Thanks !!
What are the advantages of using the new input system over the old one?
after re doing everything in the new one I can say it's way easier to manage inputs with the new one. It's actually a bliss
my proble is that doesnt work on the build for some reason
Pretty much everything except it's harder to get started and requires a couple more clicks to set up your input map
you can't.
just apply your own modifier in code
Or use the new input system if you want full control over your input system
How do people setup the new input for UI generally? If I instantiate the actions in another script, which I think is generally what you want to do since it doesn't make sense for the UI to own that, the UI system instantiates its own actions, which doesn't play nice with the first one. Do people use 2 sets, one for UI & another one for the rest of the game?
The event system which the UI relies on also seems to be closely tied to the UI overall & seems to be used as a singleton for the tutorials I've seen. But that seems to for example preclude the use of multiple menus being open at the same time. Imagine a split screen game where each player has its own menus which they control.
There's a special event system you're supposed to use for split screen.
Also for split screen by far the simplest way is to use PlayerInputManager and PlayerInput as it handles device/player mapping/management
Ok, cool I'll take a look at that
Anyone happens to know why my character keeps moving the same direction when I try apply a sideways direction? E.G I hold w, but the character keeps moving up even when I press d and release w
not really input system related, more like a bug in your code
void Awake()
{
input = new ();
input.Game.Movement.performed += Move;
input.Game.Movement.canceled += StopMove;
}
void Move(Context context)
{
velocity = context.ReadValue<Vector2>();
}
void StopMove(Context context)
{
velocity = Vector2.zero;
}
void Update()
{
var speedVector = velocity * speed;
rigidBody.velocity = speedVector;
}
That's what I figured, that's why I wanted to ask 😉
show your input action configuration?
In the inspector?
no
the input action configuration
for the Movement action
in your input actions asset
Is this enough
get rid of the Press interaction
Also just FYI the way your code is, you're not really using the PlayerInput component at all
you can remove that component entirely
it's doing nothing for you
Thanks
Hi, how do I use the new unity input system to make a camera look script for mobile?
I am currently working on a turn-based tactic. In a turn, your pick your option, like choosing an ability, and then the options menu closes you can click on a square on the ground to use your ability on. The problem I am facing is that when I press submit, the button onclick registers, and changes the game state to choosing the square the ground to use your ability on. A problem that might occur is that if I hold down the submit button, and let go after the game state changes, I would accidentally pick a square because I am currently using WasReleasedThisFrame().
I have considered changing to WasPressedThisFrame, but I was wondering if was any way to cancel the WasReleasedThisFrame if a button on click has registered the input
How do I control flow in UI depending on 'Cancel' button in the input system?
Buttons has a Clicked which can be hooked up, but nothing for Cancel it seems
NVM found it
is there a way to prevent mouse clicks from triggering the player input when a UI event is triggered
So we run the game logic in FixedUpdate. Therefor we set the input to fixed update as well as otherwise you can get pressed -> released and miss it. The problem however is that setting the timeScale to 0 for pause also stops updating the input system. Am I missing something?
update what in input system ?
input system is unaffected by time scale
unless you're using it inside an Update
i never really changed those
Yeah if you do your game logic in Update() you're probably fine, but that has issues with the physics side of things
For example if you use delta time for deciding movement on a kinematic actor, the movement won't happen until a fixed time step is taken
So for example if you have 3 Updates() per FixedUpdate() things will move 1/3 the expected distance
Imagine FixedUpdate() -> user pushes down button -> Update() -> user releases button -> Update() -> FixedUpdate()
oh i see
So if you use the WasPressedLastFrame or whatever it's called for example will say false
Even if the button was down
WasPressedThisFrame I mean
you could just pause the game the tedious way then
Yeah I think we'll have to smack in a base class which overrides & hides FixedUpdate to protect against pause everywhere
But it's kind of cumbersome
Hello, how do i do held button => do something with just the InputAction? I'm aware that i can use its raw value but i'd think it can do that. Like if i press and hold a button, the performed event would just start firing until i release the button. Edit: I'm talking about the new input system.
you can just check when the button is pressed and released
that's its behavior by default
bool pressed = context.ReadValueAsButton()
assigned this to a class variable
it'll stay true while the button is pressed
Yeah, i can do that, or like in this 1st pic but it'd be the odd one out from the pack (2nd pic).
Single and Hybrid are handled by the event alone, so it feel weird.
But if it's not possible then i guess there's no other way.
for the behavior i use, there isn't another way, so i guess there isn't for that either
Thanks! I guess it's the only option.
you can still keep experimenting though, there could be one
any idea about this
it looks like setting ui action types to button and value instead of "pass through" isn't helping either
Maybe you can have a GameManager which will tell the Player script to stop it's logic. (I'm assuming a UI event as in a UI is setActive?)
Won't it depend on the execution order then
I mean, it can be a frame off but not something to worry about. When HUD set active > Send Event to GameManager > GameManager change to Pause state > Send event to any scripts that need to be pause.
There are plenty of GameManager tutorials on Youtube too, really help me out. Maybe you can check those.
Umm
That's a bit confusing
I've attached functions to each UI element
So they are the ones that trigger click event
And input is handled by single script
You can see here. When My GameManager send event, it will change isPause to true.
Or you can unsubscribe input if any.
So with isPause being true, my logic no longer run, hence player script won't do anything
But my inputs aren't handled inside updates
They are invoked
So it is dependent on execution order
Well, you can have GameManager tell the input to stop.
Same problem
I have a game manager btw
I always use one
I just call it the global script
I would have to switch my input system behavior in order to achieve that
Then it does look straightforward
I switches my input system like 3 times (due to being a beginner, lol). Then i think you can take this to general channel, more people there can help you.
This channel get no love, i feel like.
Yeah it's usually very silent here
There is a way to achieve what I want with the present bahavior, so I'll just try that out first
Anyone with an idea why the "new input system" onscreen stick produces jerky movement on device but not in the editor?
Might have to tweak the settings in input system package asset
could you give an example of what settings might be worth tweaking?
Sounds like you might have some framerate-dependent code
It's not, unless you ask a question
If anyone ever faces this problem,
The solution is to use a Graphics RayCaster
WHAT IS THAT
My eyes
Is that the new input system
Lol, i'm sure there are more elegant solutions. Just doing what works for now.
How can I read the input of clicking the scroll wheel down?
Hey guys, I want to convert controls for my game from keyboard to be android controls with buttons in a UI panel, how do I link inputActions to these buttons, so for example if I click the jump button in the screen it does the same thing as pressing space and jumps ? (I am using the new input system)
There are ready-made onButton and onScreen scripts you can use for that.
You can read more here, I think this is what you are looking for? https://docs.unity3d.com/Packages/com.unity.inputsystem@1.4/manual/OnScreen.html
Can anyone help me out with receiving Input from a device outside of focus from the application?
and then with a steering wheel xD
it's generally mapped as the third mouse button (aka mouse button 2)
i want to be able to move the camera around the player with my mouse. (eg like in 3d person)
i have a camera controller script
this isn't really an input system question. But all you need to do is set the camera up as a child of an object that follows the player's position (using PositionConstraint for example) and offset its position to your desired distance. Then you just rotate that follower object and the camera will follow the rotation, achieving an orbit.
5$ to the first person able to help me out :D
that's a completely separate question from the camera question
i asked this:
move the camera around the player with my mouse
soo...
nvmd tho, because i solved it
forget the camera
those are two separate questions:
- how to get mouse input
- how to move the camera
you should approach problems like this - break it down into small pieces
ok thanks
is there a better way to detect input within the FixedUpdate() function rather than using an if statement? Im trying to have actions occur continuously while a button is being held
you should only do such checks in Update
unless you have your input system set up to use FixedUpdate (not typical or recommended)
you can also go event-based rather than polling like this
why? i figured i'd do it in FixedUpdate since most of the called functions are physics related
because FixedUpdate doesn't run every frame, which means you are sometimes going to miss the exact frame where a button is pressed for example
using UnityEvents or C# events?
Either
The input system supports both
ok, im thinking ill use UnityEvents since they're more straightforward
thanks
seeing as i have all of my functions public anyways
wait, there is a problem
so most of the functions that i use as actions from the controls are on another gameobject that is dynamically spawned into the game once a level loads, so where i'd go to set the UnityEvents has no access to the gameobject that actually has the functions that the controls would call
in other words the script that executes the detected actions is not located in the context of the PlayerInput component
hmm, i'd probably have to rethink my entire system i have here
perhaps i just change the if statements to switches instead and call it a day
Hi! I made a joystick that outputs a normalized value, in that case the value is the joystickVec variable. In general it works fine but my issue is that the normalized value is really sensitive and sometimes I move the joystick just pixels and it already jumps to 1. Can you see anything that might cause this? I can show other bits of the setup/code but this is basically the main thing
Anybody know why the "Press Only" would register the input twice? If I use Release or both, it detects it just once like it should. I'm not sure why it does that.
If I press it very quickly, it does it twice, If press and release slowly (Basically hold it down a bit), it'll register only once.
That's what normalizing the value does
It gives you a vector with the same direction and a length of 1
What's your goal? Why do you need the press interactipn?
It seems to be the default setting if you configure nothing in it. So I left it like that and I've been testing a few thing since I had my event registering twice every stroke.
Is that suposed to be a normal behavior? it's really just for menu interaction but it doesn't make sense in me head that this would happen twice.
The default is no interaction
Yes. Well. I am getting the same result wiht "Nothing" so I assumed it was the same as this
It's not but sounds like you're neglecting to read the phase of the callback context
The callback context tells you if it's performed, started, or cancelled
As I understand, I don't have access to the callback when using the message system
You'll get performed and started immediately, and canceled upon release
Correct when using SendMessages you get an input value
So you would read if it's not zero
Print out the value
value.ReadValue<float>() I think?
I'm on mobile so going off memory
ok let me check that
Yeah. I see that the Press action actually register 1 for the first input and 0 at the second one. What would that be? On a keyboard, is it just on/off?
nothing actually just register 0
and it doesn't register twice now. I'm just trying to understand what the behavior is here and how it works so I can use it all properly. Documentation isn't great. but that points me in the right direction at least.
basically - Send Messages mode is awful. If you use Unity Events mode you'll at least get a CallbackContext. From that you can read the current phase of the action - started, performed, canceled
for a default button, you'll get started and performed when the button is pressed, and canceled when it's released
Hello Can someone please help me with VS Code, I've been trying to fix this issues for house and I'm about to pull all my hair out.
hours*
Quick suggestions are not working, and apparently this should be on by default.
Not the right channel
Yes I know. What I mean is when moving the joystick the value doesn’t seem to go linear from 0 to 1 rather jumping sometimes. The sensitivity is just really high.
Did you install the vscode package for unity? This fixed it for me
I did have this installed but it didn’t help with the suggestions. I just installed Visual Studio and that seems to have the suggestion’s I needed. I wanted to use rider but I’m not paying
Hi guys! Is possibile to connect mobile controller (like iPhone or iPad) for a pc game (without switch to mobile game)? Thanks you 🙏🏼
Would you have some guide?
I just started working with Unity's free Third Person Controller, and I'm having an issue adding a new action. I read through the document that came with it and followed the steps, but the action I set up is never triggered. If anyone else has gone through this process I could use some help with it.
Wait I think I just rubber ducked myself.
Na, I'm still not registering the new input.
I've essentially duplicated the OnSprint and SprintInput in the StarterAssetsInput.cs (but with my own names of course), and then over in ThirdPersonController I created my functionality in a new method and then called it in Update. I don't see anything else missing, but when I press my input button nothing happens. I tried to log out the state of the input and nothing at all logs to the console.
Further testing shows that if I manually tick the input value in the inspector, then the action is taken correctly. So, the issue seems to be that the button press isn't being registered.
Rider also says that my input method is never being called, whereas the default ones don't show that warning. However, I can't see usages of those symbols anywhere except in the mobile controls, which I am not using.
Anyone can help me?
Have you searched the asset store as suggested before?
I am trying to detect that a key was pressed this frame (esc) using the new unity input system but i cant figure it out, i found a solution is this thread: https://forum.unity.com/threads/waspressedthisframe-not-working-with-new-input-system.1142143/ But that did not work for me either.
show your code
https://pastebin.com/gXX4Lj47 im trying to get this to work with the new input system but its not working but i dont get any error messages either.
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.
at first i did get some error about active input something something but it went away for some reason
Did you happen to put this script on an object that starts out deactivated?
Update doesn't run on deactivated objects/scripts
Oh, it seems to work when i activate the ui but when i test it in play mode it will let me close and then i cant open it again because the object is now deactivated. How would i somehow stop that from happening?
put the script on an object that never gets deactivated
so yeah, not an input system issue at all
I put the script onto a empty gameobject but for some reason i still have the same problem
well your code is also always turning it off right after turning it on
what do you mean by that?
read your code
top to bottom
look what it does
if i pressed the key this frame
if menu wasnt active activate it
if i pressed the key this frame
if menu was active, deactivate it
it does ALL of this
every frame
So I have a problem in regards to input in VR. I have a pointer for each hand and I'm pretty much trying to do a color picker where I pick a color from a Texture2D. For the most part it works great, but the previewing only functions properly for one hand. The other it'll only run the OnPointerEnter event before essentially breaking because it decides it wants to track the location of the other pointer instead.
New input system user here
I'm using Unity's First Person Character Controller starter pack, and I'm trying to add some functionality but it's not doing what I want
So, like the Jump input, I have Block and Attack configured as buttons, right?
And I've added them to the script that processes the messages the Player Input sends to the GameObject
But I only want Block and Attack to register right when the respective buttons (mouse1, mouse2) are pressed -- not pressed and held!
so like, the first frame of the input changing state to pressed.
Instead, on startup, the game just acts like both buttons are held down (I'm not pressing any mouse buttons here, but I'm spamming projectiles as if I'm holding the mouse down.)
What do I do here?
I can't even click mouse1 to reset the input
Hey everyone, I'm fairly new to Unity but I've been working on games of my own after finishing a Udemy, just to learn stuff and rebuild popular games with a twist and challenge myself. I'm in a 2D project with the new Input System and trying to make a top down where the mouse/gamepad stick controls where you look and WASD/the other gamepad stick is for movement, relative to the front facing direction. However, I've been like, all over YT and the internet trying to figure out how to do this moving/looking with the new system and always find stuff different/outdated than mine. Can anyone point me in the right direction (no pun intended), like starting with what to even put under the void OnLook(InputValue value) method? These are the basics that I have so far
What’s the main advantage of the new input system compared to the old one?
It's not outdated stuff, there are simply many different ways to use the input system
If you're using a PlayerInput component in SendMessages mode, you'll probably want to just store the Vector2 value from the move input in a variable in that method. You can then use it in update to move your character
yeah. I was looking up some things around YT and reaching documentation and I guess I didn't fully know the extent of the Input System
ty btw
I'm trying to figure it now, it does kinda get tricky though as everyone's method is different
for example, I used a YouTube guide to help me to this point, but any idea how I would implement it so the player moves relative to the mouse?
That screenshot is using a completely different approach from what you shared above
It's using the generated C# class from the input actions asset.
yeah. I couldn't find something using the original approach so I switched it
tried starting from scratch
I'd ideally like to seamlessly switch from mouse/keyboard to gamepad, would either approach be particularly better for that?
I know with the first one, the "OnEvent" can cover multiple controls
They can both handle that just fine
Hi, I am having issues with the input system. When I call Mouse.current.WarpCursorPosition() Unity throws a NullReferenceException. Any ideas why ?
P.S: I do have a mouse connected to my computer.
Here is the part that is concerned :
public void OnControlsChanged(PlayerInput input)
{
string mouseScheme = "Keyboard&Mouse";
string gamepadScheme = "Gamepad";
// Check if we are now using the mouse and keyboard
if (input.currentControlScheme == mouseScheme && previousControlScheme != mouseScheme)
{
cursorTransorm.gameObject.SetActive(false);
Cursor.visible = true;
// PROBLEM IS HERE VVV
Mouse.current.WarpCursorPosition(virtualMouse.position.ReadValue());
// PROBLEM IS HERE ^^^
previousControlScheme = mouseScheme;
}
// Check if we are now using a gamepad
else if (input.currentControlScheme == gamepadScheme && previousControlScheme != gamepadScheme)
{
cursorTransorm.gameObject.SetActive(true);
Cursor.visible = false;
InputState.Change(virtualMouse.position, Mouse.current.position.ReadValue());
AnchorCursor(Mouse.current.position.ReadValue());
previousControlScheme = gamepadScheme;
}
}
what's the actual line of code that throws the exception
this?
Mouse.current.WarpCursorPosition(virtualMouse.position.ReadValue());?
what's virtualMouse ? Seems like that could be null easily
Also Mouse.current could be null if your device doesn't have a mouse
does anyone know if I can change
moveAction = new InputAction("Move");
moveAction.AddBinding("<Keyboard>/w");
moveAction.AddBinding("<Keyboard>/a");
moveAction.AddBinding("<Keyboard>/s");
moveAction.AddBinding("<Keyboard>/d");
moveAction.Enable();
moveAction.performed += OnPerformed;
into just one binding?
sorry, just started using new input system today
What you're doing - manually creating input actions in code - is... a pretty advanced topic in the new input system
I recommend starting with the simpler approaches for now
e.g. creating an Input Actions Asset
and then using PlayerInput or the generated C# class
I did that on purpose, I like to do many things from code, and this works, and also have it so it is disabled so not going in background, I just wanted to know if AddBinding could be done in a way that was like AddBinding("<Keyboard>/w/a/s/d");
sweet ty, I for some reason fail to navigate their package documents well lol
I think just that I knew the phrase "composite binding" helped me find that
sorry, kinda a side question but on topic. I see the benefit of the interactive binding on that page, but, it made me wonder, is there a benefit to rebinding lets say on the editor side vs disabling/enabling an action?
disabling/enabling an action is completely different than rebinding
Okay, cool. Then I'll stick with the code I have atm, the C# generated style. In the screenshot I have, what would I need to make the player move relative to the mouse direction? Like, the way that the mouse is facing will always be forward
oh okay. My mind just was thinking about input doing things in the background and either rebinding an action, or disabling other actions from happening when you don't want them to?
usually you put your input actions into Action Maps
and disable/enable whole maps at a time
so for exmaple you might have an action map for controls for your character on foot. But when they get into a vehicle, there's a separate action map for that
and a separate action map for when you're in a UI menu
So I guess, the only benefit to rebinding is allowing a user to map their own bindings to a map that already exists?
yeah
it's for building those menus in game to rebind stuff
maybe I'm not understanding it fully, but, CompositeBinding seems almost identical to just binding, however, you can make a new class that inherits from IInputInteraction which although isn't what I was looking for, can add more customization, and then create an action with it doing something like var action = new InputAction(interactions: "MyInteraction(boolParameter=true,intParameter=1,floatParameter=1.2,enumParameter=1);
I am making a local multiplayer game and need to connect the correct controller to the correct player when they move from the menu to the main game scene. How do I do this? everything I have tried hasn't worked and I can't find anything on how to do this online.
best way to do this is use the new input system and use PLayerInputManager/PlayerInput
they were designed for this
I’m using the join manually option on the multiplayer input component because I have all the players join in one scene and then I spawn that amount in the other. I need some way to connect the player to its corresponding controller
it's done automatically when you spawn the players using the PlayerInputManager to spawn the players
how would i use the right stick (xInput) in unity? like which axis is based on the right stick?
Am I not understanding wildcard fully?
input = new InputAction("Input");
input.AddBinding("*");
input.performed += OnInput;
input.Enable();
void OnInput(InputAction.CallbackContext context)
{
Debug.Log("True");
}
Doesn't seem to register back to back mouse clicks unless I type something on the keyboard again first
changed the debug to Debug.Log(InputControlPath.ToHumanReadableString(context.control.path)); just to make my life better, which makes me wonder since just realized even moving the mouse triggers this
Yeah binding everything to one control will probably act pretty funky. When the performed callback is called is determined by the interaction you have on the action/binding. Since you didn't set one you have the "default" interaction which generally calls performed when you get a change in the input control's current value that is non-zero
But with so many different types of input events coming in it might be getting pretty confused about its internal state
oh okay, I was setting this for now just to understand wildcard better haha, and didn't realize I could be making it worse
If I have a movement InputAction, is it better to separate different devices into different Input Actions, for example,
InputAction gamepadMovement = new InputActions("GamepadMovement");
InputAction keyboardMovement = new InputActions("KeyboardMovement");
or just include all the bindings into one InputAction? Or does it not really matter?
oh wait, @austere grotto I think I better understand composite binding now? It is better to use this for multiple controls that do the same thing?
so I set this up in my action map just get a better idea of checking if a key is held
upAction.started += (context) => Debug.Log(string.Join("\n", upAction.controls));
upAction.canceled += (context) => Debug.Log(string.Join("\n", upAction.controls));
upAction.performed += (context) => Debug.Log(string.Join("\n", upAction.controls));
but reading the documentation some more, I'm kinda confused on .performed now? If .started can be used to check if an input is happening and .canceled to see if the input has ended, what do I do with .performed
oh, I guess I need to read more about PassThrough actions since they only use .performed
does the Hold;Press interactions natively exist, or do I have create my own class inheriting from IInputInteraction doing what those do?
If you have something like a joystick that can change values without "turning on" or "turning off" completely, that's what performed will help with
started will happen when it goes from 0 to anything, and canceled when it goes from anything to 0
but performed will happen for everything in between
started/canceled are sufficient for a traditional "button" control
not sure if this is the correct channel, but is there a way to achieve what OP is trying to do here?
https://forum.unity.com/threads/feature-request-key-binding-style.539691/
does anyone know how to fix this error? here is the code and error
you forgot to remove this
thanks i will try it
fixed 2 erros your a code saver
i think i can handle the rest
i have a new error after fixing this one can anybody help?
You have no action map called FootActions in your PlayerInput asset.
You first need to configure your IDE using the instructions in #854851968446365696 so you have proper error highlighting and autocomplete
Hi guys! I should connect the phone to a pc game to use as a controller do you know how i can send two different scenes? that of the game on the pc and the controller on the phone
thanks!
you should combine all of them
guys, I'm trying to use Input.mouseScrollDelta, but the value never changes, I'm on macOS
works with 2 fingers on touch pad tho, but mouse scrolling is a no go
Camera.main.ScreenToWorldPoint(MouseInputPos);
isn't changing when I move my mouse
Are you using a perspective camera?
yea
then you need to provide a non-zero z distance
or you'll always jsut get the camera's position
alright i'll try that
Or do what I recommend which is Plane.Raycast
nice it's working :)
I'm having trouble with the input system and visual scripting, the two don't seem to be working together, my graph doesn't recognize my options in the PlayerMovement input script
I've regenerated the nodes n everything
Is there something I'm doing wrong? Why isnt the graph recognizing the inputs I determined in the input system??
you would want to use the generated script class
from the input actions asset
probably kinda fragile through VS because any time you change the input actions asset you need to regenerate the C# script and then regenerate the Bolt nodes
Thanks! @austere grotto
How do you regenerate the C# script? Is that in Project settings?
no it's in the inspector of the input actions asset
wherever you tell it to go in that inspector
Hey, I was just trying to make a game idea I had, and was wondering how i would be able to read and store a string of inputs in the order that they have been input. For example, if the string of input is; "Up, Up, Down", then i want it to be saved like this to be able to be called at a later time
I really worded that terribly my bad
But hopefully it's understandable
i cant enable anything in the xr plug-in
@austere grotto @sharp geode thank you for the responses. Yesterday was super busy so just getting to them today
i have a mouse over event on some item slots in an inventory i have been working on, the item names are displayed on a tooltip whichs works almost perfectly
but when i deactive the inventory canvas and reactivate it
the OnPointerEnter and Exit no longer work
so they work the first time but not the second time, i have checked and the issue is that it is simply not being detected
wow nvm
i manually set the sort order and it started working
would InputDevice.deviceID ever not be unique?
nvm, just read the tooltip better
okay, so, it says the only exception is when a layout is registered that replaces a previous layout, but also says at the end of it that only the devices are recreated and will keep their existing device IDs. So, that is kinda confusing wording
in a sense that that isn't really an exception?
is this like a "Shift W" to run?
like if i put shift in the modifier and the w in the binding would that mean they both have to be pressed to work
Okay, so I have a client that asked me to fix his input system one button not working. The thing is, I tested it now with my ps4 controller and it works fine, but I guess he's using some other controller and it isn't. Any ideas what could be going on?
yes
is there a way I can add an array of names to an action name?
Do I have to do a composite binding, with just different names? For example,
InputAction movementAction.AddCompositeBinding("Movement")
.With("Move")
.With("MoveAction")
.With("Moving");
then do something like
movementAction.AddCompositeBinding("Dpad")
//all the things;
okay read more into custom composites, and think I use
static CustomComposite()
{
// Can give custom name or use default (type name with "Composite" clipped off).
// Same composite can be registered multiple times with different names to introduce
// aliases.
//
// NOTE: Registering from the static constructor using InitializeOnLoad and
// RuntimeInitializeOnLoadMethod is only one way. You can register the
// composite from wherever it works best for you. Note, however, that
// the registration has to take place before the composite is first used
// in a binding. Also, for the composite to show in the editor, it has
// to be registered from code that runs in edit mode.
InputSystem.RegisterBindingComposite<CustomComposite>();
}
is there a way to use toggle crouch/toggle sprint instead of a continues sprint/crouch when i press the keys i assigned
Have the press toggle a bool instead of using the hold as the conditional. Not 100% for the default input system but I know it's possible either way.
Coroutine?
I think he misread you typing "continues" as "coroutine"
and I think you meant "continuous"
ops yeah crusty morning eyes @austere grotto
i bough the ash vehicle physics, his car works when i just drag and drop it into the scene
i made got a kart model from sketchfab and used his script to setup the car physics
but i guess there's something wrong with the controls
if you look closely
the steering works on the gray kart but nothing else
i can drive the red car tho
i'm pretty new to this so i'm trying to reverse engineer what i see
hi is there any other ways to share data between files without using get or add component?
bc im using TMPro and 2 object using same file will error out.
any help?
Off topic
So last year i made a rebinding system with the input manager, i can make it work with the Input system but idk if it's any good compared to the regular ways to do it.
It basically stores the keys as strings (in a file) and convert them back to a key then stores that into the variable used to check for input
Is there any more "correct" way of implementing this ?
private void Start()
{
InputActions.Gameplay.LeftButton.performed += ctx => LeftButtonPressed(ctx);
InputActions.Gameplay.RightButton.performed += ctx => RightButtonPressed(ctx);
InputActions.Gameplay.UpButton.performed += ctx => UpButtonPressed(ctx);
InputActions.Gameplay.DownButton.performed += ctx => DownButtonPressed(ctx);
InputActions.Gameplay.LeftButton.canceled += ctx => LeftButtonReleased(ctx);
InputActions.Gameplay.RightButton.canceled += ctx => RightButtonReleased(ctx);
InputActions.Gameplay.UpButton.canceled += ctx => UpButtonReleased(ctx);
InputActions.Gameplay.DownButton.canceled += ctx => DownButtonReleased(ctx);
}
I just want to notify when the left button was pressed and when it was released and so on
Code for the methods is this one and it's the same for all of them
private void UpButtonPressed(InputAction.CallbackContext context)
{
OnDirectionPressed?.Invoke(Vector2.up);
}
private void UpButtonReleased(InputAction.CallbackContext ctx)
{
OnDirectionReleased?.Invoke(Vector2.up);
}
(the context may be ignored since i was testing some stuff and forgor to delet it)
better to use it in an update function
wym
in update you do
if(inputactions.gameplay.upbutton.waspressedthisframe())
{
}
or you could use the event method with a composite type input
whichever suits you
@jagged wyvern They are using New Input System
i know?
You subscribe to events you don't need to run anything in Update
it's still an option
much less complicated
not like there's only one way to use the input system
😂
Yes, it is very flexible. But even if it supports backward method of using it, doesn't meant that you have to use it.
hello I'm new here
I'm gonna straight forward
is there any purchasable asset on store
to make a simple inputfield on Unity that later on stored on mysql database as just a string text raw data (on a certain column)
No
You will need to connect those things yourself
It's much too bespoke of a thing to have an asset for
Hi,
Can someone explain me why we should use the new Unity Input System instead of the Old Unity Input System. Moreover we have to code less in old unity input system and we can customize that too.
highlights of the new input system IMO are:
- Runtime rebinding support
- Support for event-based input handling
- Enhanced Local multiplayer support
if you don't need that stuff, or have figured out ways to do that stuff in the old system, more power to you.
I'd also add better compatibility with non-xbox controllers (Dualshock, Switch Controllers, Generic, etc.)
Working with non-xbox/non-xinput controllers with the old system is... messy, to say the least.
so i'm using the InputSystem.
and i want to dynamically change the input for an action (eg: MAP.ACTION).
eg some code would look like:
CONTROLL_OBJECT.MAP.ACTION.listenForAction();
basically this code would be the same as opening the Action Editor > MAP > ACTION > binding > path > listen
(CONTROLL_OBJECT is the cs class generated by the InputSystem.)
example use:
a controls tab in the settings menu so you can change your control scheme.
does this make sense?
It does - there is a method for this...
{
var rebindOperation = actionToRebind
.PerformInteractiveRebinding().Start();
}``` should work, I think?
where do i put this function?
CONTROLL_OBJECT.MAP.ACTION.PerformInteractiveRebinding().Start();
I am assuming that CONTROLL_OBJECT is an instance of InputActions in your example, as generated.
no
🤔 InputActions CONTROLL_OBJECT = new InputActions(); CONTROLL_OBJECT.MyMap.MyAction.PerformInteractiveRebinding().Start();
https://youtu.be/p-3S73MaDP8?t=379 (CONTROLL_OBJCET is what the video says PlayerControlls)
Let’s set up Gamepad controls using the new Unity Input System!
► SIGN UP FOR JASON'S UNITY COURSES: https://game.courses/mastery-course-brackeys-bonus/?ref=21
👕Check out our merch! https://lineofcode.io/
♥ Support Brackeys on Patreon: http://patreon.com/brackeys/
·············································································...
But of course, remember to enable it.
?
CONTROLL_OBJECT.Enable(); CONTROLL_OBJECT.MyMap.Enable();
CONTROLL_OBJECT.MyMap.MyAction.PerformInteractiveRebinding().Start();```
ok
is there a way to see if an action is currently "active"?
eg: i have current code that uses float x = Input.GetAxis('Horizontal'); inside update()
eg: new code would look like: float x = CTRL.Map.Right.ReadValue() - CTRL.Map.Left.ReadValue();
EDIT: I get you.
@forest oak Yes, you check the value of InputAction.phase, which essentially controls whether an action is in use. The values are as follows:
- Started: same as GetButtonDown()
- Performed: same as GetButton()
- Cancelled: same as GetButtonUp().
To get the values, you need to use ReadValue<T>() like this:
T myvalue = InputAction.ReadValue<T>(); where T is the type relevant to what you are trying to read.
For instance: float x = CTRL.Map.Right.ReadValue<float>() - CTRL.Map.Left.ReadValue<float>();, assuming that Right is set up as a single axis.
so a joys tic action would be type Vector2?
Yes, exactly.
for this i was thinking:
action LEFT = LeftArrow or A or JoystickLeft
action RIGHT = RightArrow or D or JoystickRight
but i guess you can make specific axis?
Ugh yeah, you can configure that in the UI if you want to create an axis with binary bindings (like keyboard keys). Actually, if A and D are fully left and fully right, then that's the way to do it.
nice
how can I detect when a gamepad's joystick is reset to its default position? moving it moves my player, but when I stop moving the joystick it does not set the movement to 0
i got you
Let’s set up Gamepad controls using the new Unity Input System!
► SIGN UP FOR JASON'S UNITY COURSES: https://game.courses/mastery-course-brackeys-bonus/?ref=21
👕Check out our merch! https://lineofcode.io/
♥ Support Brackeys on Patreon: http://patreon.com/brackeys/
·············································································...
I knew I saw the solution somewhere once, thank you!
i mean; is it possible to connect a wii-mote (via Bluetooth, on pc) with unity
@blissful lotus do you know if that is possible?
Those wii-motes are little white boxes to me. I've never wondered before, but I can tell you that some controllers don't work outside their native product family (like PS DualShock controllers).
ah ok
i keep seeing these "gamecube controller usb adapters" for pc
Vector3 state;
bool success = controller.TryGetFeatureValue( CommonUsages.deviceAngularAcceleration, out state );
anyone know why this return 0,0,0?
I got oculus quest 2. rotation and other properties are working.,
what setup is required?
ok nvm its still zero, not sure what im doing lol
I have an Input Actions set up, and the very simple script below to test. My WASD controls and my gamepad controls are both set to Pass Through Vector2 > 2D Vector Digital Normalized. However, when I play my game the gamepad controls work, but the WASD controls don't. I will also post a pic of my Player Input component.
`public class PlayerMovement : MonoBehaviour
{
[SerializeField] private float moveSpeed = 10f;
private Vector2 _moveVector;
private void FixedUpdate()
{
Move();
}
private void OnMovement(InputValue value)
{
_moveVector = value.Get<Vector2>();
}
private void Move()
{
transform.Translate(new Vector3(_moveVector.x, _moveVector.y, 0f) * moveSpeed * Time.deltaTime);
}
}`
Can anyone tell me why the WASD controls don't function?
why'd you make it a pass through?
Try value/vector2
hi guys, how do you go about shooting in semi auto or in full auto with the new input system? Thanks!
Do you guys use the old default input system or the new one (with the component)?
Can you explain why?
bool shootInput = automatic ? myAction.ReadValueAsButton() : myAction.performed;```
I use the new one but usually without the PlayerInput component
Oh you can do that? I thought you needed it
PlayerInput is one of many ways to use the new system
Okay, I'm reading that actually, hope it'll talk about all that properly !
https://gamedevbeginner.com/input-in-unity-made-easy-complete-guide-to-the-new-system/#input_manager
This seems to have solved the issue, so thank you. I have to admit I don't understand why though. My understanding is that pass through is the same as value, except that it triggers regardless of the input type and doesn't do an initial state check. Am I missing something?
Yeah I think the problem is that pass through also doesn't do any disambiguation between different control bindings so even if your keyboard is actuating it's reading a constant 0 from the joystick. Something like that ☺️
Bizarre! Thanks again.
Hey! I'm not a dev, but have a question about inputs in unity for a game I play.
In the game you can left click to move an item, or shift + left click to move a stack of items. On a controller, you can only press A to move one item.
Is there something limiting the devs from assigning the shift modifier to another button (left trigger, for example)? Shift has no other use in the game.
I mean I don't know what game you're talking about or what the implementation is but that is definitely possible. However game designers to tend to keep things as simple as possible on controllers when they can.
Bump
is there a way to have the browser ignore ctrl+F ?
it brings up the find/search text tool
I doubt it
hmm
from unity? unlikely
thanks
if you have access to the html file you can add a javascript with ```js
window.addEventListener("keydown", e=>{
if (e.ctrlKey && e.key == "f") e.preventDefault();
})
thanks!. i actually just made a custom webgl template and added that
it worked
does a TI-Nspire work with the input system?
Pretty much 0% chance Unity actively worked on supporting a graphing calculator
aww
Also what the heck is that, what happened to TI-84's
but it supports/recognizes my power bank?
I'm sure it has some limited support for "generic usb device"
so i made my action with these values:
but how do i actualy add W for +1 and S for -1
add a binding
k
composite binding
?
add a composite binding to the Action
witch one
positive/negative binding
depends on which axis
Horizontal and vertical
Maybe you stil have the old one>?
Delete the old generated class
the old one what?
generated class file
what can i use instead of Input.GetAxis("Mouse X") (this is old)
depends what strategy you're using to process input
there are many ways in the new system
Are you new to the Input System?
YES
Add Binding -> Mouse X or Y
Then read that first
what is delta?
If you really want to understand the basis of it, read that, and you'll be able to understand most of it and to pretty much anything if you read actively (which means reading and trying to understand, not just dumb reading)
it means "change"
that is what i want
instead of having all these functions for each class that uses input:
using UnityEngine;
using UnityEngine.InputSystem;
public class NAME: MonoBehaviour
{
InputControls controls;
void Awake() {
controls = new InputControls();
}
void OnEnable() {
controls.WANTED.Enable();
}
void OnDisable() {
controls.WANTED.Disable();
}
}
what should i do?
eg; rn i have a:
PlayerController.csthat usescontrols.PlayerControlsCameraController.csthat usescontrols.CameraControls
Did you ask a question?
i don't want to put all these functions in every class i need.
what should i do?
all what functions
i guess not functions.
this:
InputControls controls;
void Awake() {
controls = new InputControls();
}
void OnEnable() {
controls.WANTED.Enable();
}
void OnDisable() {
controls.WANTED.Disable();
}
Awake, OnEnable OnDisable?
NO
I mean if you want to just have one instance of InputControls you could make a script that sort of centrally manages it
make it a singleton
i have two (there will be more) scripts that use input. i don't want to have to do all that code over and over for each class that uses it
Hence what I just said...
so it would be like this:
INPUT.cs ```cs
...
class INPUT {
public InputControls controls;
void Awake() {
controls = new InputControls();
}
void OnEnable() {
controls.PlayerControls.Enable();
controls.CameraControls.Enable();
}
void OnDisable() {
controls.PlayerControls.Disable();
controls.CameraControls.Disable();
}
}
`PlayerController.cs` ```cs
...
class PlayerController {
public INPUT;
...
}
```?
i would rename INPUT to something else
nah make it a singleton
singleton?
i'll look
singleton pattern?
i found a video.
the first 2 mins are him yelling at how painful they are
i don't understand
I'm saying I don't think videos are the best medium for learning programming skills
then link me a doc or smth
PS. i moved all the old code to the new system
what type is a MAP in the cs?
does anintendo wii classic controller work?
???
Chill man people sleep sometimes
Is there any way to work around that? Or it is what it is for now and we can't differentiate SHIFT+A and A, at all?
Oh nevermind seems like it's fixed in 1.4
Dont know if this is the right place, but my flythrough mode for the scene view just stopped working. Any fixes?
I cant work on my game like this
Did you try to just close your project and launch it again?
No sir, but thats a good suggestion
Ill check it out later, thank you very much :)** **
No problem, tell me if it works (and please don't play Taz)
Can I use SendMessages and Invoke Unity Events behaviours in the same project? Or do I have to choose 1 early in the project and stick to it?
(if I understood correctly I can use SendMessages and BroadcastMessages together, but Unity Events uses a different way to get input datas so I wonder if you can combine)
Unfortunately this and reimporting into a new project didnt work
Okay the problem solved itself, it started working again after 5 minutes
Well, looks like another random bug haha
Is it normal that Visual Studio never autocompletes my Input functions?
For example if I try to type OnMove, it'll always auto-correct to OnAnimatorMove
(I regenerated project files with Registry Packages checked, several times, and Input System namespace is already added)
If anyone has the same issue, I created a thread
https://forum.unity.com/threads/vs-not-recognizing-input-systems-functions.1320435/
OnMove isn't really anything that VS could know about
These are just based on your input action names right? VS doesn't know anything about that
Now if you were to use the interface from the generated C# class, that would get autocorrect.
Hm okay so everytime I'll want to use OnMove I'll have to counter the auto-correct then? x)
I spent the last 3 days reading and watching tutorials about the Input System, and the last 20 minutes reading official Unity manuals on it
Conclusion is that Unity tutorials suck, it lacks the most basic explanations about it
CONTROLS.MAP.ACTION.??? action is of type Button. how do i get a true/false value of if it is down?
@austere grotto
?
bool modifierPressed; void OnModifier(InputValue value) { modifierPressed = value.isPressed; }
isPressed returns a bool
error CS1061: 'InputAction' does not contain a definition for 'isPressed' and no accessible extension method 'isPressed' accepting a first argument of type 'InputAction' could be found (are you missing a using directive or an assembly reference?)
i also want when it's released
Is the Stick Deadzone - Processor not working with anyone else?
Not a problem as I end up writing my own code for it, which works.
//Prevent picking up jitter from controllers.
if (value.ReadValue<Vector2>().magnitude > 0.25f)
{
Debug.Log(value.ReadValue<Vector2>());
}```
But still curious why it doesn't work. 🤔
@austere grotto
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.4/api/UnityEngine.InputSystem.InputAction.html#UnityEngine_InputSystem_InputAction_IsPressed
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.4/api/UnityEngine.InputSystem.InputAction.html#UnityEngine_InputSystem_InputAction_WasPressedThisFrame
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.4/api/UnityEngine.InputSystem.InputAction.html#UnityEngine_InputSystem_InputAction_WasReleasedThisFrame
Hello I got a quick general question for everyone. I am a beginner when it comes to Unity. So when it comes to the "New input system" vs the "old". The new seems more convenient once understood, but seems to have a steeper learning curve. I'm still unsure which to use especially when it comes to mobile development (touchscreen). Touchscreen seems to be in a realm of its own when it comes to input category. Any suggestions or advice ?
here is my script:
using UnityEngine;
public class Interface: MonoBehaviour
{
public Controls controls;
void open() {
if (controls.controls.Interface.Open.IsPressed()) {
float r = transform.rotation.y;
Debug.Log(r);
}
}
}
but it doesn't log anything
🤦
😮💨
i never call open
Hello everyone! For the life of me I cannot figure out why my player won't look at my mouse. It always keeps resetting it's rotation to -90 on the y axis.
Here is my relevant code and Input System settings
I cannot for the life of me find a way to specify action(s) in the editor.
Is it hidden behind some obscure attribute? 🤔
I just need to randomly select from a few specified by the designer.
Edit: NVM I'm dumb. InputActionReference is what I need.
If you're using a perspective camera you can't just use ScreenToWorldPoint like that
What do you mean?
I mean if you call ScreenToWorldPoint with a perspective camera and any Vector3 with a z value of 0, you will just get the camera's world position out
I'm confused, I just looked at several ways to make the Input System work, and it seems like it can work listening to Unity Events, C# Events, etc, being attached to a game object.
But it seems like it also work being attached to.. Nothing? Then why would I attach my Input Actions to a game object?
there are many, many ways to use it, yes. Not 100% sure what you're asking
Well I don't understand why there is so many ways to use it, what's their usage, why using this one or this one
There's too many ways to list them all and provide an exhaustive list and it's not really worthwhile to do so
Find a way you like
I already struggle understanding how the whole thing works, but I realized I'm just getting very confused by different sources of knowledge that all use a different method
and use it
The basic concept is that you have some Input Actions that can be used to read input in various ways, and you use that to get input data into your code.
Yeah okay, that is understood
But how do you choose one way? Like I wouldn't want to pick a random one and figure out it's not what I needed
Documentation regarding Input System is still a bit confusing for a new comers imo haha, just spent 3 days melting my brain trying to understand how all that works
I'm not really sure what to say
try a few
see which you like best
and go with it
you'll learn more as you see more and get more experience with it
Well I don't care, that's the issue, cause I'm not advanced enough to understand the real differences
I guess I'll just go with the "basic" way of not using the component, cause I don't really know what it changes anyways
Not using the Player Input Component is similar to using it with behavior Invoke C# Events, right?
There are many ways to use the input system without the PlayerInput component
so I'm not sure how to answer that
But no probably not
Invoke C# events is a very misunderstood mode on PlayerInput
If you use Invoke C# events you're supposed to use this one event for everything basically:
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.4/api/UnityEngine.InputSystem.PlayerInput.html#UnityEngine_InputSystem_PlayerInput_onActionTriggered
Input System is a very misunderstood tool to me, at all 
I thought the CallbackContext was for Invoke Unity Events
Well
It is used in many places for many things

Did you learn how to use all that through raw Unity Documentation like a chad?
Learned a lot from documentation, experimentation, and experience.
And by experience, what method would you recommend for let's say a 2D solo platformer?
Not that I don't want to experiment etc, but I have a limited amount of free time, so I want to optimize it, it's not really the right time for me to spend weeks experimenting
I just need somewhere to start and keep myself working on this one thing
It's kind of hard for me to make a recommendation because things that feel easy for me are hard to use for beginners. Probably PlayerInput with SendMessages/BroadcastMessages is the simplest way to do things.
Because you don't really have to hook things up much
Hm ok I'll try to find something on that, thanks!
But tomorrow, I spent 8 hours a day for the last 3 days only working on understanding the Input System
Just viewing dozens of docs and videos, each of them doing things a different way
Exhausting x)
In my personal projects I usually skip the PlayerInput component and use InputActionReferences all over the place
I'll do as they tell to do in the doc/video I'll find tbh haha
SendMessages/BroadcastMessages aren't too limited compared to Invoke Unity Events?
I went through only 1 doc explaining those, and it was a general doc not saying much about it, just that it existed, so I wonder why not so many people seems to use it
they're a bit limited
but for a simple platformer you should be fine
they're easy and quick to set up and use
Hm okay, but I wouldn't want to learn a method that would limit me for another more complicated game, I think that if I have to put the time in understanding a method, it'll take time no matter what, so I might better use that time learning a method that'll be enough on its own and not limit me, you see what I mean
Well I wouldn't be afraid of learning multiple methods, and understanding the strengths, weaknesses, and nuances of each
True, but I'd like to understand fully one method first
I mean, I'd love to learn multiple etc, but I found no documentation or video regarding the technical differences, weaknesses, strength etc, comparing them, and my programming skills are waaay too low for me to figure that out by myself in less that 6 months (and I'm being kind with myself, I'd say over a year if I'm realistic, from the point I am now)
Honestly if your programming skills are not great, is there a reason you insist on the new system, which has arguably a higher barrier for entry? The old system is still there, works fine, and is much more friendly to lower skilled programmers
I think if you are a beginner programmer, try to stick to PlayerInput in either SendMessages/Broadcast Messages mode OR Invoke Unity Events mode
Well I hate wasting time, and learning old system sounds like a waste of time when the new system is better at everything (except learning), it means I would still have to go through learning path of the new system
Those two are probably the most beginner friendly ways of using the system
I feel like Invoke Unity Events mode is the most complete one, maybe a bit less than Invoke C#, but easier and still complete, while SendMessages looks limited
Another pretty beginner friendly way is to directly define input actions on your script and read them in Update sort of like the old system:
public InputAction JumpAction;
public InputAction MoveAction;
void Update() {
if (JumpAction.WasPressedThisFrame()) {
//jump
}
Vector2 moveInput = MoveAction.ReadValue<Vector2>();
transform.Translate(moveInput * speed * Time.deltaTime);
}```
I've seen that but I felt like it was too similar from the old one
honestly I think it's not a bad way to ease into it
you start to get an idea of what Input Actions can do
and if you want you can also easily do something event-based with the same approach
e.g.
public InputAction JumpAction;
void OnEnable() {
JumpAction.performed += JumpListener;
}
void JumpListener(InputAction.CallbackContext ctx) {
// do the jump
}
This is all very self contained
you define the bindings and the actions right on your script in the inspector
and a bunch of these skills (dealing with InputAction and CallbackContext) will carry over into many other modes of using the system too
Okay that sound pretty straight forward explained that way haha
So I just put my action in JumpListener function? And where do I attach the Input Actions Control file? In the Player Input component added to my character?
I'm not even sure about that cause I've seen a guy adding it to an empty object, and then calling for the player's component in the Events list like that (screen), and then calling for the event in the "No Function" list
I didn't really understand that method tho, since I thought Player Input had to go on the Player, thus it confused me regarding the Events itself and how to use it haha
But I'll find someone who explains how to use Invoke Unity Events, the basic way x)
Could someone help me convert my project from old input system to the new input system
I'm stuck with it so I can't help, all I can say is "good fucking luck" 
In the example I gave you don't. There's no PlayerInput, and no Input Actions Asset at all
you just define the Input Action directly in the inspector
I think I'm too tired for now, I've been working on that for the last 13 hours with no break, I think no matter what my brain won't compute information haha, I'll read through all you wrote tomorrow, thanks a lot!
So I think I'm done with what I wanted to do, but since I wrote this code reading and watching a bunch of different sources, I'd like to make sure I don't start with bad habits, so if anyone could check and tell me if it's fine or not, would be very appreciated!
(I used the new Input System, with C# Events)
hi im using the new input system to transition between an idle animation and a walking animation and my idle animation simply plays on repeat. The issue is with the "GetKey.w" im aware thats not the correct statement and want to replace it with the correct one however i have been looking at the documentation and i cant get this to work.
using UnityEngine;
using UnityEngine.InputSystem;
public class IdleWalk : MonoBehaviour
{
Animator animator;
private void Awake()
{
animator = GetComponent<Animator>();
}
private void Update()
{
if (animator == null) return;
if (Keyboard.current.wKey.wasPressedThisFrame)
{
animator.SetBool("walk", true);
}
if (Keyboard.current.wKey.wasReleasedThisFrame)
{
animator.SetBool("walk", false);
}
}
}
this name keyboard doesnt exist
you need using UnityEngine.InputSystem;
dingo is very dumb
Hello I'm working on a small makeshift inventory system. I don't understand what I'm doing wrong I keep getting an error saying "Input Button f is not setup". I did set it up in the input manger that's why I'm confused and a little stuck. If anyone could help it would be appreciated
code- https://paste.ofcode.org/8NjKLvukRNf6ZhWeDUPW53
Error ScreenShot- https://prnt.sc/Yz86mcSxpm17
Input Manager ScreenShot- https://prnt.sc/udeq-e4ZnTIg
I think that's caused by the UI, from memory I think if you click on "Event settings" and the inspector should have a button to fix it
sorry where would the event settings be?
The button you have made is not f, it's FlashLight
it uses the f key as one of it's inputs
unfortunately its still looping without stopping
for reference this is my animator
Yeah I found it thank you!
show parameters for animator and show transitions
Hey, I've been told that I should have my input management in a script, and the physics in another script, so that my Input System is more modular. But I can't find a reliable and well-explained way to do this.
I'm wondering if that guy was right or not, and if yes, how could I do that? I just can't find how to use Unity Events behavior with the inputs and the physics in separate scripts
So, I'm trying to do this but for some reason JumpListener is never called even if you bind something on inspector, maybe I'm missing something?
you might need to do JumpAction.Enable(); ?
see if that helps
if not, show your code
it worked! thanks!
I am trying to make something happen after pressing a controller trigger and then releasing it. (I'm using the old input system) With how controller triggers are set up they are considered axis (like a joystick) due to being analogue. Because of this I've only managed to make it so that when you press it something happens but you can hold down the trigger and I don't want that. (For reference to make something happen I'm just doing this: if(Input.GetAxisRaw("Grapple") > 0.5) do something) is there a way to treat a trigger like any other button and use something like Input.GetButtonDown?
pretty sure if you just do Input.GetButton("Grapple") it will work.
you can also go into the axis settings and modify where the "activation point" is
(not sure it's called that)
Is this a better place to ask about buttons and prefabs or more like #archived-code-general?
Anyone have tips how to solve problem when input system UI input module overwrites some of player input data. If I enable and disable input system ui input module it starts to work again. but I dislike that kind of workaround
it seems having seperate InputActions solves this problem. Does having multiple files for InputActions have any negatives ?
instead of having one with two action maps?
I'm getting two events per axis event, one for start and one for ending. How can I ignore the end event?
I've already tried setting the interaction type to "Press only"
oh well i just wont use an axis
check the phase of your cllback context in the listener
don't use the press only interaction
I just decided to move back to my old method of just using 4 inputs instead of 1 axis
well too late to go back now but i just found out I had two player input components, so that was probably the problem
definitely never too late to go back
that will also hurt though yes
Well the way I'm doing my input now is much simpler so I don't think it would be worth it to refactor for the third time today when what I have works with much less work
How can I change this rb.velocity = new Vector2(moveDirection, 0) * speed; to work with a 1D Axis?
Cause atm I'm setting Y to 0 and it's breaking gravity and my jump :v
(moveDirection being a float taking the left and right inputs)
I'm pretty sure there's something simple built-in to work with 1D Axis, but I still can't find it!
Replacing = with += worked but now my character's just lightning fast and feels like on an icefloor, so I'm not sure this is the right solution since it'd need a bunch of extra work to keep it from sliding and being that fast
If anyone has the same issue, I finally found a fix: rb.velocity = new Vector2(moveDirection * speed, rb.velocity.y); 😄
Movement works fine , but this random errors pops us and option change action maps disappears from the left. How to fix this ?
I bumped up the resolution of my game and now all the buttons are broken. Any ideas?
You probably have some other UI object blocking it
Hello, I have the following code in a FixedUpdate method:
if (Input.GetButton("SpeedControl"))
{
float currentAxisSpeed = Input.GetAxis("SpeedControl");
Debug.Log("SpeedControl Down: "+currentAxisSpeed.ToString());
}
Here is a configuration of SpeedControl axis:
The problem is - keypress is getting registered multiple times
5-6 times I get 'SpeedControl Down' notification
Yeah why wouldn't it?
GetKey returns true every frame while the key is held down
How do I configure numbers to be less sensitive on keypress?
What are you trying to actually do
I want to increase/decrease some internal counter on pressing F1 and F2
Decrease on F1, increase on F2, as defined in Axis setting
Gravity, Dead and Sensitive settings are confusing
You want
int myCounter;
void Update() {
if (Input.GetKeyDown(KeyCode.F1)) {
myCounter += 1;
}
}```
unless you want it to continuously increase as you hold it down
in which case you want:
float myCounter;
void Update() {
myCounter += Input.GetAxisRaw("SpeedControl") * Time.deltaTime;
}```
second option feels better for me, since you can potentially redeclare keys for Axis later
A user may, potentially, I think
they do very different things though
also users cannot rebind axes in the old input system
sad
so, do I need big or small values in axis configuration - Gravity and Sensitivity - to "dumb down" axis?
you really can ignore all of that stuff
for the code I shared above
it doesn't matter
that's only for when you use GetAxis which has sort of a "momentum" to it
float currentAxisSpeed = Input.GetAxisRaw("SpeedControl") * Time.fixedDeltaTime;
if (currentAxisSpeed!=0)
{
Debug.Log("SpeedControl Down: "+currentAxisSpeed.ToString());
}
too fast for me...
actually, I may smack in a multiplier
but still...
yes that is what you need to do
guess there is no other way 😔
it's not a mystery
make a multiplier value and it will represent "speed" expressed in units per second
Hello Guys, I'm curious about how can I get full float value in Unity new Input system, I mean if I press button halfway, it will return the value of 0.5 or -0.5.
currently, I get the value (1, 0) (0,0 )(-1, 0)
You have it bound to the keyboard
keyboards don't report half presses
ah, okay
Thank you, let me take a look
Wait, so if I want to make a movement, which binding should I use
whatever binding you want to use to move with
I mean if there any input usage for keyboard to return the value I just mentioned?🤣
no
there's no way to detect if a keyboard key is half pressed
it's either pressed or it isn't
Alright, thanks bro
Does anyone know the Input System equivalent of GetKeyDown and GetKeyUp?
Keyboard.current[Key.Whatever].wasPressed/ReleasedThisFrame```
It's better to use input actions though...
idk if my raycasting is acting up
for this inventory that is behind my pause menu, it contains 8 buttons (the white and image ones)
so if I turn on raycasting for all these inventory buttons, the pause menu buttons can't be pressed on areas where the inventory button is behind it.
and if I turn off raycasting, the inventory buttons won't work
Also any buttons behind the pause menu seems to be interacting too
And if there'stext behind the canvas, it doen't work also
private Touch mytouch;
private Touch nullTouch;
private int cameraControlAreaTouchId;
private void Start()
{
cameraControlAreaTouchId = -1;
Input.multiTouchEnabled = true;
nullTouch = default(Touch);
}
private void Update()
{
foreach (Touch touch in Input.touches)
{
if (touch.phase == TouchPhase.Began && cameraControlAreaTouchId == -1 && touch.position.x >= (float)(Screen.width / 2))
{
cameraControlAreaTouchId = touch.fingerId;
mytouch = touch;
}
if (touch.phase == TouchPhase.Moved && touch.fingerId == cameraControlAreaTouchId)
{
mytouch = touch;
}
if (touch.phase == TouchPhase.Ended && touch.fingerId == cameraControlAreaTouchId)
{
cameraControlAreaTouchId = -1;
mytouch = nullTouch;
}
if (touch.phase == TouchPhase.Stationary && touch.position.x >= (float)(Screen.width / 2))
{
mytouch = nullTouch;
}
}
}```
How do I port this to the new input system
touch input seems really confusing on the new input system than the old one
can someone help me understand why my code isn't working as intended?
(rb is the Rigidbody initialized earlier)
it should be adding a force forward if W is pressed, adding a force backward if S is pressed, rotating left if A is pressed, and rotating right if D is pressed
but for some reason, only the A key works properly
(D just keeps rotating in the same direction as A, and W and S don't have any effect at all)
Note: I would prefer to use transform.translate and transform.rotate, but I have found that these are like “teleportation” and thus override any collision mechanisms. As a result, even with colliders and rigid bodies, my objects are not colliding properly when I use transform like this
But if there is a way to collide them properly even that transform, I’d be glad to use them instead
You should not be multiplying Time.deltaTime at the top
Also AddForce/AddTorque are extremely different beasts from Translate/Rotate
You should use MovePosition/MoveRotation if you want it to behave similarly to that
is there a way to detect what controller is connected / in use?
Xbox360 /XboxOne / PS4 etc
look into this demo project. https://github.com/UnityTechnologies/InputSystem_Warriors
im just looking through the code on git (dont want to download it) this is strange, i see that its assigning sprites to buttons, But not how its getting the controller to get the right sprite
string currentDeviceRawPath = playerInput.devices[0].ToString(); im gonna see what this debugs
I can download the project later when I'm come back home, if you'd like I can take a look as well. I just remembered seeing this demo a while back and the UI immediately matched what was plugged in stood out to me
i dont have any other controller to test if its right or not lol
i only have the keybaord and an xbox one controller
foreach(var foo in input.devices)
{
var bar = foo.displayName;
Debug.Log("Device Name: " + bar);
}```
seems to be working then huh
i mean sure, xbox controller, but xbox one controller would be good
and if i were to use an xbox 360 controller, was hoping it'd show that
i might need to buy a ps4 controller to check
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.4/manual/Devices.html checking this page rn
so I guess it can be changed in the JSON
Ooo, need to look into haptics too, that could be fun
I deleted this out of Beginner and moved it to here, didn't realize there was an input system chat.
I'm pretty new at learning the new Unity Input system and right now I'm just trying to do a simple Raycast Shooting using the input system. I have it set up to shoot on left mouse click
This is the script on the gun:
public void Shoot()
{
RaycastHit hit;
if(Physics.Raycast(cam.position, cam.forward, out hit, range))
{
print(hit.collider.name);
}
}
This is the script on the Input Manager:
private void Awake()
{
playerInput = new PlayerInput();
onFoot = playerInput.OnFoot;
motor = GetComponent<PlayerMotor>();
look = GetComponent<PlayerLook>();
gun = GetComponent<Gun>();
onFoot.Jump.performed += ctx => motor.Jump();
onFoot.Crouch.performed += ctx => motor.Crouch();
onFoot.Sprint.performed += ctx => motor.Sprint();
onFoot.Shoot.performed += _ => gun.Shoot();
}
When I press left click I get a null reference exception error, not sure what's causing it. All the other actions such as crouching and sprinting work.
the error should tell you which line the NRE is on. Look at all the variables on that line and think about which one could possibly be null. It should be couldBeNull.XXX to give you a NRE. Add Debug.Log right before that line for each variable that could give a NRE on that line, and see which one is null
Yeah it's telling me the NRE is the line that says
onFoot.Shoot.performed += _ => gun.Shoot();
But it's stumping me as to why
well, onFoot, onFoot.Shoot, and gun are the three things to check on that line
so onFoot is the player input which is made automatically when I save correct?
I don't care whether you think something is definitely there. Add a Debug.Log to see what its value is
Oh I'm not saying something is there haha
I'm just not sure what's missing. You want me to debug log those three things? Is that what you're saying?
yes
Gotcha. One min
uhm, I think I'm slightly confused on how to debug that. normally I can Debug.Log a raycast by checking what it's hitting etc. But I'm not sure how to debug log the NRE line I sent above:
onFoot.Shoot.performed += _ => gun.Shoot();
Debug.Log(onFoot);
Debug.Log(onFhoot.Shoot);
Debug.Log(gun);
don't beat yourself up. Learning is a process
The gun is null
alright, so where did you think you were setting gun? And why did that fail?
So I had the gun set up here I believe:
gun = GetComponent<Gun>();
Which is inside the Awake
yep
I also tried just making it Serialized and dragging it but it's still null
I'm not really sure why it failed though to be honest
can you screenshot your inspector?
Of the input manager section?
You're wanting what the gun should be attached to though correct?
That whole inspector
whatever object this script we're looking at is on
Any chance you have this script on more than one object?
I can check
maybe its null on one of them but not the one we're looking at?
I don't see it on anything else
oh, you know what, when you set it in the inspector, did you comment out the GetComponent line?
I don't think so. Let me try that
I'd rather get it from that line though tbh
But I can check at least.
sure, I just want to confirm that that line is the problem and not that we're looking at the wrong object
So yeah now that's working
okay, good
so, GetComponet looks through all of the components on this object and finds one of the right type and returns that
wait
but this object doesn't have a component of type Gun
If it's in a child I need to look in child right
Let me try that
Yeah now it's working lol.
I hate when I mess one simple line up
I appreciate it!
so fixing it next time should be fast and easy
Hi! I've installed the Starter Assets Pack to use controllers on Desktop and Mobile. Everything works great except that on Mobile, the Look Joystick is linked also to all the screen so when we use the Left Joystick to control the character, the camera moves also. How can I change that to be able to use only the Right Joystick to look around?
Would you mind helping me with MovePosition and MoveRotation? I can't figure out how to make it work like I want it to
Using this code, I can get the object to move and rotate, but all of the movement is unfortunately relative to global coordinates
how can I move relative to local coordinates?
it seems like all the results I find on Google are for transform.translate (or something like it), which doesn't work for me because then I can't collide
nevermind! just got it working 😄
Nobody to help me to check some settings..??
I found that is when I add an Input controller to the Freelook camera, the whole screen can be use to look around. If I deactivate this setting it's okay but now the Right Joystick doesn't work at all...
Did u combine them
by default, yeah I guess
If I uncheck this setting, the camera movement stops on the whole mobile screen
and on the UI_Virtual_Joystick_Look GameObject I have this
@green sun any thoughts ?
I'm the poor designer of the project hehe my partner is the dev but he has too much work for now
I can send u a code maybe tommorow
Wont be perfect tho
Wil have alot of issues
Vus i mainly dk keyboard
for now I think I will just deactivate the input provider.. we have to launch the project tomorrow. They will not be able to look around for now but at least it's less annoying than having a camera who rotates all the time
Have u added a camera lock to ur code
It's the Asset from Unity, the Starter Assets Pack. The only issue I had with it, was the VirtualCamera. the look around Joystick was too fast on mobile so I decided to change for the Freelook camera. I like it better but not for mobile to control the look around Joystick. Finally, I used the Virtual Camera again and I find the settings to be less fast to control. It's different a little bit for the view but for now, it will be okay.
I'm currently mapping out a gamecube controller using a mayflash adapter in the new input system, but the C-stick behaves weirdly. Unity only recognizes the X and Y axis of the controller, and only outputs positive values, so only right and down work. In the Input Debugger Unity does recognize that the x and y axis go into the negatives but I cant seem to replicate that in any way through code or mapping. I tried setting the control types as axis, didnt work. Vector2 did not work either. Anyone have any ideas?
how can i check that a device is connected or not... For e.g : i only want to play haptics if controller is connected.
How can i get what controller im using?
With an xbox one controller it debugs: "Xbox Controller"
with a ps4 controller it debugs "Wireless Controller"
mouse is mouse, keyboard is keyboard.
I want to find out the platform controller being used. so if im using a ps4 controller, i want to know that its a playstation controller.
public void OnDeviceChanged(PlayerInput input)
{
UsingGamePad = !input.devices[0].device.name.Equals("Keyboard");
//Debug.Log(input.devices[0].device.name);
foreach(var foo in input.devices)
{
var bar = foo.displayName;
Debug.Log("Device Name: " + bar);
}
}```
this is debugged when doing var bar = foo.name instead.
unless whats being shown is correct?
Does anyone know why the new input system is throwing this exception?
This is the first time I'm attempting some more complex button behaviour and I found this solution on this post
https://forum.unity.com/threads/having-multitap-interaction-issues.859300/
So if you know of a better way please let me know
private void OnEnable()
{
PlayerCommons.InputMappings.Interactions.Inventory.actionMap.actionTriggered += QuickCheckInventoryAction_performed;
}
private void OnDisable()
{
PlayerCommons.InputMappings.Interactions.Inventory.actionMap.actionTriggered -= QuickCheckInventoryAction_performed;
}
private void QuickCheckInventoryAction_performed(UnityEngine.InputSystem.InputAction.CallbackContext obj)
{
if (!obj.performed)
return;
if (obj.interaction is MultiTapInteraction mti)
{
Debug.Log("Checking quick");
return;
}
if (obj.interaction is PressInteraction pi)
{
Debug.Log("Open Inventory");
}
}```
hmm i dont understand how u can specify inputs for 2 different pads, since the buttons overlap, for example i have to delete buttons relevant to ps pad in order to get xbox pad working correctly, and vice versa
am i being dumb here?
for example on ps square is 0, and on xbox A is zero, both in different places
If a game is menu-based, meant to be controlled entirely through clicks/taps, there's no need to use the Input System, right?
Or are there any benefits to it over using the standard input module and event system?
how would you implement unique key for actions in a map?
what kind of actions
ie player movements, you wouldn't want the same bind for different actions when rebind
Hello everyone! I'm learning about the new input system, watched some videos already, but I'm trying to understand how can I get the Input(Touch) from my cellphone and then destroy the object that it touches?.
IPointerEnterHandler
Hey guys, can anyone help me with Buttons on Android? I'm using the New Input System but want to have seamless swapping between movement buttons
For example if you hold the right button here, without releasing your finger off it, it will remain pushed, is it possible to drag your finger off of it and activate the left? What part of the component is responsible for that?
The Input System UI Input Module processes the pointer for gamepads as well.
PointerType is None, but it still does raycasts at screen position (0, 0) which leads to my UI element in the bottom left screen corner always being hovered while using a gamepad.
That is surely an oversight, no?
Sadly I can't override any of the methods, because they are not virtual.
There is a workaround I just found, basically using infinitely large numbers as the "Pointer" for gamepads. But this feels very janky.
any idea?
only if you bind your "UI/Point" action in the Input module to an InputAction that uses joystick delta as pointer position, no?
No, I tried removing it completely, and it still uses the (0, 0) screen space position to raycast. I've looked at the source code, it really seems to be an oversight.
weird I've never run into this issue
Yea, I've never had an interactable UI element at the bottom left corner, but now I do
the raycast at the bottom should not happen if pointerType == PointerType.None
This is from the InputSystemUIInputModule class.
I'll take your word for it - submit a bug!
I will!
Can you implement dual joy-con local multiplayer for nintendo switch?
like this thing
So I have a q for anyone who has used the new input system in production. Today we tried to plug in a generic gamepad. The system recognized it as a joystick. We had to create a custom class and a struct with explicit byte layouts according to the raw HID data. The docs say that using the InteractiveRebind is better for generic controllers. How ever without our custom struct the listen for input option in the binding menu doesnt even work. So.... WTF ?
For some reason this script isnt changing my inputs, the most it's doing is, changing my text to what i clicked, so it knows what im clicking, but not mapping it to my input system. http://pastie.org/p/3jaGDE7kcnxgDk8dYsN45D
Okay, I tried to use this but I didn't get so far, I'm still with difficult to destroy the gameObject when I click/touch on it... Is there something similliar to OnMouseDown() that I can use in a different way on the new input system? A more beginner friendly way
IPointerDownHandler is similar. Neither are part of the input system
But do I need to add something beyond the IPointerDownHandler to it works?
Another thing that I didn't get it.. normally when you create a public method you can use from here for example:
But when I try to use the OnPointClicker Method in the sameway that is on the documentation I can't acess it through here
this was the code that I was using.. but didn't work.. Is there anything that I'm forgetting or doing wrong?
I tried without the if statement too and it didn't work
only methods that have no arguments or a single string, int, bool, or float argument (don't quote me on this list) show up in that menu
or ones that match the signature of the UnityEvent, which will then show up in the dynamic section the menu (which your screenshot doesn't have since nothing matches)
Why are you trying to hook it up to your player input component? That's not how It works
Yes you need a collider on the object, an event system in the scene, and a physics raycaster on the camera
my paramaters and transitions
You still didn’t figure it out ? Fyi the transitions are the white arrows..
It’s my first time using animations so I have alot to learn can you point me in the right direction? Thank you
