#🖱️┃input-system
1 messages · Page 7 of 1
So I also needed WasPressedThisFrame as well.
Many thanks! 😄
Wow, this whole thing is really cool! 😄
How do I get mouse movement to work with the new input system?
This is what I have thus far...
public class PlayerCam : MonoBehaviour
{
public float xSens, ySens;
public Transform orientation, aimDir;
float xRot, yRot;
public FR_Inputs controls;
private void Awake()
{
controls = new FR_Inputs();
}
// Start is called before the first frame update
private void Start()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
// Update is called once per frame
void Update()
{
// Get mouse input
Vector2 mouseVec = controls.Player.Look.ReadValue<Vector2>();
float mouseX = /*Input.GetAxisRaw("Mouse X")*/ mouseVec.x * Time.deltaTime * xSens;
float mouseY = /*Input.GetAxisRaw("Mouse Y")*/ mouseVec.y * Time.deltaTime * ySens;
xRot -= mouseY;
xRot = Mathf.Clamp(xRot, -90f, 90f);
yRot += mouseX;
// Cam rotation/transformation
transform.rotation = aimDir.rotation = Quaternion.Euler(xRot, yRot, 0);
orientation.rotation = Quaternion.Euler(0, yRot, 0);
}
}
If multiplying by Input.GetAxisRaw("Mouse [X/Y]"), it works perfectly... but it doesn't work with this new scheme yet. 🤔
How to I get the value of an Input Action in script? I made an Input Action and I want that value in my script
I've googled this for an hour and can't find it
I have an Input Action Vector2 called MoveLily, how to i get that value in script
- Make sure the input action is set up as "Mouse Delta" and is type Value/Vector2
- You should NOT be multiplying Time.deltaTime there, remove it.
There are many approaches. It depends on how you want to do it. Many options:
- Using the PlayerInput component (In Send Messages mode or Unity Events mode)
- Using InputActionReference
- Using InputActionAsset references
- Using the generated C# script
I am reading the documentation and I don't understand it
How do I pull the input action value into my player script
Again it depends which approach you're taking
I don't even know what you mean by that
There are many ways to use the input system
{
MoveLily = MoveLily.current
LilyMovement = MoveLily.ReadValue<Vector2>();
}```
I'm trying to do this
depending on which way you are trying to use it, the code to get the value is different
reference the action I made
what is MoveLily?
I made an Action called MoveLily
in the input system
Obviously...
I made an action
I have no idea how to describe it to you
You do one of these things
public InputActionReference MoveLilyAction;```
Then you will need to assign the action in the inspector
ah
then in your code you can do MoveLilyAction.action.ReadValue<Vector2>();
ok that's what I was looking for
Note again this is just one of many ways to do it
I'll try to make it work, thanks!
One thing you might have to do is enable the input action asset before that works though, don't remember off the top of my head
yea the public action isn't showing up in inspector
I just made InputAction, does it have to be InputActionReference?
InputActionReference would be to refer to an InputAction you defined in an input action asset somewhere
And if the slot doesn't show up in the inspector you probably have a compile error
ok I get it
Again can you be specific about this?
Did you define a public InputAction MoveLily;?
Or did you make an action in an input actions asset?
InputAction is if I'm making a new one in script
I didn't know enough to answer your question
reference is what i need
testing it now
You don't know if you wrote the code public InputAction MoveLily;?
Input Action Assets look like this:
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
You either defined your input action in one of these^
Or you did it directly on a script
You mean, in an asset, like this?
in the picture yea
ok yes then InputActionReference will work with it
ok in that code is there anything wrong? because the input value isn't working
LilyMovement = MoveLily.action.ReadValue<Vector2>();
in what way is it not working
when I move the left stick on my controller it's not changing the values
Ok so yeah it might be as I suspected, you might need to enable it
I assigned the left stick as the vector2 in the Input Window
One thing you can do is, in Start, Awake, or OnEnable, you can do MoveLily.action.Enable();
ok it works now, I just want the player to move the same forward as the camera
not the player object's forward
I thought I did that with LilyCam.transform.forward
If you want Translate to work in world space you need to add a second parameter:
transform.Translate(LilyMovement.y * LilyCam.transform.forward * walkSpeed * Time.deltaTime, Space.World);```
I did that and player is still moving it's forward and backwards
show what you wrote, and show what "LilyCam" is assigned to
LilyCam is assigned to the Cinemachine Free Look Camera I made
Should assign it to the actual unity camera (the one with the CinemachineBrain on it)
not the FreeLook
the FreeLook (especially the top level object) is not going to move
I currently have a problem with the Input System: I am using this 2d vector for the WASD Controls, "Keyboard" is a digitally normalized 2d vector composite. If I press W or S, and try to read the vector, it tells me that both axes are zero. Only when I press A or D simultaneously, the y axis(W/S) updates correctly. This doesn't happen with the x axis(A/D), it always updates correctly without further button presses. I am just really confused here, is this a Unity bug or did I miss something?
hey is the function SwitchCurrentActionMap() still available? my editor doesn't seem to recognise it
Arent onpointer events and checking for raycast hit from a mouse identical at least for 2D Games? Are there any performance benefits?
No they're not identical, no performance is not a major concern
The main benefit is your UI will seamlessly work with clicking on game world stuff
I've added a second canvas, and now it doesn't seem to recognise when I press button components, No idea why, it's still registering the clicks and I've tried a few things like changing the Graphics Raycaster settings but no luck.
Is the other canvas blocking it?
You need to make it Value/Vector2
Hello Guys,
we are developing a tower defense game and facing the problem, that our cursor is leaving the screen when scrolling to the edges if people using multiple monitors.
We tried different cursor lock methods but they doesnt seem to work correct.
I think this problem should be solved very easily but i cant find the correct way right now.
Is someone here who can share his/her knowledge with this? 🙂
please please please PLEASE someone help i have been working on this for almost 4 days
Go to player settings and for input chose both
Hi there, let's say I wish to have a different event if:
-the button was tapped.
-the button was hold.
-the button was released.
Also I wish to know if:
-the button is currently being held
What is the "intended" way of doing this with the new input system ? Multiple interaction Or Multiple Actions ?
The aim is to have:
-Tap: WeaponSwap with Previous one
-Hold: WeaponWheel
-Realease: Close the wheel
You need to convert your scripts to the new input system
your actions can have different states
A single action with a Hold interaction
You mean Started Performed and Canceled ?
And started/cancelled/performed subscriptions
And IsPressed() to check if currently held
But in this case I can't have n event for the release of the button after the hold is performed no ?
Because Performed would be Hold
Cancled Would be the Tap
Okay so here I can't really have the tap event
Oh np ^^
What ended up happening was that the new Canvas replaced my old EventSystem somehow, so it wasn't using the New Input System.
"request class"?
You mean serialize it?
Well for one if it's abstract you're going to need to use [SerializeReference] on the array
for two, your class needs [Serializable] to be serialized
for three... you're not really going to be able to do this with an abstract class this easily.
not without some extra editor scripting
it won't be abstaract, i just want put abilities inside unit, while all abilities implement Ability.class
- _ - it - will, implementations wont
obviously
i feel dumb...
did you do this part
because it's complex
I posted this in another section before noticing the input system has its own channel. I am having an issue where my input system is not updating the C# script that it has generated. I have tried a refresh, a reimport, disabling auto save, manually saving, regenerating the C# script, but it will not add my new action map or any changes to the script.
Double check the script name vs the asset name
If you changed the asset name it may be generating under the new name
Also of course check the settings on the asset
They are identical, its not generating a second script either
Tried deleting as well it refuses to automatically generate a new one
have you checked the settings on the asset?
By the asset you mean? The input system package or the input handler? I have it set to auto-generated with the right location for the script.
They match up. No missmatched names or anything
About the UI ToolKit, when I touch the textField, the keyboard of mobile did not pop up through Unity remote. Anyone knows how to pop up it, thank you.
Sorry,I misunderstood, this is the wrong channel.
how do i use the new input system
Resources are pinned top right in the channel.
[Qick question]:
Can i get the playerindex from only the InputAction.CallbackContext?
i am subscribing the same function to multiple PlayerInputs but the invoke only has the InputAction.CallbackContext as a parameter and i dont know how to get the PlayerInput.playerIndex from there. Or is that not possible?
the function needs the playerId
i am subscribing the same function to multiple PlayerInputs
Why?
in what context
is the subscribing object not itself unique per player?
its a single object that multiple players should be able to interact with.
why is it subscribing to all the players inputs then
shouldn't the player input be handled on the players, and the players communicate with this script?
that is a question i asked myself as well... the script managing all players could exist and work fine on its own without the players knowing of it. I kinda like this solution because of that.
On the other hand there could be a player component script managing the input-otherScript connection and having clean access to the PlayerInput component. Then the functionality of the other script is coupled to the player components. Idk if i like that design. not sure. Any thoughts?
Then the functionality of the other script is coupled to the player components
Not sure I follow here
I'm imagining something like this on a script attached to the player:
public void HandleInput(CallbackContext ctx) {
MySharedObject.Instance.SomethingHappened(this.playerInput.playerIndex, whatever);
}```
the other script has its core functionality and struggling to get the playerinput. I could solve that struggle by handling the playerinput with a script on the player and coupling that with the other script. Kinda like you just wrote.
but it is very possible to keep everything on the other scripts and not change the player at all. The only hangup i got is the missing playerIndex which does not seem to come with the CallbackCOntext
you can hjave the players fire events
to inverse the dependency
e.g.
public delegate void MyDelegate(int playerIndex, whatever else...);
public event MyDelegate MyEvent;
public void HandleInput(CallbackContext ctx) {
MyEvent?.Invoke(this.playerInput.playerIndex, ...);
}```
Then have the "other" script listen to this event
ahh, thats quite nice. so basically extending the callback with another delegate layer using additional parameters.
cool, ill try that. Thankyoou!
Rather than playerIndex it might be simpler just to pass this in the event too
up to you
I think the first bit was already that way...
However, after getting rid of the multiplication of Time.deltaTime, it still doesn't budge.
(Before you ask, I also tried setting the delta to Mouse instead of Pointer and got the same result too.)
I'm trying to add a "sprint" mode for my character. I want you to be able to hold down space while any of the WASD keys are held down as well. How would I do this correctly? Can I use a modifier or something in my "Move" input action?
No, you have to track that Space is being pressed and released via a bool isRunning for example, and use that when handling the movement.
@timber robin Ye that's what I ended up doing, thanks
Input.mousePosition returns the mouse position on the screen, but I want to know the mouse cords as if it were a gameobject. Is it posiible?
Of course. But you need to be more specific
"as if it were a gameobject" is vague
you presumably want to project the mouse position into the game world
but you need to be specific about the "depth" of that projection
for example if i created a circle on 4,4,0 and the mouse points on its center, the property would be 4,4,0
that's still kinda vague
do you want to know where the mouse is on the x/y plane where z == 0?
yep
Or do you want to know where the mouse is on whatever GameObject it happens to be hovering over
everything except the main camera has z as 0 in my game
that doesn't quite answer the question 😛
but I'll assume you mean the x/y plane then
Is your camera projection perspective or orthographic?
ortographic
ok then you can just use ScreenToWorldPoint
thanks
so just ScreenToWorldPoint(Input.mousePosition)
I'd say do this:
Vector2 mousePos = ScreenToWorldPoint(Input.mousePosition);```
that way you drop the z
So I'm currently trying to run through the steps required to fix the input system issue that I am having. After going through everything recommended I tried to delete the C# script again, but it will not generate a new C# script, even with auto generate on.
I think I had a naming conflict. Deleting the input system and rebuilding it with a different name allowed it to work fine.
Aw man I wish we had something like this in GZDoom... or we may, but I just haven't discovered it yet. 🤔
OK so new development...
I debugged my script like so:
// Update is called once per frame
void Update()
{
// Get mouse input
Vector2 mouseVec = controls.Player.Look.ReadValue<Vector2>();
Debug.Log("Mouse X: " + mouseVec.x + ", Mouse Y: " + mouseVec.y);
float mouseX = /*Input.GetAxisRaw("Mouse X") * Time.deltaTime */ mouseVec.x * xSens;
float mouseY = /*Input.GetAxisRaw("Mouse Y") * Time.deltaTime */ mouseVec.y * ySens;
xRot -= mouseY;
xRot = Mathf.Clamp(xRot, -90f, 90f);
yRot += mouseX;
// Cam rotation/transformation
transform.rotation = aimDir.rotation = Quaternion.Euler(xRot, yRot, 0);
orientation.rotation = Quaternion.Euler(0, yRot, 0);
}
According to the debug, whenever I move my mouse, it's still returning 0 for both axes.
did you ever enable controls?
I'm such a dumbass.
In any case it works now!
HOLY SCHMIDT I gotta turn down the sensitivity now.
Thanks!
BTW... is there a way to interpolate the mouse movement now?
'Cuz it feels kinda rough.
Huh... I guess it wasn't as smooth before, either.
Sensitivity was just a bit too high still.
Would still be cool to know about interpolation for that, if it's possible... 🤔
lots of games use so-called "mouse acceleration" and I want to die whenever I play one
give me 1-1 mouse cursor to look rotation or give me death.
Hey...
how can i remove the titlebar in unity or change its color to black ?? any ideas
or maybe just making it fullscreen ?
does unity provide facilities to switch between different input contexts
like mouse controlling a mouse cursor in ui but player look when the menu is closed
or player movement with wasd in one mode but maybe moving a map view in another
or is that something I have to implement myself, like an input manager that different layers of my application can attach to or detach from
I suppose my input receiver manager could enable/disable inputs on various objects that have InputActionMaps
Halo all
I'm using IPointerClickHandler.OnPointerClick, which works, until at some point i add another unity physics scene
I'm doing multi unity physics simulation scene. Each sim scene has an EventSystem object, which gets disabled depending on which scene is the "focus"
Physics.Raycast also doesn't work, btw. Had to do the PhysicsScene.Raycast variant for it to work
So, is there any extra step i gotta do to make IPointerClickHandler work?
Yes this is what input action maps are for
The issue here is the physics raycaster on your camera
I've never actually thought about how this works with multiple physics scenes but my assumption is that the camera needs to be in the scene with the physics you want it to Raycast to
Yes that's already the case
Each phys scene is a replica of the others, already handled the dis/enabling all but the "active" one
It's ok tho, end up doing manual physScene.Raycast. A bit more work but reckoned will need the extra control in the future anyways
My guess is that under the hood physicsraycaster uses Physics.Raycast instead of the physics scene version
The robust way to handle this would be to make a custom raycaster that uses physics scene Raycast I suppose
Is there anyone here who might have a second to chat with me about a weird issue I'm having with the new Input System? It looks like the input system is not allowing player input (other than movement) when my game manager is in the scene. It's a very weird specific issue with no errors to guide me, and I'm wondering if I could get someone to just hop on a call and look at what I have going on and maybe there is something I'm just not doing
Hey, how can i change in script the EventSystem first selected item ? thanks
help, i installed the input package and already have an error, it shows up every time i try to interact with input manager, input manager doesn't work too.
ah nvm fixed it
Update, I figured it out. I wasn’t switching input maps.
It turns out all I needed was a few hours of sleep.
Does the Input System have a simple way to detect last used device manufacturer? I'm trying to make UI icons that update automatically and the onDeviceChange event is not working the way I assumed it did.
Hey everyone. I've got a bit of a problem. I need my input system to make an action on the button release.
What I do:
What I expect:
When I press escape, main menu should open
What I get:
The main menu opens and closes like thousand times in a row.
What am I doing wrong?
I'm using Player Input component in Send Unity Event mode
Sounds like you're not checking the phase of the callback context in your code
if (context.performed) {
OpenMenu();
}```
note this will happen on button release with that interaction
I don't have a code. I'm using Player Input component from the Unity Input System package. That will not work?
You said you're using Send Unity Event mode
oh god you're using SendMessage?
don't do that
no that won't work
It's not PlayerInput that's the problem it's that you're using SendMessage
make a proper listener function and call that
Also that looks like a totally different action than the one you discussed above
Oh, sorry, that's a bad example))) No, I'm not using SendMessage, I'm calling a function.
Sorry) I've meant I don't receive input through my own code, I'm using PlayerInput.
and in that function you should be doing this
Ok, I see. The function I call is input agnostic. It is called through multiple different methods, and it can't have any code related to the input. I was hoping PlayerInput would take care of that for me but apparently not. I'll try to write my own input receiver. Thank you!
Hey, I'm trying to do an equivalent to key pressed, I don't want to hold the button down, how my code works now is it takes my right gamepad stick press and I have it switch cameras, but it switches back and forth then I hold the button down, and I don't want that I only want it to detect the initial button press
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
it only takes the button value as a float which I must be doing wrong
it said it wouldn't take a bool
if (CharSwitch.action.WasPressedThisFrame())
guys how do i create repeat script while holding key?
like
Mouse.current.leftButton.isPressed
@full rose write it on update when ispressed true
Excellent, thanks!
mouse input works on Android phones, right?
Is there no way to get the Laptop's Trackpad horizontal/vertical/touches in Unity ?
how, show me an example ?
there's no way to detect it using mouse, only thing mouse detects is position click of 1 finger + scroll of trackpad
idk about pointer tho
is that not what you're asking about?
What are you asking about
what is a "horizontal/vertical touch"?
i want to simulate the trackpad pich-zoom and twoFinger-drag of google chrome
but i cant detect neither in unity.
pinch-zooming in unity of trackpad is mouse wheel
nothing more.
Learn how to use the new input system to detect pinching in mobile! I'll also show you how to zoom in and out.
📥 Get the Source Code 📥
https://www.patreon.com/posts/46446020
🤝 Support Me 🤝
Patreon: https://www.patreon.com/samyg
Donate: https://ko-fi.com/samyam
Disclosure: This post may contain affiliate links, which means we may receive a com...
Pretty sure the touch stuff works for trackpad
If not here's a plugin for it https://github.com/kevinw/trackpadtouch
nope tried it, doesnt work
idk then
this is it, but this is only for apple tho
I think you will basically need a native plugin per os
yea so unity doesnt support it for some reason.
Is there a way to get an InputActionReference by name from an InputActionAsset? Looks like i can get the InputAction, but I want to get the InputActionReference.
InputActionReference is not typically a thing
it's just there to refer to an InputAction directly in the inspector
If you're not explicitly making one, it doesn't exist
Creating a new InputActions asset just creates a blank file. Here's what happens when I click on it
I'm using InputSystem 1.4.4 and Unity 2022.2.0b10
Do you have any errors in your console?
I reimported and it worked again
Facing a different issue now though
I’ve exposed InputAction as a field in some Monobehaviors and I can no longer set the binding form the Inspector
I have to click on Properties and do it from that window
hi for some reason this script does not seem to work properly with regards to inpt master. i get a argumentnullexception
public InputMaster controls;
// Start is called before the first frame update
private void Awake()
{
controls = new InputMaster();
//Subscribe to interact button press event
controls.Player.Interact.performed += ctx => Output();
}
void Start()
{
}
private void OnEnable()
{
controls.Player.Enable();
}
private void OnDisable()
{
controls.Player.Disable();
}
Im not sure why it doesn't work as i set it up the same in other scripts
Where do you get an exception
Hello, General question.
in unity, if a mouse click happened, would the event of press be dispatched in the next frame or the same frame ? would the event of release be dispatched in the next frame or the frame after it or the same frame?
It will be in the frame during which it is pressed
Release will happen in the frame in which it's released
interesting. and how is that possible ?
does it mean that input is run in // ?
also what about mouse position ?
huh? What is //?
What about it?
No the input is basically gathered at the beginning of the frame and the state of it remains the same all frame
So I’m trying to implement the new input system, but I can’t find the player input component. I’ve tried three different versions of unity with no luck. Its just not there when I search for it
Did you install the input system package?
hello i don't know why this isn't working with the shooting method the code is down below
do i need to add something in here?
You never enabled playerInpuActions
I was following Justin's tutorial and but at the moment of adding the XRI Default thing this popped out:
and also 20 errors
this is the tutorial: https://youtu.be/yxMzAw2Sg5w
hi folks i am trying to figure out why, in my blend tree for the animator, it correctly switches between up and down animations (when the y input crosses from negative to positive around zero), however for left and right animations, it sticks to right until hitting exactly -1 for the left
Hi guys, How can I rebind composite binding? In movement I have: Left/Right and I want button for each of directions
this is code I'm using for normal binding: rebindingOperation = action.action.PerformInteractiveRebinding(3).OnMatchWaitForAnother(0.1f)
.OnComplete(operation => RebindComplete()).Start();
Is there any way to use the Touchpad (on laptops for example) specifically? For example registering a two finger swipe gesture
I can only find support for Touchscreen
Can anyone help me with this?
make sure your camera has the MainCamera tag
doesn't seem input system related TBH thuogh
HI! Can someone help me with touch controls? As in explain it to me like I was 5.
I'm trying to implement a simple "Tap this object" touch control. Nothing fancy. No swipes or anything like that. Apparently Unity discontinued the Mouse Click = Touch a while back and I didn't realize this. Anyone willing to help someone who does not understand these docs?
Has anyone been able to figure out how to get a "Hold and Release" Interaction to work with SendMessage input? InputValue for a button has literally zero ways of returning useful information except "isPressed" which isnt exactly helpful in determining if the Hold interaction is still held or not, since it only triggers true like, the frame that the Hold condition is met, but immediately becomes false. Can I convert the InputValue to an InputAction.CallbackContext in any way?
EDIT: Apparently, the fix is to set the Action Type to "Value" and the Control Type to "Any." Extremely unintuitive way of getting the value to return true when hold time is passed and return false when the button is released. But it works for me with InputSystem 1.4.4 and Unity LTS 2021.3.8f1, in case anyone else uses the search function to find a solution.
Yo guys I am making a 3rd person shooter controller with the starter asset input package by unity I am trying to make aiming with holding right mouse button but it isn't working I tried by Debug.Log method but it isn't workin
I made this method as well on the Starter Asset
AH! Ok my post was moved into input. Makes sense. I wasn't sure where to post my question. Anyone know about touch who's online?
@austere grotto I love you so much
Hi people! I was wondering how to distribute Action Maps across Input Action Assets and where to attach those assets as components in the scene. For example is it a smart choice to make an Input Action Asset called "MainCharacter" and attach it to the main character prefab? Because I did this, but now I find myself in the situation that I need to disable the possibility to control the main character when the game menu is open and I am not sure what's the cleanest way to do this.
What you people usually do?
Should I make a generic Input Action Asset with the "MainCharacter" action map and the "Menu" action map and attach it to both the character and the menu?
Guys can you please help me? I'm trying to make a game and I use Input.GetKeyDown to find out when button was pressed. But Unity keeps telling me nothing like GetKeyDown exists, refuses to run my code and I have no idea what to do. I have the odl player input enabled and it doesn't work.
Unity keeps telling me nothing like GetKeyDown exists
Read your error messages carefully, they contain important hints on how to fix your issue
refuses to run my code and I have no idea what to do
Again, the errors will likely give you hint. For example "Fix all compile errors before entering play mode"
it doesn't work.
Specific error messages and code etc. would be helpful. We can't help you with vague statements like this.
Whole error message. Input is the script
(this discussion was continued in #💻┃code-beginner )
@tame oracle Don't crosspost. #💻┃code-beginner
why isn't my mouse input being taken.... I am using a keyboard function and a mouse function and only the mouse isnt' working
PI.PlayerMap.Menu.performed += MenuInput;
PI.PlayerMap.Fire1.performed += ChangeTargetNext;
PI.PlayerMap.Fire2.performed += ChangeTargetPrev;
only the first one is working well
as for the 2 functions ChangeTargetNext they'er not... first command i use in the 2 functions is debug... and it is NOT showing
this is how I set up the fire1
(same for fire2 except right mouse button)
anyone who can give feedback would be really appreciated
The code and config you have shared do not contain the error. Did you enable all actions you are using?
sorry I was away @verbal remnant
I dont know why you're refering to nvidia and vr...
My code's problem is that the controls aren't being performed... only the menu.performed is getting invoked... I dont know what's the cause.. there's no error or anything when I run the game.. which makes it more confusing
nvm the nvidia thing, that was supposed to go into a completely unrelated message
ah ok
if the .performed is not happening, either the InputAction is not enabled or the configured input device is not added to the input system
I am sure they both are... I checked everything related to both the menu and fire1... still not working for some reason
how exactly did you check?
can you share the code where you enable the action?
you are only enabling the menu action
the inputmanaging is a game object that's in the scene and inputactions public
call Enable() on the PlayerMap to enable all
what do you mean
the last line in that screenshot enables the Menu InputAction
it does not enable the other InputActions
oh
💀 😒 I am blind... I saw it yesterday I thought it was the inputmap not the menu
thank you
depending on what your EventHandlers do, you may want to use a more constrained event to detect action triggers, what you are doing there basically eliminates most of the configurability you have with the Input System. For example, if you use someAction.triggered, you can configure exactly how that trigger behaves in the editor.
I am not sure what you mean... but the current goal doesnt require me to get the exact moment the action was triggered... just when the button is pressed
well, the main point of the Input System is to abstract away that notion of a "button" into a the generic concept of an InputAction. The idea is that your game-logic should not care-about how an action is physically triggered, (e.g. via a button press or joystick actuation or a shaking of the device). You need to clarify what the difference between a button press and a trigger signal would be and whether that is actually meaningful to your gameplay logic, It would probably make sense to make two separate input actions if you need to differentiate a half-press from a full-press or if you want to differentiate keyUp and keyDown.
oooooooooooh now I get what you mean.. @verbal remnant thank you
yo tryna learn off of other people's code, is InputActions a class inside of the InputManaging Class? also what is performed, is it using operator overloading?
that's my code... also yes it is... because I wanted the input asset to be universal through all my game aaaaaaaand no.. no overloading
does anyone know how to use a custom input action for "UI/Click" on the event system for basic menu controls?
on the event system when i got that warning regarding old/new input system i forgot what i clicked but this basically almost did the whole menu screen navigation
but i have another input action i have from another action map i want to put in the Click to basically click a button on my menu but i cant get it to work
You can only pick actions from the actions asset you've dragged into the slot in the inspector there
Can someone help me?
I am using the new input system, I have set 2 inputs; one is Vector2(value) for wasd and the other one is bool(button) for space. These inputs are bound to actions and work correctly in the editor. However when I build the game space works but wasd doesnt.
you'd have to show more details about your setup:
- how your input actions are configured (any interactions etc)
- how you hooked them up to your code
- your code itself
You can and should also debug your code in the build
i will try to debug but are the details necessary when it properly works in the editor?
yes
they are
Some things that can cause differences between editor:
- reliance on some specific script execution order which is not guaranteed.
- framerate dependent code
- reliance on the ordering of a collection returned from a Unity api method which is not guaranteed
etc... which can only be deduced from looking at the code.
ok so first of all i am using a state machine that selects a current state(which is a script) and enables it and runs its update methods
should i send the scripts?
Not sure what the problem was but after some debugging and refactoring I managed to fix it. Thank you for the help!
Hey! Super general question about the "new" input system. Whenever I load a new prefab, I have to redo my PlayerInput Action Maps because they are using editor references.
I am guessing that whenever you spawn a player controlled character you just add to the Start script and update all the references for that correct? Or is there a simpler way to do it that I'm missing?
Can you elaborate on what you mean?
What do you mean by "editor references"
inspector references if i had to guess
drag and drop into the field sort of references
couldn't you just put a PlayerInput component on the prefab youre spawning?
Action Maps
Assuming you set them in C# script when you spawn the Character. Can't really find anything on it. Can you change these at run time? Like what is the correct way to set these?
you can assign to unityevents at runtime yes
Just assign them on the prefab itself
What happens if the object they are referencing isn't created yet? Will it trigger an event, or if the object it references is destroyed?
null reference
You won't be able to assign it then
its probably better to have a script that searches for this object and sets the unityevent up
or even better make a method on this script that gets called by these events inside the prefab
In a player input context it's really weird to need to worry about this
What are you trying to do
It's multiplayer. So these Prefabs are going to be spawned in. Setting them in the prefab beforehand will not work.
You should attach player input to the player prefab and assign everything to a script on the prefab
The playerInput should be part of the prefab
^
It will work
i think the issue is
main_Server object is inside the scene
thus the player prefab cannot reference it
What the heck is main server and why should playerInput care about it
in this case attach a script that retrieves a reference when spawned in
Is it a singleton
Just reference the singleton as usual through the static field
No need to hook playerInput callback directly to it
Oh wait that wasn't it. Can someone show me in Docs how you set those in code?
Ohhh I see why you guys are confused now, I'm not supposed to be using these to call functions on other prefabs. I can just have them all reference the PlayerController locally. And from there I can call out to other gameobjects.
Yes
@tardy apex Don't ping people or user groups, it's obnoxious. Ask your question like everyone else and anyone who wants to help, will.
Well, I'm sorry, but this problem has been with me for two days
When I start a new project it never wants to activate it
Tells me failed to create project
Hey im having issues with turning off Soft Keyboard on tmp input field, it's not accepting text at all
Question: I got a class generated from a inputAction-Asset. Can i create multiple instances of those or do these block or clear each others access to inputs?
You can make as many instances as you want
Sweet, thanks!
so i added input system form the pakage manager and then set it as both in project settings but keeps giving me error for getkeydown methods and also evn if i click the old one only still same issue do any one knows whats happening?
Can i use the action map i already have for movement for one game object on another instead of creating a new one? Like with broadcast message
Hello everyone, not sure if it's the right channel but it's input related 😄
I'm trying to setup some script using the IPointerDownHandler interface.
My scene contains a game object with an Event System and a Standalone Input Module.
My main camera has a Physics 2D raycaster (also tried with the regular raycaster) and a CinemachineBrain (not sure if it impacts anything).
Also, the game object which i'm trying to click on and has the interface attached to has a polygon collider.
I do see my script Start Debug log but nothing ever comes into my public void OnPointerDown(PointerEventData pointerEventData) method.
Any ideas of what i'm missing ?
Standalone input module doesnt work with the new input system.thats for the old one
oh
The one you need is InputSystemUIInput Module
Is that a component ? can't find it
I got Touch and standalone module
oooh god I just saw it
It's always hitting the cinemachine confiner collider
🤦♂️
hi
my gamepad goes offline after 2 seconds when i plug in
why?
i tried 2 different pc 2 different gamepads usb and bluetooth ones its same
it can recognize disconnected but i plug in again
it gives error about parsing data?
??
I seem to have input actions that are mutually exclusive
in one place I create an instance from the codegen-ed IInputActionCollection2 derived class
then for a camera using cinemachine's CinemachineInputProvider I use an inputactionreference from the same asset
however, if I set autoenable on cinemachine, which enabled the inputaction the reference resolves to, I can no longer use the player movement from the codegen instance
if I do not autoenable it, camera movement does not work. if I enable the camera action from the codegen class it has no effect
I am wondering how this works
Hi all!
So at the moment we're removing a certain control scheme from our InputActionAsset with the help of InputActionAsset.RemoveControlScheme
Now the thing is, is that the Unity Input System is still listening to the controls within that removed control scheme.
Is there anything we're missing here?
@frigid kernel That will result in not executing the action at all, right?
Because I still need the action for a certain device.
The action still exists and will handle button presses, it's just not part of the ActionMap anymore
But then the binding to the action will still exist. OK, I'll get an example.
So we're having a "Mute" action connected to 2 ControlSchemes. XR & Generic XR.
In the XR Control Scheme, the primary button of Oculus is connected.
In the Generic XR Control Scheme, the grip button of a generic XR device is connected.
Now what we want, is that whenever an Oculus device is detected (which we already have made), the Generic XR ControlScheme needs to be removed and not be listened to at all anymore. This however doesn't happen and for some reason, the "Mute" action still has the Oculus grip button connected with it. (next to the primary button)
How is that possible?
this is quite a basic question, but after mapping inputs, how do i make the sprite move?
This is not a question that can be answered quickly. You should watch the tutorial video on the new input system on Unity's youtube channel to understand how to read the values from input.
read the input data in your code.
Use the input data to move the character in whatever way your character moves
What is the point of the Dpad control type vs Vector2 control type?
never used dpad but I assume it's a matter of dpad being 8-directional vs full 360 degree freedom for joystick
Yeah but when you ReadValue is there a type that can be used other than Vector2? Because if not I don't see the point
the point is the different data you get...
Ohh I see
Does anyone know why my controllers are giving constant events (like 500 a second) in the input debugger? Also, my PS4 controller is recognized as both a PS4 controller and an Xbox controller. I get 2 inputs for every key press. I don't use DS4 or any other driver.
Do you have another controller plugged in by accident?
Otherwise IDK that might just be how it works
Are you seeing any weird input data in your game?
In game mode, absolutely. If I build the game and run it via steam everything works perfectly. But in the editor, I get 2 separate inputs with my 1 controller
On top of that, my switch pro controller gives no input (despite the input debug screen looking identical to the PS4 one. Tons of events.) Works fine in steam though too
hi, i'm using the new input system, and it seems like the game can only detect 1 device at a time in the editor (the first one hit after pressing play) regardless of how many players are in the game or having auto-switch off. i even manually joined players with specific controls in mind so each stays, but they are still both controlled by the same controller:
var player1 = PlayerInput.Instantiate(player, controlScheme: "WASD", pairWithDevice:
Keyboard.current);
var player2 = PlayerInput.Instantiate(player, controlScheme: "Controller", pairWithDevice: Joystick.current);
is there any way to make the system detect each device differently for each player? i've gone through several tutorials and i don't think i'm making any progress
Hi! im a student currently trying to debug my project(Level based maze game) , was wondering if i could get some help! Im using the joystick pack off the asset store and have encountered some very annoying issues such as , when i reload the scene like switching levels sometimes the joystick doesnt wanna move my player, the handle moves but my player stands still , theres very little code for this so im not sure what else to try change and ive run out of ideas as this is due monday. I tried setting the coordinate values to 0 in the start but this didnt change anything and made my player angle to one side. Any ideas would be amazing ty
Do you destroy all objects when changing the scene or do you keep some of them alive?
Hi! I'm currently working on a game's UI system, more specifically on the main menu. I want to add button actions to navigate between menus. Most important functionality is when pressing "ECP" or "B" on the controller I would go back to a menu. I see that there is a "Cancel" event, but how can I connect actions or buttons to it? I'm really struggling with event handling in unity rn
hi! No i dont think so the objects are just standalone in the scene , not instantiated or anything, so the scene stays as is and just resets whenever i change levels. im fairly new to unity so not experienced much with loading in objects and prefabs etc
So when you change the scene, none of the old objects stay? And there not multiple ones? Is Object.DontDestroyOnLoad used in the scripts?
thats my scene view , the only thing im changing is my player that moves around , theres nothing in my scripts that handle any of the objects in my actual level scene apart from colliding with my coins
thats the code for the movement itself if that helps
Okay, you need to debug. Attach visual studio and find out which parts of the code are called or not. Not only your code, but also that joystick-class.
i just find it odd that it works completely fine the first time its loaded just never again after
how do I use both input systems at the same time?
Why is it greyed out
Project settings -> Player - Configuration -> Active Input handling
You can select "both" there
@night dew i fixed it! i just forgot to reset timescale back to 1 🤣 😅
Haha, that happened to me once a few years back. Well glad to hear that it works now.
You don't have the correct action type and control type chosen
O tysm!
Hey all, XR guys here, i'm messing around with things. I bought the VRIF from BNG, great tool!
Weird issue though, in editor when i play, my sprint control works fine, when i build, it doesnt sprint but seems it registers the input because i see a little skip in movement when its clicked down
but im stumped with it
Can someone please help me I keep getting this argument to come up
ArgumentException: Input Button Cancel is not setup.
To change the input settings use: Edit -> Settings -> Input (edited)
ive looked threw my Project settings and can't figure it out
click "reset" top right in the settings on input then just fix your inputs accordingly to what you have set in-game. that's what I did to fix it quickly.
thank you i just remade the cancel input and thta seemed to fix it but i will do that from now on
Not sure if this is the right channel, but does anyone have a resource they could link that would teach more more about why aiming with a joystick typically "sticks" when the aiming direction approaches either of the four cardinal directions?
Hey. I got 2 Gamepads plugged in, but "Gamepad.all.Count" is still returning 0. Can someone help me?
The controllers in question do show up in "Devices" in the Input Debugger, but it doesn't change "Gamepad.all.Count".
i want to run in my game using left shift and right trigger, i have that exept i dont know what right trigger is defined as
When you're setting the input in the map, you can click the "listen" button and press the button on your controller.
where is that?
Oh this is the old system.
https://docs.unity3d.com/Manual/class-InputManager.html
so what would right trigger be, that doc didnt explain much on finding what buttons to what trigger and such
This is where you use Google. You see that they are generic Joystick Button 1,2,3 etc.
So look that up. You get this answer
https://answers.unity.com/questions/1483922/how-to-map-controls-for-any-controller.html
Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers.
this shows it being joystick button 5, i have that and its not working still
Can someone help me out with this?
So I'm having issues where my Spacebar is tied to skipping/continuing text in dialogue as well as interacting with objects. Currently, when I try to skip or continue dialogue in front of an NPC, it immediately re-triggers the dialogue by interacting with them.
Will switching to the new input system fix this?
That's a 40 year old issue and the input system can't solve that. You want the player to press space in rapid frequency without delays when he skips through dialogs, so limiting that on the input system level won't help. What you can do is just disable the key for a half second at the end of the dialog. In the new InputSystem you can Enable() and Disable() individual actions and keys easily.
Okay, i am relatively sure there was some debug visualization of the UI with lines that show in which order navigation by keyboard works. What is it called?
Is there a flag that determines if the player control is active or not? If you saved that for last when exiting out of a dialogue, you might be able to solve the problem.
It's okay, I was able to get around it with a lot of tiny wait coroutines and bools 😅 I'm sure I'll need to switch to the new Input System eventually though
Can someone help me with my Gamepad detection issue?
sorry, i'm having issues too
reposting if anyone can help
hey
i am using Joystick everything is good on UI but
i can not select anything, when i try with gamepad its select with "X" but in joystick i can not select anything
any idea?
i can navigate on ui but can not select
is there a version of InputField / TMP_InputField which correctly uses input system instead of IMGUI?
The connection between the UI and the event system is the input module
unless i'm misinterpreting what you're saying
i am specifically talking about why such a gist exists - https://gist.github.com/ErikOG/5ec6c344148e880e01236b7199b4c928
because both classes use Event. which is an IMGUI class for gathering keyboard inputs
oh for the typing
i really need the wojack pulling eyes face
i don't understand how components everyone uses are not maintained for years
it's ridiculous that instead of using new input system, they use IMGUI instead.
i mean they have code specifically for input system
but instead of wiring it up to the input system keyboard or something like that
it uses imgui
i assume this is actually because of IME
is there some kind of IME event layer for input system?
it does
so they have no excuse
was input system's multiplayer selections ever implemented?
like is it actually true that each user has their own selected object? how would you query the player's specific selected object?
it doesn't look like it is, it looks like vaporware
How do I get continuous input from a gamepad stick? Right now I'm just getting input when the stick is moving, but if I hold it in a set position then I stop getting events from it.
Hello there!
I'm creating a 2D game which has local multiplayer. I'm using Mirror as well to support networking.
However the Unity Input System is playing up and being weird with split screen and controls
I have 3 Inputs I want to work at the same time locally: An XBox controller, a PS5 controller and Keyboard+Mouse.
When I create the first Player instance, no input is detected.
When I create the second Player instance, the PS5 controller will control it.
When I create a third Player instance, the PS5 controller also controls it.
When I create a fourth Player instance, the XBox controller controls it.
The keyboard input never works.
Each player object has it's own Player Input script, movement and character controller.
How are you creating the player instances
Network.Spawn(gameObject)
You're not using PlayerInputManager?
I have one
however it does not create my instances (still produces split screen)
as I need to instantiate them through Mirror
I have seen that there is some way to register my objects with the PlayerInputManager but I have been unable to find how to do this
PlayerInputManager creates the objects with the Platerinputs for you
Your player prefab should have playerInput component on it it'll wire it up for you automatically
That's the point of PlayerInputManager
You can have that prefab spawn the network objects separately and control them
[Unit Test] so I want to simulate mouse click on buttons with this script
_input.Move(Mouse.current.position, eventButton.GetComponent<RectTransform>().RectTransformToScreenSpace().position, queueEventOnly: true);
InputSystem.Update();
Debug.Log("Mouse pos room test: " + Mouse.current.position.ReadValue());
_input.Click(Mouse.current.leftButton);
InputSystem.Update();
but the button won't get clicked. is there something that I missed?
do you have an event system and input module in the scene?
graphic raycaster on the camera?
did you meant on the canvas?
I have. I've been successfully simulate escape key before
yes I have it attached
I've debugged the button position and mouse position. the result is close
note that canvas space and screen space are not exactly the same
Save the vector and when you dont get any new input, use the saved vector
Thanks that’s what I ended up doing. I had to wire up separate inputs for mouse and stick, which seems to defeat the point of using an input system, but I guess it’s not perfect.
Read the value in Update
How?
Straight from the InputAction with ReadValue
Oh, something like this?
public InputActionAsset inputActions;
void Update()
{
Vector2 input = inputActions.actionMaps[0].actions[0].ReadValue<Vector2>();
I forgot to hit reply so ping
Sure basically
Would cache the action though
You can also use InputActionReference to make that cleaner
so reading the value like that in update will get the current position of the stick, even if it's not moving?
yes
sweet, thanks.
Hmm, it's just reading zero constantly.
I didn't delete the other actions, will they capture the mouse input and it won't be received by the new one I made? I did drag in the "Look" one to be used by my script.
nope, I deleted the others and it still isn't receiving the input.
Hello there, I'm trying to use the UI toolkit but I can't click on my gameobjects anymore since the ray always hit the PanelSettings. What did I not understood ? any help appreciated 🙂
I have my UIDocument on the UI layer and the raycaster attached to my camera has the "Interacables" event mask, which my gameobject are on
you have to enable the asset
inputActions.Enable();
Eureka! Thanks.
Aaaah nevermind, I just setp the pickmode to ignore on my transparent containers
[Unit Test] I want to simulate keyboard buttons to show alphabet in input field
_input.Press(Keyboard.current.qKey);
InputSystem.Update();
Assert.IsTrue(Keyboard.current.qKey.isPressed);
yield return new WaitForSeconds(3);
_input.Press(Keyboard.current.wKey);
InputSystem.Update();
Assert.IsTrue(Keyboard.current.wKey.isPressed);
yield return new WaitForSeconds(3);
_input.Press(Keyboard.current.eKey);
InputSystem.Update();
Assert.IsTrue(Keyboard.current.eKey.isPressed);
yield return new WaitForSeconds(3);
the asserts returns true but for some reason I didn't see the alphabets in input field. why is that?
pretty sure input fields ignore the input system for typing and read their data from IMGUI's Event system.
Meaning simulating input system keypresses won't do anything for an input field
aww that's too bad. so how am I going to validate if the input field contains alphabet by simulating keypresses of the keyboard buttons?
I'm not really sure but what's the point of this test? Are you testing that input fields work? Leave that up to Unity.
so I have chat system and I need to test if the message sent was correct. and I think I have to type it in input field and then send it
basically I want to validate the instantiated message sent by user. and it requires typing and send so I think I also have to simulate keypresses
I think you're getting too into the weeds of it
i would skip the whole ui/typing part of it
just send a string through your "SendChatMessage" function or whatever
and verify it ends up in the right place
i'm pretty new with unit test in unity. is it can be considered valid without doing the keypresses simulation?
maybe its because i didnt add anything on the collision tile map yet?
don't drag things into the script inspector
drag them into the inspector of the GameObject that you've attached the script to
i.e. your player object
ok.i started from the beginning.created the input actions map again and will apply everything again.everything should work just fine.thanks for answering me
@austere grotto
Has anyone encountered such a problem in Unity "In the Unity editor everything works, but in the build the inputmenager does not work both old and new ?"
i need help because i create game to end university 😦
differences in build vs editor are usually due to either:
- code that depends on a certain order of scripts execution (which is not guaranteed)
- code that depends on framerate or resolution (which can vary)
To diagnose your specific problem you will have to do some debugging
Is it possible to debug the code in build ?
yes
As long as it's a development build you can:
- use Debug.Log
- attach a debugger
Hey. Whats the AZERTY-Version of WASD controls? The same key positions just different keys?
If that's the case, the InputSystems ability to set a key position instead of a key should be enough.
I am trying to make simple twin stick shooter controls in 2D
the gamepad controls work flawlessly
but when i use the keyboard/mouse controls, using WASD or the arrow keys, the movement x/y values randomly reset to 0
the same thing happens to the mouse coords, with the character turning to face the origin of the screen (0,0). i've fixed the turning issue, but not the movement stuttering
the only solution i've heard of so far is to change the Update mode in the input system package to "process events in dynamic update", my project is already set to this however
any tips?
wow i fixed that rather quickly. the problem was that in my input actions script, the WASD/arroy key's action type was set to pass through, i set it to button, the mouse pointer i set to value, everything is working fine now
can someone help me with the failed to resolve project template, Failed to decompress.
Does the new input system have some built in lerping of value from button presses?
no
Hi guys, I've been trying to implement controller/mouse rotation on my playersprite for a while and I've finally done it. Now im just running into the problem, that when i let go of the controller stick, the sprite just rotates to a random(?) rotation and i can't figure out why it's doing that... im using Inputactions Here is my Code:
lookDirection = value.Get<Vector2>();
Vector2 objectPosition = (Vector2) Camera.main.WorldToScreenPoint(transform.position);
Vector2 d = (lookDirection - objectPosition).normalized;
rotation(d);
}
void OnRotationC(InputValue value) {
controllerPos = value.Get<Vector2>();
if (controllerPos.x != 0 || controllerPos.y != 0) {
// Debug.Log("x: " + controllerPos.x + " y: " + controllerPos.y);
rotation(controllerPos);
}
}
void rotation(Vector2 d) {
if (d.x != 0 || d.y != 0) {
float angle = Mathf.Atan2(d.y, d.x) * Mathf.Rad2Deg;
// Debug.Log(angle);
transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle-90));
}
}```
is there a easy way to make it so when i press both left and right buttons at the same time, the player moves to left instead of staying still, and the same for upwards and downwards?
That would be something with your player movement script
Ig u could also get player key inputs and then choose what axis to apply force too
So i have to setup each key invidetuality to the key bind window and i cant use the arrow key combination thing?
There's settings on the composite for this
Pretty sure you can do things like "left wins"
it only seems to exist for 1d axis and not vector2
i managed to do it with 2 1dAxis things
Is there any way to convert a single digit int to a key code?
I know that's not how enum's work but there must be some way
KeyCode.Alpha0 + (KeyCode)myInt
If that's what you mean
How do I make an action that is on multiple maps? My use case is this: I have inventory button that opens the inventory, and I'd like the same button to close it too, but since turning on the menu disables the Player action map, it doesn't register the Inventory action anymore. I tried just copying the action to both UI and Player maps, but disabling the Player map for some reason also disables the Inventory action on the UI map:
Just make another action (without copying)
Tried that and all the actions I add to the UI map get disabled when the game starts, ditto for creating a new map altogether
I mean that's clearly not normal
Most likely a bug in your code
Although depending on how you are setting things up, all of the actions are expected to start out disabled
The only actions that start out disabled for me are any I add to UI or another map
Like I said it depends how you're doing things
If you're using the PlayerInput component that's expected
I am, but haven't found a way to enable more than one map
Ok, finally got it working, apparently the maps are under PlayerInput.actions
Hi. Hey. I wanted to program the dualsense gamepad and I can not find property for the arrows on the controller. Most of other keys are there, but those are missing. What is the way to read the input of it? (Using Gamepad.all[0])
Ok, solved. I had to use DualShockGamepad. current
https://pastebin.com/NkksnvbF i have my input actions code set up plus the input actions map set up but my player is not moving and the action map is attached to him
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.
i did animations with transitions but not in code.could it be thats why the wasd keys and arrow keys are not working?
Hey so i have a simple 2d character controller that i got off a video no youtube, the thing is it uses the old input system, what are the things I would have to change exactly for it to work with the new input system??
thanks! ill check it out
how can i get the default keyboard repeat on a keyboard binding for an action? i am fixing tmp input field / input field to use input actions instead of IMGUI events even when in input system is the only backend selected, and i would like a way to elegantly bind to the various input field keyboard control actions. my obstacle is that holding left arrow, for example, does not cause performed to be called as the left arrow repeats on the keyboard
There's a default repeat interaction?
okay let me restate this
let's say i have an action that looks like this
it's a pass through key control binding
now, let's say i press and hold left arrow
i observe this action will only be performed twice: once when it is pressed (key down) and again when it is released (key up), with wasPressedThisFrame wasReleasedThisFrame along with times
i expect that the keyboard action will be performed many times: once when it is pressed, again after the short delay until repeating according to the system keyboard repeat delay, and then as frequently as the keyboard is configured to send inputs on repeat according to system repeat rate (i.e. frequency), and then once when the key is released
is there a way to configure the action to get the behavior i expect?
i tried googling and there's just so much noise
it's impossible to find a straight answer
So you want to have the key keep performing the interaction when held?
With some kind of repeat interval
i would want it to use the system repeat behavior, which it does correctly for text and not for things like arrow keys
but beggars can't be choosers huh
yes i would like it to keep performing the action when held with some kind of repeat interval
but i think i can achieve that using unirx
i can fake the repeat... i'm wondering if there's a way to do this correctly
If you want to do it with the input system you can write a custom interaction
looking at the input debugger it doesn't send repeating events for non-text keys
hmm but they're not stateful right?
interactions
i mean is this stateful? i guess not
i can use the start time
but i don't get multiple events
so i don't think it will work
i don't think i can achieve this with custom interactions because looking at the input debugger, pressing and holding the arrow key only generates 1 event. releasing it generates the second event. the interactor / processor / etc. cannot generate synthetic events afaik
they cannot "select many" on events
Are you sure they can't be? Pretty sure I have a few that store state, I might not be using that across multiple inputs though, not 100% sure
I wrote a repeat interaction ages ago, and that seems to work with the arrow key as well from testing just now
But you are right, it doesn't send repeat events in the input debugger for the arrow keys
do modifier bindings work in 1.4.4?
they look like they're broken
the modifier is ignored
You mean like shift + L or something?
yes
in this case, ctrl+A
on a mac
which is command a
pressing just A causes the action to be performed
Hmm, seems to work for me
this only triggers on shift + L, not on L for me
what version of input system are you using?
1.4.4
i'm not holding control... this is a nightmare*
That doesn't look like your action though? Or is this just formatted weirdly
what do you mean it doesn't look like my action?
Is OnNext not the action name?
maybe if you did the action reference.action.performed += it will also come up for you
I'm hooking up my listener to performed
Is your action marked as PassThrough? Because that will basically ignore everything
It needs to be Button for the binding to work
PassThrough will just pass the state of all registered inputs to the event
the composite?
So it would trigger on both a ctrl or an a press
Only the action should have the InputActionType field
Button and Value both run the input through the processing chain, PassThrough ignores it
I'm actually not sure what the difference is, I had it set to One Modifier
well
actually it may have just broke it standby
no just breaks it
i think this is a mac bug
some options make A always trigger Ctrl+A
other options make the action never performed
regardless of whether i use Command or Ctrl
For example?
it's a clusterfuck
left system is display name for left meta and left command is left meta
One Modifier, modifier left meta, action type passthrough, control type key: "a" fires when left meta not pressed
Button Modifier, modifier left meta, action type passthrough, control type key: "a" fires when left meta not pressed
Button Modifier, modifier left meta, action type button: never fires (meta+a and a and meta do not fire)
One Modifier, modifier left meta, action type button: never fires (meta+a and a and meta do not fire)
One Modifier, modifier left meta, action type value, control type key: never fires (meta+a and a and meta do not fire)
@vocal jay
i'm going to try restarting unity
okay
@vocal jay i resolved the issue
What was it?
apparently the left command key on macOS is actually right system
i clicked through Listen
man. "build the cube."
the correct choice is One Modifier, modifier right system, action type button
every time i run into an excruciating unity bug, should i send them a postcard with a picture of the cube in central park with the contents "build the cube"?
do you think they'd get it @vocal jay ?
lol. what if the cube had the unity logo on it
would they get it
it would be like the unity cube, but meat colored
Does it at least get the correct key if you hit listen to bind it in the input action asset?
no, that's how i found out it was right system
i hit left command, it gives me right system
Ah yeah, that's what I meant, by it "binding" correctly
lol
So the naming is just off
Yeah usually it works pretty well, odd that it is "right system"
it did indeed bind and finally work
i think because it's an external windows keyboard.
like a gaming keyboard
ironic
an even more surprising detail... onTextInput repeats for some text keys, and not others
The repeating should only matter if the key is set to PassThrough, if you want to "simulate" repeating keys you should be able to do it with an interaction
I can send you my repeat key interaction if you like, I wrote it ages ago so no idea if it's still the "correct" way to do it
I tested it earlier though and it still seemed to work
for example e does
i got the simulated part working
e isn't bound to any actions afaik
i'm talking about only in InputSystem.onTextInput +=
on macos
bizarre!
i and l do
why why why why
Ah yeah, that basically circumvents the input system
@sharp geode I'm guessing the keys that are bound to an action don't work?
that was my guess to but it doesn't seem related
it's random
input consumption?
input system is giving me consumption
so what is this
uh
yeah
it breaks the working bindings o..
i nixed that
the appmana virtual keyboard repeats, whereas the macos native keyboard only repeats on some text letters
Hmm, not sure then why InputSystem.onTextInput doesn't work for you...
probably IMGUI Event repeats correctly
for all characters
i'm not sure iether
i'm sure if i didn't enable any of htese actions nothing would change
Is only the repeating part broken?
yes
and if i don't enable the actions nothing changes
i think it might be a real bug
You could try with a custom interaction on a binding that actuates on <Keyboard/Any>
yeah but i need the event for the character
i might listen for every event
and recreate onTextInput and see what happens
I guess you could also add all letters to the binding 😅
That sounds like a UI question, not an input system question
Hi guys, I've been trying to implement controller/mouse rotation on my playersprite for a while and I've finally done it. Now im just running into the problem, that when i let go of the controller stick, the sprite just rotates to a random(?) rotation and i can't figure out why it's doing that... im using Inputactions Here is my Code:
void OnRotationK(InputValue value) {
lookDirection = value.Get<Vector2>();
Vector2 objectPosition = (Vector2) Camera.main.WorldToScreenPoint(transform.position);
Vector2 d = (lookDirection - objectPosition).normalized;
rotation(d);
}
//rotation on controller
void OnRotationC(InputValue value) {
controllerPos = value.Get<Vector2>();
if (controllerPos.x != 0 || controllerPos.y != 0) {
// Debug.Log("x: " + controllerPos.x + " y: " + controllerPos.y);
rotation(controllerPos);
}
}
void rotation(Vector2 d) {
if (d.x != 0 || d.y != 0) {
float angle = Mathf.Atan2(d.y, d.x) * Mathf.Rad2Deg;
// Debug.Log(angle);
transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle-90));
}
}```
Do you have a deadzone set for your input?
Oh that makes sense. Set it to 0.01 now. I am seeing alot less of the issue. Perhaps it disappears completely after i set the deadzone higher?
Yes, it should be higher. I would just use the default values
Wait is there a option for it in the input manager? i've been hardcoding it like this until now:
if (d.x > 0.1 || d.y > 0.1 && d.x < -0.1 || d.y < -0.1)
Yes, it's an input processor
oh well that makes things easier xD
Ideally if you are using the input system you shouldn't be doing any input processing in your code
(unless that code is an interaction, processor, or modifier)
you can see my attempt at wiring up input system to a very very slightly modified tmp inputfield https://github.com/AppMana/appmana-unity-plugin/blob/experimental/keyboard-support/AppManaPublic/UI/TMPro/InputSystemTMPInputFieldModule.cs
not sure why unity hasn't done this already
my buttons dont allow me to do anything. the only option i have for pick function is Monoscript
I am an independent game developer creating a game for the PlayStation platform. I am seeking assistance for adding playstation 5 dualsense controller to work with my player!
any help is appreciated!
to make it easier I am using the FPS microgame as a template at the moment
(need reply withtin a few days I dont mind)
how do i fix this error? im using the newer input system with vr controls
@stiff mauvedo u even have ps5 controllers to begin with?
Yes
Assuming coding dualshock 4 support could work as well
.
Should be a float. Axis allows multiple components to be bound to influence the value positive and negative.
button.onClick.AddListener(() => this.PerformRebind(button.gameObject.GetComponent<InputText>()));
When this gets called I get an obejct reference error and I'm not sure how to fix it
I still need help on adding controller support/input to my game
I am using the fps microgame as a template hope that helps
Do all input classes generated by Input System derive from IInputActionCollection2? Can I safely depend on it without one day getting an input class which doesn't derive from it?
In the current versions of the input system package yes
why isnt it not working?
here
using System.Collections.Generic;
using UnityEngine;
public class PlayerControlling : MonoBehaviour
{
PlayerControls controls;
float direction = 0;
public float speed = 3.0f;
public Rigidbody2D playerRB;
private void Awake()
{
controls = new PlayerControls();
controls.Enable();
controls.Land.Move.performed += ctx =>
{
direction = ctx.ReadValue<float>();
};
}
// Update is called once per frame
void Update()
{
playerRB.velocity = new Vector2(direction * speed * Time.deltaTime, playerRB.velocity.y);
}
}
that's the movement script
and this is the input system generated script:
any help please?
here is some extra stuff
What is not working?
when i hit play
the player doesnt move
at all
i assigned path for the + and -
it still doesnt move
hmm?
dont i have it in the update
void Update() { playerRB.velocity = new Vector2(direction * speed * Time.deltaTime, playerRB.velocity.y); }
yeah but "direction" is set only once
how can i fix it?
you need to update it constantly
ohh i see
i have that on awake
set as: direction = ctx.ReadValue<float>();
yeah
yeah
alr let me try
okay so yeah, i still cant move
strange
code:
OP
fixeed it
it was just the speed thingy
i had it on 3 and it was suppose to be at 400
mb
nice then
thanks a lot man
u
do not understand how much i took for this
ty s om uch
even without the direction = controls.Land.Move.ReadValue<float>();
in the update section
it still works, it was all just the speed set at a low rate
nvm, i didn't know you could assign it to a variable, that's nice
how do i fix this?
also i want this to only happen once you enter a trigger collider beside clicking E
does this work?
ok it work
one thing, you can move the "controls.Land.Interact.performed" to awake
i didn't know you could, but it is better there
gotcha
one final thing
why doesnt the animation play when the player clicks on the screen buttons
my game is touch screen
and everything works but the animations
they dont play
left button:
right button:
Why are you mixing up old and new input system code
eh im following a tutorial
I don't understand what the input.keycode bit is supposed to do. Seems completely out of place
It also makes no sense to put it there
Shouldn't you just be checking if direction is positive or negative?
Hey I want to ask if is possible to make Dedicated Server console input reader / handler.
if (direction is postive or negtive)
{
play animation?
}
Thanks, do you know how one can adjust the axis from being -120 and 120 to 1
would that be a magnitude?
Figured it out
so I have playerinput and this little script on same game object:
public void OnClick(InputValue value) {
Debug.Log("********************** Yoooo point");
enabled = false;
}
Idea is that it will run this script once, andafter that disables it self. However this keeps running even if script is disabled, my guess is I failed to unsubscribe it somehow, but not sure how to do it.
Disabling a script simply means Update, FixedUpdate etc won't be called
It doesn't affect anything else really
Talking about input system... how it is with every Unity update Webgl Input system keeps getting problems with focus again and again. It seems they Fix it, but next update comes, and again, WebGL loses Focus and input system forgets to reset input and your character continues walking without any buttons..... I was sure they fixed it. 2022.2.1 -> it is back again. Saw something about it in 2022.2.2... Lets hope that is the fix.
Hi does anyone know how can i get touch input but i dont want ui to register the input.
And also i want add a long jump input by holding the touch screen anyidea
Create two Action maps. One for UI and one for Player.
Or at even check if the coordination of touch is over UI or not.
Is there a method to check if the user is clicking on ui?
I created check like this, it will be different for you I guess:
private int PlayerUILayer_mask ;
private int UILayer_mask;
private void Start(){
PlayerUILayer_mask = LayerMask.NameToLayer("PlayerUIMaskName");
UILayer_mask = LayerMask.NameToLayer("UILayerMaskName");
}
public bool IsOverUI() {
var results = new List<RaycastResult>();
EventSystem.current.RaycastAll(ScreenPosToPointerData(point), results);
if (results.Count > 0) {
var layer = results.First().gameObject.layer;
if (layer == PlayerUILayer_mask || layer == UILayer_mask ) {
isOverUI = false;
return isOverUI;
} else {
isOverUI = true;
return isOverUI;
}
}
}
And I call this if (IsOverUI) DoStuff or dont do stuff on every click. This is one of methods, it depends on your project. This is most primitive, as more advanced methods did not work in my scenario.
Here there is assumption that your UI is put on different layer.
have in mind this is just one of many methods.
Pretty long code for a very simple task previously i used event triggers.
yes it is, but I needed it to work on multiple types of UI, and when I am using Ui toolkit and legacy UI, normal methods did not work 😄
I hope someone else will give you better answer, but at least u will have back up plan
hi guys i have been traumatized by the new unity input system code can anyone send me a ref code so i cn understand it
I can
@tropic tulip i can also suggest to you to read the manual on the input system on the unity website till you understand it.going by a certain code is just an example but it doesnt teach you the system in a full way.it just shows you one way to write and implement your input action map
This might go here so I attempted to have selectable ui using arrowkeys but it doesn't work, first selected doesn't work for my ui eventsystem, any clue why?
This helped me to understand Player controller, UI controller is bit more simple. This uses SendMessages and is very convenient. Tho UnityEvents in my opinion is easier to understand instead of SendMessages. But in general for controller it is good approach as you can do fancy stuff while intercepting the controller data and adjusting it if needed rather than getting just inputs.
What do you mean first selected? Does it trigger any events? Like hover and click? Do you have event listener and converted it to new input system listener? Are you using UI toolkit or Legacy UI?
wtf?
If you reference an instance of the generated input actions, you can subscribe to any of the inputs you put in there
Little late mb, Ill provide the YouTube video im referencing
https://youtu.be/8mFWJwxV3ps
And yes im using Legacy UI
Hi, I wonder if anyone already discussed about rebind a key and check if the key is already used?
on discord top right there is search button, you can make sure to search in this thread and just search for rebind. in:input-system rebind threre is 193 results talking about it. sorry I havent done it my self, but it seems there some forums links there as well.
emmm, are you sure it is not working?
First make sure colour does change depending on button
Ill check