#🖱️┃input-system
1 messages · Page 30 of 1
I think I'm finding out my big weakness here is not knowing enough C#/Unity C# scripting. Expecially not know much of how to apply physics to gameobjects is also slowing the learning down. Anyone recommend a good course that covers these concepts?
see resources in #💻┃code-beginner for c#
Thank you, I think I should also stop being so gung ho on always trying to use the new input system😂
There any significant overhead associated with having additional control schemes active? I'm probably overthinking it but I have a context menu system that I want to close if the player clicks at all, either on other parts of the UI or on objects in the world, and I figured the easiest way to do that would just be tacking on another control scheme that just listens for mouse events and closes the active context menu.
The way I usually do this is a large invisible UI element covering the whole screen in a Screen Space Camera canvas with a plane distance of 1000 and IPointerClickHandler
Might as well ask how to build a car from scratch.
- Pick a network framework
- Go through their getting started tutorials to learn the basics
- Apply those learnings to your game, being ready for a lot of trial and error
Is it possible to use XInputController with an ESP32 ?
No
Multiplayer easy I just dont know how in unity
This is how:
#🖱️┃input-system message
Also it has nothing to do with the input system
Check Unity Multiplayer doc (i think there is one)
that may actually be better considering how my code is currently set up, falls way more in line with what I'm already doing. thanks
i have input handler script,
and button.
when i hold the button, attackInput bool is true while i hold,
but i need when hold button, variable will be true for once...
i dont know how to use new input action maps...
i need GetKeyDown but on new input system...
so you're using sendmessages with a button type action
OnAttack will only be called when you press the button, you won't have anything to inform when the button is released
so you can do one of the following options:
- react immediately in
OnAttack - set a bool in
OnAttack, and then consume that bool (and reset it) later in some other method - set an interaction to have both press and release send messages, then check
isPressedinOnAttack- but this doesn't really make sense given that you've said you only want to check when it's pressed
the issue isn't really in the input system, you've just set a state even though you didn't need to
i doesnt have OnAttack
private void RegisterInputActions()
{
moveAction.performed += context => moveInput = context.ReadValue<Vector2>();
moveAction.canceled += context => moveInput = Vector2.zero;
lookAction.performed += context => lookInput = context.ReadValue<Vector2>();
lookAction.canceled += context => lookInput = Vector2.zero;
attackAction.performed += context => attackInput = true;
attackAction.canceled += context => attackInput = false;
}
why do you have a playerinput then lol
if you're using the actions directly then you don't need the playerinput
uh...
lol
welp same answer really, just replace OnAttack with attackAction.performed
private void RegisterInputActions()
{
moveAction.performed += context => moveInput = context.ReadValue<Vector2>();
moveAction.canceled += context => moveInput = Vector2.zero;
lookAction.performed += context => lookInput = context.ReadValue<Vector2>();
lookAction.canceled += context => lookInput = Vector2.zero;
attackAction.performed += context => attackInput = true;
attackAction.canceled += context => Invoke("AttackTap", 0.1f);
}
private void AttackTap()
{
attackInput = false;
}
like this?
no, not at all
yes, i mentioned it
how does this fit into any of the options i mentioned lol
maybe i shoudl use coroutine?
no, that's pretty unnecessary
i already gave you options
why are you ignoring them lol
set a bool in OnAttack, and then consume that bool (and reset it) later in some other method
that's not "consuming" the buffered input though
private void RegisterInputActions()
{
moveAction.performed += context => moveInput = context.ReadValue<Vector2>();
moveAction.canceled += context => moveInput = Vector2.zero;
lookAction.performed += context => lookInput = context.ReadValue<Vector2>();
lookAction.canceled += context => lookInput = Vector2.zero;
attackAction.performed += context => StartCoroutine(AttackTap());
}
private IEnumerator AttackTap()
{
attackInput = true;
yield return new WaitForSeconds(0.05f);
attackInput = false;
}
i coded this, and this is will not be work...
what i'm referring to is something like this:
bool shouldAttack;
attackAction.performed += () => shouldAttack = true;
void Update() {
if (shouldAttack) {
// do actual attacking
shouldAttack = false;
}
}
yeah this just.. doesn't make sense at all
uh ...
you're really overcomplicating it
i dont using update...
ok, how do you plan to attack?
as in, where are you going to do the actual attack logic
on key down, player will attack
where do you want to put that logic
Melee script
and you already have a method to call for that?
then just call the method directly
attackAction.performed += () => melee.Attack();
private void Inputs()
{
_moveInput = ih.moveInput;
_lookInput = ih.lookInput;
_attack = ih.attackInput;
}
its just copy inputs from Handler and just use this
oh
and you call this each frame?
yes...
i dont know how to use this input action maps...
my code is terrible because of that
you don't need a variable to do that then
and tutorials doesnt helps
you can just grab WasPressedThisFrame() or one of the other methods
just a public bool attackInput => attackAction.WasPressedThisFrame();
ok, something like this?
sure
though theoretically i guess you could have moveInput and lookInput be properties too
that's up to you if you want it though
and i have other problem, but not with the input system
you don't have to tell me that, just ask (but in the appropriate channel for the question)
yes, but i wanna go to the #💻┃code-beginner
again, you don't have to tell me that
just go ask
i'm not your personal assisstant lmao
ok
Hey, would this be the appropriate place to ask for help with a problem Im having relating to buttons?
well if you aren't sure, go ahead and ask
you'll be redirected if it doesn't fit
So, Im attempting to add an event listener to the button so that when the button is clicked it does something. I've successfully managed to attached the event listener to the button. I already debugged this to verify that it works and does what I intend it to. However depending where this button is in the hierarchy it does and does not work which is the problem im having. I added a test button inside InventoryUI to test that button clicks register and it does however when I move it inside item panel or anywhere further in the hierarchy it stops working. I've read that it has to do with canvas and graphic raycaster but I tried messing around with that and nothing I changed works. I tried removing the canvas and raycaster on the children but that didnt' work because I read that it causes it to conflict with the parent canvas so clicks arent registered
Im trying to make the buttons interactable at the RowItem SellButton level (these are the buttons I want to work) which they do if I raise them higher in the hierarchy but not at their currently level
uhh you sure this is about #🖱️┃input-system?
uh well let's start with that, are you using the input system
Most likely you have some other #📲┃ui-ux element blocking it.
Hello, I'm currently having trouble with my Unity input System button input as the system is just stuck on one button and doesn't change with arrow keys. The visualized system shows the correct system, but my game doesn't seem to follow it when running.
Here is my event system parameters and: visaulized path
This is a #📲┃ui-ux question
Ok, thanks for info
im having a hard time making a touch input action that correctly calls performed when i press on screen, and canceled when release AND give the touch position
to get the correct performed/canceled callbacks i need to set the input action type to Button action type, to get position i need to set it to value
i tried making 2 input actions, one of type button and the other one of type value, but whatever order i set in the mapping context or in the callback registration the button is always called before the value so i cannot cache properly the touch position
For convenient touch input handling you typically need to make a wrapper on top of input system. Many just use (has a free version) https://assetstore.unity.com/packages/tools/input-management/fingers-touch-gestures-for-unity-41076?srsltid=AfmBOoqACdWSq7WirJz13arvnqzk8hfI049QSuGwe2TlWwSEEKjY9aZc
i got mostly what i wanted using one input action, but for some reason the "Press" interaction modifier doesnt cancel on release, and to perform it again i have to focus another window and click back
eh, another common thing that unity doesnt handle by itself 🥳
thanks for the link tho
Touch for games is not easily standardized, and unity focuses only on those things that are. Fingers is pretty much iOS way of handling touch
You're meant to make two separate actions for this
There's also no good reason to use the press interaction in this circumstance.
Anyway if you want more fluent touch handling look into the Enhanced Touch API
hi someone can help me? aftter format of my pc i add project to my unity, project what i had saved in my dysk. And everyting work but i dont have a hints in visul studio code, for examle when im writing getc i dont get a hint to write getcomponent. WHY?
don't crosspost
Hey! I am trying to use New Input sytem's Rebind Action UI Prefab to rebind UI. But it's not working. So, I am trying to rebind jump and what happens is, nothing changes. But when I stop the run and play again, it rebinds to that key I pressed earlier. In addition to that, the text stays the change (Spacebar) no matter what key it is rebinded to.
Hi, I'm trying to disable a specific action map so the player can't look around when another action map is pressed. I'm just using a reference to the specific input map actions with InputActionReference and calling:
referenceAction.action.Disable();
Before this was the way to do it, I looked into the docs and it hasn't really change but for some reason it doesn't work anymore. I'm using Unity 6.0.5 with the new input system.
Nothing has changed with the API but you're only disabling a single action there not a whole map
Yes, as I would only like to disable that input
given the very limited information you have shared here, it should be fine. If it's not working then something else is at play. For example perhaps you're dealing with more than one instance of the input action. in which case, disabling one instance would not affect any other instances.
You would need to share more context if you want more help than that.
As I'm instantiating the player, the Input Asset get instantiated as well, but I only have 1 Input Asset.
It's that what you mean?
ok you're using the PlayerInput component
that's a totally different thing
your other code is disasbling an action on the input action asset itself
PlayerInput creates its own instance
you would need to do like myPlayerInputComponent.actions["MyMap/MyAction"].Disable(); to disable the one the PlayerInput component is using.
Ooh alright, thank you, I'll try this
Hey y'all, I'm having a weird issue with my game lagging from analog input? After the game has been running for a while when you move the analog stick the game starts lagging real bad (and the faster you mash directions the more it lags), but this doesn't happen with the dpad at all (at least it's never been reported)
I can get some screenshots of how I have the input setup and how it's generally used in code
If you're having framerate issues the way to diagnose is via the profiler
I'll try that, it just takes so long for the lag to show up before I can start diagnosing
Here's how I added them into the input system
And this is an example of how I read the inputs, just wanted to know if any of this is like, obviously wrong
I'll start trying to profile as well
you should probably just let deadzones govern that
no, this code itself is not going to cause any performance issues on its own
and you should probably cache the value that you read
Yeah the code is from before I was using the deadzone system from the input stuff, so it's kinda redundant
Okay so it looks like there might be something else going on, I'll get to profiling
Hello I have an issue regarding the input system. I thought the issue at first was me using the new input system, i eventually switched to version 2022.3.5.1f1. Somehow the inputs for horizontal axis is working (aka A/D and left arrow keys) but q doesnt work (i'm doin visual scripting so its the input get key down Q) I'm not sure how to make the input work.
you'd have to show how you set everything up
and how you determined it's "not working"
You have to go in project settings, in input system - and manually add Q as an action (entry key). So it shows up in the editor.
In uVS - for example, when you add a node (unit) >> input >> button... You can select that action if its added.
If its not - it wont show up.
Q is not added by default.
Hi yall, got a problem here. I was using the new input system with WASD input. Using the same setup and same version from my other games, they worked well, but this time it just don't work for some reasons. Checked the references are correct. Doing everything the copilot asked me to debug it seemed alright, but my perform doesn't trigger functions
public class BodyController : MonoBehaviour {
[SerializeField] private InputActionAsset inputActionAsset;
[SerializeField] private InputAction moveAction;
// [SerializeField] private InputAction confirmAction;
private Vector2 moveInput;
[SerializeField] private float moveSpeed;
private void Awake() {
inputActionAsset = GetComponent<PlayerInput>().actions;
Debug.Log(inputActionAsset);
InputActionMap actionMap = inputActionAsset.FindActionMap("Move", true);
actionMap.Enable();
Debug.Log(actionMap.enabled);
moveAction = actionMap.FindAction("WASD", true);
Debug.Log(moveAction.enabled);
}
private void OnEnable() {
moveAction.Enable();
moveAction.performed += OnMovePerformed;
moveAction.canceled += OnMoveCanceled;
}
private void OnDisable() {
moveAction.Disable();
}
private void OnMovePerformed(InputAction.CallbackContext context) {
// Update the move input when the action is performed
moveInput = context.ReadValue<Vector2>();
Debug.Log($"Move performed {moveInput}");
}
private void OnMoveCanceled(InputAction.CallbackContext context) {
// Reset the move input when the action is canceled
moveInput = Vector2.zero;
}
private void OnConfirmPerformed(InputAction.CallbackContext context) {
Debug.Log("Confirm");
}
private void Update() {
Vector3 movement = (transform.forward * moveInput.y + transform.right * moveInput.x) * moveSpeed * Time.deltaTime;
transform.Translate(movement);
}
}```
and here is the inspector screen shot during run time, it has no response when I press keys
If anyone can help, thanks
If you're using InputActionAssets, I would recommend using InputActionReference instead of InputAction - it will allow you to reference a particular action without needing to search for it by string. It will reduce the odds that you'll make a typo in the map/action name.
Other than that, I would suggest double-checking if your InputActionAsset is properly configured. Make sure that proper keys are assigned. You can also try the input debugger to see if Unity even receives these inputs.
Why do you have a, true in your moveAction variable?
moveAction = actionMap.FindAction("WASD", true);
Here is my playeraction script if you need a reference. I do a WASD action as well but mine is called Move instead:
https://gist.github.com/NullSimLabs/a054fc38f3780c23c485e46f823cdd24
I've tried with or without it doesn't matter. The true is that it throws an exception if the fetch fails and it never failed which is weird
Good point, I'll try InputActionReference out. I was doing the set up as usual, I even reference back to my old project make sure every thing is same but it didn't work out.
Or anyone had worked with OpenSeeFace? I'm building the controller with this library. Used copilot to check if anything will clash, but it seems that it doesn't intervene with input controls
how did you configure the Move/WASD action?
Also those things are named very oddly. It seems like you have the wrong level of abstraction there. An action map should be something like "PlayerCOntrols" and an action should be like "Move"
the binding would be WASD
my configuration is set up like this. Yea, not a good name to start with.
OK problem fixed, I guess the solve is just revert the whole project to my last patch. Thanks for the insight!!
Hello! I just changed to the new input system and its looking great but I am having trouble getting UI Submit to work.
So far I took the following steps :
- I updated the EventSystem on the scene
- double checked that submit is assigned to UI/Submit
- Created a scheme with an action map named UI and a action Submit
- Created a Controller Manager to deal with actionmaps changes, etc (it works ok on every other aspect than UI)
- Created the Settings Asset on Edit - Project Settings - Input System Package (couldn't find anything to change here)
Now on my game I have dialogue choices that are buttons, with a on click listener that trigger the dialogue selection, and I can't get those button to react to the assigned key to UI/submit. They still work with mouse click and the navigation is working fine (when I press the key I added a log to confirm what is currently selected by the EventSystem).
Oddly they work correctly with a gamepad south button, even though I haven't assigned that under UI - Submit
Thanks
Nevermind guys... I fixed (most of it at least).. I was forgetting this reference.
Hello ! I have a big problem with unity's input system.
It doesn't register when any of the joysticks is pushed toward topLeft (northWest).
I only have this problem with the Official Nintendo Switch Controller for now... (the controller's input work on every other game).
Here's some screenshot for proof that the problem is real :
(I tried to mess with the deadzones in the project settings but the same things happened regardless...)
Maybe check what the input debugger says to make sure it’s not the custom code that causes the error.
thanks for replying
I never knew the input debugger was things. and it does show that the input work, but then why does it return 0 when I use it ?
it can't be my custom code.. as cinemachine itself have the same problem picking up the right stick's value in their own "Cinemachine Input Axis Controller" component, where I just passed the "Input Action" as argument
can you show the configuration of your input action in question?
the input action asset ?
I tried to change the "Control Type" to : Analog, Stick or Axis. but they still don't fix it..
if the debugger shows it correctly, then you're likely seeing a deadzone or other config error that affects the action. Vector2 is the correct type and i'd assume you arent processing it. Maybe the generated class does something weird or your global settings are interfering.
I have not touched the global settings.. and even when grabbing the inputAction itself, so wihout the generated class. it doesn't pick it
i'm sorry, i don't have any more ideas what to check.
What happened to my characters face?
Dunno but I doubt it's related to the Input System
Yeah I mean to do a help channel
whoops
i'm trying to detect any key being pressed and then getting what key was pressed. i currently have a setup like this in my input actions. i don't really know how to use the new input system in code so i have no idea how to get the actual key from this
What's the end goal of this
getting the pressed key and checking if its in a list
aka if its a letter and not a random character
A slightly easier way would be to use
where would i start with implementing this?
as in where do i use onTextInput (i am really absurdly bad at reading documentation)
oh wait i think i found it lemme see
The docs I linked have example code
i was misreading it really bad :P
Hey, do you have any clue how to do it better without losing the input map benefits?
In old systems I used GetKeyDown(KeyCode.Alpha1 + i), but that's obviously not the play here
this is the best way
Mostly because this way makes it much simpler than any other way to handle rebinding etc
You can still put them in an array inside your code etc.
so you can do itemAction[i].WasPressedThisFrame() or whatever you need
Damn, kinda hoped they would be some clever way to assign such "linear sequences"
I need to later look how games do rebinding for such things
yeah, like i said, there is
you just put the actions in an array in your code
But I get what you mean
Oh yeah, I will for sure do that. Having them all separate all over the code would be awful
OnMove calls just fine
OnLook created the same way does not
Both are properly assigned in my gameobject
any ideas?
define "does not work"
have you debugged to see if the method is called, and what value it's called with?
Yes
The method is not called
public void OnLook(InputAction.CallbackContext context)
{
UnityEngine.Debug.Log("OnLook called");
lookInput = context.ReadValue<Vector2>();
}```
have you tried the input debugger, to make the input system is picking up the input?
I may be reading the debugger wrong but it doesn't show anything for wasd either
Is it supposed to light up or something?
OH I see. Mouse calls
Yes, the mouse is
Onlook value.. vector 2.. <Mouse>/delta
what control type have you set OnLook to?
Vector 2
shouldn't it be Delta?
uhhh perhaps but its not calling the debug log regardless
ill try setting it to delta
no log still
so confused lol
-# man what do those control types even do
when i select LISTEN and move my mouse it doesn't pick it up, not sure if that relates
i had just manually selected mouse delta
Is there a cool way to detect left/right swipes on a given object? Or do I have to just get a raw touch and figure everything out myself
I need a bool, if a swipe is done or not
he looks like "Mike Junior"
Reposting, since it remains unanswered;
Having some issues with Proton on Steam Deck. A user is reporting that an action I mapped to "button south", is mapped to the B key, which should be east.
No idea if other keys are off too, but everything is mapped to be generic and works properly on Playstation and Xbox gamepads.
Unity 6000.0.47f1 and input system 1.14.
there seem to be a bunch of steamdeck-specific control issues with the new input system... Reported for a year or two now
your best bet, is submit a bug to unity about it
Hmm, yeah. Haven’t had great experience with that unless I told them the exact line of code that needed fixing 😅
But thanks.
Hello, I am looking for a template for an open world game with a car ride and arrival system.
It is free
Hi everyone, I'm having trouble getting my keypad UI to work properly in Unity. I have a Canvas prefab with buttons (0-9, *, #) that represent a keypad. The buttons are set up with OnClick() events that call a method KeypadUI.PressNumber(string num) and pass the correct string (like "1", "2", etc.). The KeypadUI script updates a TMP_Text field to show the pressed numbers. The prefab is located in the Resources folder and instantiated through a script attached to the player when I press "E" and look at a keypad object. The UI appears correctly when instantiated — I can see the keypad and buttons — but when I click the buttons, nothing happens: the PressNumber() function is not called, no logs appear in the Console, and the TMP_Text is not updated. I've double-checked that all buttons have the correct OnClick() references and they have it. Can someone help me pls?
Show screenshots and code of how it's set up
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
KeypadInteraction script: https://paste.mod.gg/tyyjpcyymikq/0
keypadUI script: https://paste.mod.gg/kzyastudiqmc/0
A tool for sharing your source code with the world!
A tool for sharing your source code with the world!
You're trying to do a physics Raycast to interact with UI components. That doesn't make sense
I'm using the Physics.Raycast only to interact with the 3D keypad model in the game world (to open the UI panel). I'm not trying to use it for the UI buttons themselves. The UI shows up correctly, but when I click the buttons (like 1, 2, 3), nothing happens — the PressNumber() method in the KeypadUI script isn't getting called. All buttons have the correct OnClick() assignment in the Inspector.
What kind of game is this
Is it a first person game?
Is your cursor locked/hidden?
Do you have an event system in the scene with an appropriate input module?
good evening!
in the script bellow, before changing the input system, it only acted during the one frame that it was pressed
void Start()
{
...
fsm.AddTransition(
State.Movement,
State.GroundPound,
t =>
!groundDetection.GetGrounded()
&& Time.realtimeSinceStartupAsDouble - lastGroundPoundTime
> groundPoundStateData.Cooldown
&& DownButtonIsPressed ---> here i used the old input system where it only returned true for a frame
);
fsm.AddTransition(State.GroundPound, State.Movement, t => groundDetection.GetGrounded());
fsm.AddTriggerTransitionFromAny(
Transition.Any2Free,
new Transition<State>(State.Dummy, State.Free)
);
fsm.AddTransition(new TransitionAfter<State>(State.Free, State.Movement, 0.5f));
fsm.AddTransition(
State.Movement,
State.Slide,
t =>
groundDetection.GetGrounded()
&& Time.realtimeSinceStartupAsDouble - lastSlideTime > slideStatedata.SlideCooldown
&& DownButtonIsPressed ---> here i used the old input system where it only returned true for a frame
&& m_moveDirection.x != 0f
);
void OnDownAction(InputValue value)
{
DownButtonIsPressed = value.isPressed;
Debug.Log("down " + value.isPressed);
}
now the actions linger for a second or when using the press and release interaction
and when using tap it only returns false
i needed to imitate the old behavior system where the getkeydown returned true for a frame
the behavior should be something like:
player presses (downbutton) and it dashes/ground pounds depending on the context
in order for it to do another one of those actions the player needs to release the button and press it again
This is really hard to say without knowing how you're processing input. The new system can be used in many different ways. You almost certainly don't want the Press and Release interaction
The code snippets you're sharing are too small to understand the full context here
Idk what the scope of these variables are or where these functions get called etc
ah sure
I'm also about to board a flight so I likely don't have time to look at more code at the moment
InputAction.WasPressedThisFrame() is largely equivalent to GetKeyDown
Or GetButtonDown
I would consider using that
(assuming you are using the default interaction
oh, there is something like that
i belive i am using the most basic implementation of having a player input in the game object and using the message system
Sure but that will be a drastically different workflow than using GetKeyDown so you'll need to adjust things
hmmm, any other implementation you would recomend over that one
when i started i watched about 5 videos and each of them had diferent implementations
in order to use this one the default message system wouldn't help i suppose, so i would have to make a reference to the player input in my script and get the InputAction.WasPressedThisFrame() from it right?
or rather a reference to
Yes, it's a first-person game. The cursor is normally locked and hidden during gameplay, but when I interact with the 3D keypad (using a raycast and pressing E), I unlock and show the cursor. At that point, the UI canvas becomes visible.
I do have an EventSystem in the scene, and the Canvas has a Graphic Raycaster. All buttons are interactable and have OnClick() methods assigned to call PressNumber(string num). However, clicking the buttons doesn't trigger the method.
is AndroidJoystick a composite?
uhmmm.... what??
in the input actions editor, select the Stick [AndroidJoystick] binding and show the right side
if it shows "show derived bindings" expand that first
you've set On-Screen Stick to be hooked up to Left Stick [Gamepad], that's not the same as Stick [AndroidJoystick]
did it not work or what
Nope
you said you changed it and then didn't say anything else
can you show the current joystick setup
can you show the inspector of the event system
well that seems correct...
i am using space to jump
and i have another space binding with one modifier being down to ledge drop
any way to make so that you ignore the jump command?
can someone help me with this one please?
If you are using Input System version 1.4.0 or higher, it works this way by default.
But if you're in version 1.4.4 or higher, you need to opt into it
The InputActions consume their inputs behaviour for shortcut support introduced in v1.4 is opt-in now and can be enabled via the project settings (case ISXB-254)).
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.4/changelog/CHANGELOG.html#144---2022-11-01
if you're in a version lower than 1.4.0, you will need to handle it yourself with two separate bindings.
show a screenshot of the inspector of one of the buttons OnClick events in play mode
also, it would probably be better to have a script for the keyPad buttons directly. And why are you setting the button onClick events in a script and not in the inspector directly?
@glass plaza
@glass plaza
I don't see a Button component in your screenshot
Button[] buttons = keypadUI.GetComponentsInChildren<Button>();```
this probably doesn't find any buttons because it will only get active components by default. You need to pass 'true' as parameter.
make another one in play mode (of the instantiated instance) to see if the button has any onClick events.
thanks so much!
i was sick so i didnt work in the project untilnow
i will check it out asap
ive encountered an issue with auto navigation occasionally where if i press down, nothing happens. it should always go to the "Return to Main Menu" button at the bottom left. i would say 95% of the time it works as expected.
im pretty new to setting up gamepad controls so i dont really know how to diagnose whats causing it to not work as expected. left/right will switch between the items just fine when this issue pops up, it's just the down portion not working right. what steps should i take to fix this?
i would use explicit navigation but it can vary which items the player has acquired so im not sure how to go to the right button in that case. like in the screenshot provided there is a gap because two items are missing
Isn't this a #📲┃ui-ux issue not an input system issue?
When you click on any selectable component in the UI there should be a Visualize button at the bottom of the Navigation settings that will let you see where each object will let you navigate to
Has anyone else had this issue with ps4 controllers?
It's constantly running an event every frame and I can't figure out what it is
Working fine for me with the latest version in Unity 6
I remember having issues with the DS4 in the past but now it just works
Is is possible to add a deadzone to a touch/pointer input so that small changes don’t cause an input?
can you be more specific about what you mean by "touch/pointer input"?
Are we talking about an onscreen stick or something?
i don't understand how a deadzone would factor into that exactly/ Maybe if you explain the actual gameplay mechanic or interaction you're trying to design?
basically i dont want to receive the callback unless the finger moves a minimum distance
if i drag from to the right and the delta is less than N, ignore the input
(without recording the inputs manually)
which callback
the one that sends CallbackContext
dragging is not really something to do with the input system directly
it's an abstraction you're putting on top of the input system
you will need to calculate it yourself
if (distanceFromOriginalDragPoint < someThreshold) return;
for example
the input system is just giving you stuff like pointer position
it doesn't know about dragging
yes that tells you the delta from the previous frame
not really directly useful for a deadzone thing
and maybe using something like this https://docs.unity3d.com/Packages/com.unity.inputsystem@1.14/manual/Processors.html#axis-deadzone
you'd have to sum up the delta for a while and then start reacting once the magnitude goes over a certain amount, i guess?
so i still need to do it manually in the end
thought the new system can just do it out of the box
considering there is deadzone support in sticks
yes but a stick and pointer position are completely different conceptually
You could do this with an invisible onscreen stick probably
what im trying to fix is pressing on the screen and wiggling your finger back and forth without moving where you touched
aka fat fingering
if i press and hold a finger and tilt it left and right the reported input should stay the same
if you've bound an input action to pointer position, that's not something the input system is going to do for you
it's just reporting position, the concept of a deadzone in position doesn't make sense
how do you tell unity that i'm rolling and not dragging my finger
doesn't know the difference
there isn't a physical difference
(though tbh i tend to use rolling to get small positioning shifts sometimes lol)
that's what I'm saying
{
// Movement
controls.Player.Move.performed += ctx => moveInput = ctx.ReadValue<Vector2>();
controls.Player.Move.canceled += ctx => moveInput = Vector2.zero;
// Interact (Tap vs Slow Tap)
controls.Player.Interact.performed += ctx =>
{
var duration = ctx.duration;
if (duration < 0.5f)
{
Debug.Log("Tap → Interact()");
interactManager.PerformInteraction();
}
else
{
Debug.Log("Slow Tap → HoldInteract()");
interactManager.PerformHoldInteraction();
}
};
controls.Player.Interact.canceled += ctx =>
{
Debug.Log("Canceled/Released");
interactManager.CancelHoldInteraction(); // optional
};
// Drop
controls.Player.Drop.performed += ctx =>
{
playerInventory.Drop(this.transform.position);
};
}```
can someone help me? im trying to:
execute PerformHoldInteraction(); when its holding, then CancelHoldInteraction(); if its released.
the problem is, PerformHoldInteraction seems only to execute when i release the hold, not when hold itself is executed (ive set it to 0.4s).
this code aims to: PerformHoldInteraction when its being hold, but PerformInteraction when its only a tap
hello i recently made my first game and build it into mobile but im noticing a significant performance issue and input lag any reason why it is happening
please don't crosspost
yes i wasnt getting a reply and there were ppl active on that chat so i posted there
ill keep in mind
does anyone know how to get a vive tracker working in unity?
i tried andrews tutorial but i think somethings missing in that very last bit of his tutorial
ping me if u know how to get them set up
mine show u in analysis just fine when i move them around
how do i check if they current callback context came from a touch screen or mouse click? i need to put additional checks if it's a touch or click but not for keyboard
if (context.control.device is Keyboard)
this seems to work
hi, i was following the beginner coding tutorial on unity learn, but that still uses the old input manager. how different are the two?
Very 🙆
ah damn. guess i'll have to look up a guide for it when im done with the learning path.
as a complete beginner it is kinda silly how i need to reference the input's name and then define what it does in a script rather than letting the engine manage the input. maybe scripts are still needed for things like idk, matching an animation to input like a vehicle's wheels spinning?
How would the engine managing the input help? You still have to act on it, which means you have to poll for what input was made.
Hello ! I found something interesting regarding my problem for using the new Input System with a offical Nintendo Switch controller.
the value returned from the inputSystem was way very off, as pushing the stick not even half to it's fullest would return 1.0f..
Debug.Log("Left Stick Unpro : "+Gamepad.current.leftStick.ReadUnprocessedValue().magnitude);
Debug.Log("Left Stick value : "+Gamepad.current.leftStick.value.magnitude);
and that's actually the controller can return a value greater than 1. even got to 2 when I push the stick in a corner
I tried with a different controller and the unprocessed & processed value where the same...
Is this a known behaviour ? can I fix this ?
edit: rewrote to sound less mean.
this is kind of reinventing the wheel. you can define two actions with different conditions that will trigger distinctly. There's no reason to try to post-process the event via script
how do you have the input action map setup to handle the stick
I have not set any InputActionMap. I am using the Gamepad.current
but with a different controller it does not..
uno momento
so the range of the nintendoswitch controller's stick is more limited than another controller..
yeah theres not a united world council on how to configure controllers. people will make them differently
that's why you dont' generally read raw input
even wihout reading the raw input and even creating a input action map, it does leave a big range of the stick unused.. and it's bugged when pushing the stick to the top left corner.. even Unity's own input debugged agree with me
for this controller, it would seem that it measures input axis-independent, with no pre-normalization coming out of the controller, so you're getting literally just the magnitude of the y component and the magnitude of the summed X-component and Y-component vectors
so you're getting a vector who's magnitude is sqrt(x^2 + y^2)
which means when you push it diagonally it can get to like 1.4 or somethign
so I have to like.. ask the player before starting the game to push their stick in order to determine which code to use ? it feel weird to have 3 different result given by the same controller (the raw input, the inputdebugger, the processed value)..
oh and thanks for explaining why it happen 
nah you just can't rely on raw values like that
I wish but the processed value is just cutting a big range of the stick.. it doesn't feel good at all for game to process the stick being fully pushed while it's not even half pushed..
so first of all the new input system handles controllers way better than polling Gamepad.current so i'd recommend that, because out of the box it has processors for the raw data. but i see you have that earlier message where you're getting issues when using that. do you still have the input action map setup from when you were trying that?
I removed the left and right stick.. I still use it for button because it's very usefull
in the input action map it's the same issue + the issue of returning 0 when the stick is pushed in a corner (also the raw value does show a number greater than 2 when the stick is pushed in a corner.. maybe the input system never expexted that and that's why it return 0?)
okay still waiting to see how it's setup lol
ah give me a min
gotta work with me here lol i need infoz
sorry I thought the old screnshot where enough
oh np. yeah i wanna see the input action asset with the actual action map configuration. how you have the sick setup, the processors (if any) etc
and the project setting part :
creating the settings asset does not fix or change anything, I tried
what does this mean
oh
you should have a project wide input action asset but if you're getting inputs this way i'll take your word for it. literally never set it up to not use those
something like this
ah, I'll try with thoses
like that ?
so with the nozmalization it only goes from 0 to 1. I wish to still get the range to know how much the player is pushing the stick. but also it does not fix the problem of the missing value :
2,02... mean the stick is being pushed in a corner and yet it return 0.. while when I did pushed it to the right it returned 1.42 and it did return 1.
how is the controller physically hooked into the machine? can you just plug in nintendo controllers these days
starting to think it's just a busted controller honestly lol
look ! the input debugger do give me the real value that it work :
it's just the input system that return 0,0 when the stick is actually (-0.71,0.71)
are you actually binding the inputs that you set up with the proper input action asset?
this is why you should have a single input action asset for the project cause i don't know for sure the thing i had you set up is actually the thing that you're using
yes I did : that's why I showed the Awake() part
It is created on the root of the asset folder :
what happens if you hook into the actual input action event and read the value there?
you mean doing the .performed ?
yeah subscribing to the event
sorry I forgot to add the .cancelled part
so yeah.. it should be -0.71, 0.71 and it doesn't.. also here's a screenshot to show that it work normally fine for other angles :
do you have the action on the appropriate control scheme
you should see it when you select gamepad in the dropdown
I have changed : but same result..
I can't beleive the Input debugger does display the correct value but somehow I can't have them..
did you save the asset
you can also remove the processors that was just checking something
yeah that's why I take so long.. saving asset and waiting for unity to finish loading
are you actually receiving the events when you push left
sorry I posted it too late, give me 5sec
oh np
what if you read the value in that callback from the context itself
as like :
right ?
usually when you're getting raw values but 0 processed values, it's usually a deadzone issue. you can play with the deadszone values to see if you start getting something
like min of .05 max of 1
if (magnitude < deadzoneMin) -> zero out the input
I changed the deadzone values in the project setting 0.05min & 1max
It does act as if the stick was let go.. while it's not, as the debugger show it's still being pushed.
upleft is the problem, from where I go to upleft is irrelavent (I did checked rn don't worry)
as if my thumb did left the stick
while my thumb did not leave the stick, it still push the stick
i don't understand
does it act as if you let go or does it act like you never pushed it
both ? as .cancelled event is called when the input is not being used right ?
so it act as if the stick is to it's resting place
when you say let go i'm imagining you're moving the thumb stick and it's working, and then you move it to the top left and it snaps to zero. that's what i meant by saying from left
yeah it does that, when I move it to the top left it return 0
try this, lets check the axes independently
right click your move or whatever, the root action, select add up/down/left/right composite, then for each of them, select path as gamepad->left stick-> up/down/left/right respectively. make sure "use in control scheme": gamepad is checked off. hook into those and log their outputs
like that
what i'm thinking is potentially somehow it's dead-zoning the stick based on the raw value and not the magnitude somehow so because -0.71 < 0.05, it clamps it to 0
another simple test is change your stick deadzone min to -1 if it lets you
can you send your .inputactions json as raw text here
you can do that ?
ah
open it in a text editor you'll see
that ?
ah I think that's the one :
I removed the gamepad checkbox for the leftStick and added it to each input of the 2Dvector :
running the game like this I have this result :
that looks correct no?
I have no longer the upleft problem with that setup it seem
but the value are either 1 or -1 or 0.71 or -0.71. no inbetween
it's like the stick clamp to a 8 directional vector or something
do you still have the deadzone set
the range of the stick is still not fully used.. even the debugger show (-1.00, 0.00) whe nthe stick is not even half pushed to the left
no processor of deadzone has been set on any inputs in the asset. and the settings in the project settings are :
that's what digital input does. change it to analog
the 2Dvector was set to digital normalized by default, I changed it to analog. give me 1sec
it does display -1, 1 on the upleft part. no problem
it does conform to the debugger's x & y variable of the left stick :
it still suck that it does display -1.0, 0.0 even when the stick is not halfway pushed to the left.. even the debugger miss that.. The raw input does show that it can go beyond 1.0 and reach 1.4...
But I'm so glad this first issue is resolved 
I guess I can't do anything for the second issue if even unity's input debugger miss that...
did you add the deadzone processor to the new 2d vector
it's not a unity input debugger issue. you gotta configure your shit to work the way you want it to work lol
if the debugger can't even notice the missing range then idk
like setting the deadzone max to be 1.4 ?
I did and the result are so inconsistent .. it goes from 0.0 to 1.0 when I half push it, then from 1.0 to 0.7 imediatly after I push it further, and when I push it the max it return 1.0
it's not debugging incorrect values
you're specifically trying to accommodate the switch pro controller yeah?
Add a control scheme. call it switch pro or whatever
add swtich pro controller
now under move, add binding
give that a shot
I tried and I even created another move action Move1 but it doesn't take into account the missing range..
but maybe since I can tell if the controller is a switch pro one, I can multiply the value by the raw input to take into account that missing range 
what missing range
the range of the stick, when I Move the stick halfway it return 1.0f, but the raw value does that there are more room to push the stick toward :
the correct value should be when the raw input display 1.5, it should be 1. and when the raw input display 0.75 it should display 0.5f..
but here it just remove the surplus value.. there are no resizing
I know it's so hard to describe.. wait 2 sec
there's no surplus input. it's not coupon day 
you'll get what I mean in a sec
also i don't know why you're checking the magnituude of the vector i think it's partially just you throwing yourself off becuase the diagonals will always be >1 unless you normalize the entire input, which is usable but not if you want partial movement
it's to check if the stick is halfway pushed or fully pushed
to execute different behavior the player pushed the stick fully or around halfway
yeah you're doing it wrong if you're just checking magnitude
that's what i'm saying
at first the raw input does macht what the input debugger show. but the more I push the stick further left, the input debugger stop, but the raw input does not, it show that there is more range that is unused
its. not. unused
i don't know how else to explain it lol
it's not surplus or unused. it's processed
it's missing a big part of the stick
its not missing
you need to stop thinking about it as missing
because you're confusing yourself
whats your stick deadzone max
and what do you think deadzoning does
I set it to 1, and setting it to 1.4 did not solve that issue..
show me the input asset again
you have a move action, action type Value, control type Vector 2, no interactions, no processors, Switch pro Left stick binding, on the switch pro controller scheme you made, and you're only comparing values hooked up through that? beacuse i feel like you're reading values from the generic gamepad control scheme
i thought we were testing just adding the switch pro left stick as an input
the same problem as before happened. so I made it into a 2D vector again
WHAT SAME PROBLEM jfc
the problem where upleft didn't worked
we never got to the point where it was set up all the way
didn't work
because i was talking you through your misconception
just do me a favor
open a brand new project. erase the input action asset, literally just create one scheme, one action
i don't trust any part of the conversation now
because i knwo your'e still debugging values from the raw gamepad which is a completely different scheme at this point
go back to what i told you to have
alright, I'm sorry it has escalate like this. I created a new project, deleted the default action and created a new one, with the added control scheme like you showed :
the move action type is Value, the control Type is Vector 2
kk. so what are you seeing with this
I'm generating a c#class and creating a monobehaviour to create the event .perfomed and .cancelled
(keep in mind i just want to see what the baseline for this is, likely it's not what you want right now)
the same problem of the up left part of the stick not responding happen :
can you add "Canceled" and "Performed" so we can see more clearly whats happening
and its only top left? bottom left and bottom right work?
sure :
yes, other angles work, it's also the same problem for the rightStick
if you add a normalization processor to it, it works tho?
(yes i know this will force the values to 0 or 1)
It did not force to a 0 or 1 ? I did double checked and saved the asset..
remove normalize. try inverting it just for funsies. see if it flips the quadrant where you're having the issue
It did inverted the value, but not the problem, it's still upLeft
yeah idk. controller issue or something. makes no sense
happens on left and right stick?
yes
it can't be a controller issue as the input debugger does display the correct expected value for when the stick is pushed toward upleft, it's a input system issue
what if you're only displaying the performed logs and not the canceled logs
or better yet debug drawing
the performed logs just stop happening..
when? after the first time? after you stop moving?
or like can you be in the upper left quadrant wiggling relentlessly with no performed logs occurring
I have turned the stick and kept it in the up left angle, you can see that the log stop happening, you can also see the Time in second that have passed between the two screenshot by looking at the "time" I drew a red arrow to it
Do I need another input actions map to navigate pause screen?
UI navigation has its own separate asset that's already set up by default
You don't generally need to do anything to set it up
but it looks like I could not move my cursor
Ig this is more #📲┃ui-ux talk so let's move to there if you can
Hey guys am I doing this wrong or is it a bug? I reported it as a bug to unity already but perhaps I'm just doing something wrong. But I would expect an error if so, not a crash.
I'm trying to write a unit test for input, but unity crashes. Here is some snippets of my code:
[OneTimeSetUp]
public void UnitySetup()
{
_bindings = Resources.Load<PlayerMovementInputBindings>("Tests/PlayerMovementInputBindings");
_keyboard = InputSystem.AddDevice<Keyboard>();
_mouse = InputSystem.AddDevice<Mouse>();
var go = new GameObject("PlayerMovementInputSource");
go.SetActive(false);
_playerMovementInputSource = go.AddComponent<PlayerMovementInputSource>();
var so = new SerializedObject(_playerMovementInputSource);
var prop = so.FindProperty("_inputConfig");
prop.boxedValue = _bindings.config;
so.ApplyModifiedPropertiesWithoutUndo();
go.SetActive(true);
}
[UnityTest]
public IEnumerator Test()
{
Press(_keyboard.spaceKey); // line 88, seems to initiate the crash?
yield break;
}
It's a long stacktrace, but here's from the first reference of my script:
0x00007FFAA3EEDD24 (Unity) memcpy
0x00007FFAA05C07F5 (Unity) UnsafeUtility_CUSTOM_MemCpy
0x00000181ACE5F566 (Mono JIT Code) (wrapper managed-to-native) Unity.Collections.LowLevel.Unsafe.UnsafeUtility:MemCpy (void*,void*,long)
0x00000182BFD5B77B (Mono JIT Code) [.\Library\PackageCache\com.unity.inputsystem@7fe8299111a7\InputSystem\Events\DeltaStateEvent.cs:99] UnityEngine.InputSystem.LowLevel.DeltaStateEvent:From (UnityEngine.InputSystem.InputControl,UnityEngine.InputSystem.LowLevel.InputEventPtr&,Unity.Collections.Allocator)
0x00000182BFD5A8AB (Mono JIT Code) [.\Library\PackageCache\com.unity.inputsystem@7fe8299111a7\Tests\TestFixture\InputTestFixture.cs:577] UnityEngine.InputSystem.InputTestFixture:Set<single> (UnityEngine.InputSystem.InputControl`1<single>,single,double,double,bool)
0x00000182BFD5A02B (Mono JIT Code) [.\Library\PackageCache\com.unity.inputsystem@7fe8299111a7\Tests\TestFixture\InputTestFixture.cs:461] UnityEngine.InputSystem.InputTestFixture:Press (UnityEngine.InputSystem.Controls.ButtonControl,double,double,bool)
0x00000182BFD59BA3 (Mono JIT Code) [.\Packages\com.systemscrap.squid.movement\Tests\Runtime\PlayerMovementInputSourceTests.cs:88] Squid.Movement.Tests.PlayerMovementInputSourceTests/<Test>d__10:MoveNext ()
0x00000182BFD59388 (Mono JIT Code) [.\Library\PackageCache\com.unity.test-framework@7056e7f856e9\UnityEngine.TestRunner\NUnitExtensions\Attributes\TestEnumerator.cs:44] UnityEngine.TestTools.TestEnumerator/<Execute>d__7:MoveNext ()
0x00000182BFD5847E (Mono JIT Code) [.\Library\PackageCache\com.unity.test-framework@7056e7f856e9\UnityEngine.TestRunner\NUnitExtensions\Commands\EnumerableTestMethodCommand.cs:79]
just a small sanity check - you're 100% sure it's a PlayMode test not an EditMode test, right?
Yea. But even then i would assume it to error out, not crash
is it possible to reference an inputbinding in the inspector? or would i just have to use InputActionReference and grab the binding from there?
just using a field of InputBinding seems to be for creating a new one, which i guess makes sense given it's a struct
or do i just have to use a custom inspector like the rebinding sample?
What's the use case of referencing a binding in the inspector?
I asked the same thing here not too long ago #🖱️┃input-system message
But I settled on using strings and filling it automatically
Input prompt sprites, in my case
You can use the bindings property on InputAction for that: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.14/api/UnityEngine.InputSystem.InputAction.html#UnityEngine_InputSystem_InputAction_bindings
I think that’s what I did
Loop through all actions, get the bindings they use for the device and create an array that links that to a sprite.
does the new input system have something equivalent to Input.anyKeyDown
yup, that's the one 
rebinding UI so the control can target a specific binding/control group
hi, when I'm trying to set up the left trigger to only interact on press. If I only press it half way then it works as intended, but when I press the trigger all the way and then let go it's still triggering action performed on both the press and release of the trigger.
hey, fixed it already
is there a way to create on-screen button with modifiers inbued?
Someone knows if unity ever thought about disabling the Input Manager?
because if they do that, damn, i'm screwed
i'm not saying i'm scared of the Input System (but i am)
If anyone has found a solution to a similar problem in the past, any help would be appreciated.
I have a project that uses the new input system. I have generally had decent success with the new system in the past. In this project, the inputs work fine in both the editor and a build, on my desktop (linux). However, on my laptop (also linux) the input works fine in the editor, but does not work in any builds. A webgl build also did not work on either device.
If this is of help, I used debug.log to show connected devices on my laptop:
Device found: Mouse
Device found: Keyboard
Device found: Touchscreen
Has anyone seen an error similar to this before?
Cannot read value of type Vector3 from control '/OculusHeadset2/centereyeposition' bound to action 'Transform/Position[/OculusHeadset2/centereyeposition]' (control is a 'Vector3Control' with a value type 'Vector3')
This error seems strange to me because I'm reading from the input action as a Vector3: Vector3 position = _positionAction.ReadValue<Vector3>();. Also it's interesting to note that this code works fine in the unity editor. I only get the error when running on the Meta Quest headset
I found out that this was happening because I accidently imported the System Vector3 type instead of the Unity Vector3 type
onjumpcanceled is not being called automatically
is there something wrong with the setup
behaviour of player input component is set to send message
can you please tell me what i did wrong, i will try again after fixing
with Press & Release, OnJump will be called for both the press and the release, just that it'll have isPressed at different values
so what should i do
i am checking it in OnJump()
am supposed to check in in OnJumpCanceled as well
oh i got it
Input.touchSupported is false when I press play on a simulator iPhone, yet Touchscreen.current is not null.
What are the difference between those two and why does Input.touchSupported reports false?
What should I use to detect if touch device is available?
Input is the old input system (input manager) and Touchscreen is part of the new input system
So I would not expect any kind of consistent abstraction between them
Stick to one input system or the other
Yeah I'm using the new one. Thanks, I'll just use only the Touchscreen class.
Hello Inputters, I have an issue:
I have this handeling player inputs, attacking/moving etc:
Then I have some ui buttons:
Unfortunately I need both at the same time, and I need the UI to trigger the input if I press on it, and the player to trigger the Input if not.
Currently pressing an UI-button also triggers the player attack event.
Is there some nice way to do this, or do I somehow have to check if the mouse is over an UI-image every time I call my OnAttack?
@limpid jolt the binding you're looking at is this path:
<Touchscreen>/primaryTouch/press
which you can see by pressing the T button beside the binding name
Hey, so I managed to detect the touch release by using a button action with the press [touchscreen] binding instead of the touch contact one. However I'm having a hard time mentally matching the outputs of those bindings to what I'm seeing in the script graph. Press apparently returns 1 if pressed and 0 if not , however a "On System Event Button" node has no output, instead if has "On released" "On Pressed" and "On Hold", which is more than just the true / false output the press would usually return. If I wanted to get those return values, would I have to use the "On Input System Event Float / Vector 2" instead or is there no way to get those returns via a node?
this one here
Yea, I'm coming from a fullstack webdev background but I wanted to try unity using the visual scripting route once
ah, haven't touched unity's visual scripting before...
However I feel like visual scripting is more complicated than just writing a C# script lol
what's the goal right now exactly?
Just learning tbh. The goal was to display a cube on touch and set it to inactive once the touch was released. Which I managed to do. It's just that I can't seem to fully grasp how the output of a "Press" binding (the aforementioned 1 and 0) maps to what this button node's output is (which is nothing at all apparently)
yeah there's not really anything to output for a button's event
OnPressed and OnReleased are the rising edge and falling edge when it goes from 0 to 1 or vice versa
OnHold is for interactions
(you might need an interaction for OnReleased too, not quite sure)
yeah this seems to work. I suppose the output of the touch action is directly fed into the pressed / hold / released as you just said. I'm still having a hard time properly parsing the unity documentation for some packages 😅 thanks for your help though! I'll leave it at that for today
you mean that you have "attack" bound to left mouse click for example?
The nice way to do this would be to put a big invisible UI Image behind everything else in the UI and set it up with a script with IPointerDownHandler and have that trigger the player attack
instead of doing it through the PlayerInput
Helpppp!!!! WTF is going on???? I make a new action and this happens???
i dont have and OnPause member
Duplicated the Action asset?
youre right tysm but how did this happen? i just mad a new action and it makes a whole new script?
If you moved the generated file to another folder or renamed it, that can happen
How do I detect when the player stops moving their mouse when using the pointer delta? I feel this did not used to work this way before, but currently if I don't set the action to passthrough it never passes (0, 0) as input, and if I set it to passthrough it spams (0, 0) in-between the real values of the pointer delta.
Actually currently all "value" types never pass me "0" as input. Which is really annoying. But especially annoying on the pointer delta because it seems to always spam (0, 0) even when using the canceled action.
you will only get 0 as input with the default interaction when listening to the canceled event
performed happens when the value of the input changes to a new non-zero value
although mouse delta itself may be a little special compared to a joystick for example
because the mouse only sends events to the application when it moves
like I mentioned that spams (0, 0) in between real values. So if I just log both in update it would be something like this:
(0.12, 0.3)
(0.0, 0.0)
(0.12, 0.29)
(0.0, 0.0)
(0.14, 0.14)
Which makes it difficult to tell when it actually stops
the simplest approach is probably to use Pass Through or just to skip events entirely and poll the value in Update
People get a little too married to event-based handling
Update is sometimes the best
how do you poll it in update? I thought the new input system was completely event based.
You would be mistaken about that
event based handling is one option
You can call ReadValue directly on an InputAction
Vector2 inputValue = myAction.ReadValue<Vector2>();```
ah okay thanks let me try doing it that way
you can also poll on the device directly, Mouse.current
Moving [this query](#1390355039272439868 message) over to this channel: I want something like AnimationCurve for my workflow but AnimationCurve doesn't suffice because I want the "keyframe" x-coordinate to have a type int. I'm willing to try to write a module from scratch, could somebody point me somewhere to get started with it?
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerMovement : MonoBehaviour
{
PlayerInput playerInput;
public float moveSpeed = 1f;
private Rigidbody rb;
private Vector2 moveInput;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void Update()
{
rb.linearVelocity = moveInput * moveSpeed;
}
public void Move(InputAction.CallbackContext context)
{
moveInput = context.ReadValue<Vector2>();
}
}```
Currently, because my 3d game is using vector2 for movement inputs, my character gets sent up into the sky along the y axis whenever they try to move forwards. I know I need to convert the Vector2 into a Vector3, but how would I integrate that into this code? I've tried kitbashing a few different tutorials together before asking for help here but I've been unable to get it to work myself after an age of troubleshooting because I've only been learning c# for two days now, and I'm not 100% on what some of the words mean yet.
nevermind, i decided to try another method
you would create a new Vector3 where you swap the axes appropriately, ie new Vector3(moveInput.x, 0, moveInput.y)
yeah i had put that in there previously but i must have put it in the wrong place because it gave me this error:
"There is no argument given that corresponds to the required formal parameter 'context' of 'Player Movement.Move(InputAction.CallbackContext)". How would you fit it in?
i had put it in the public void move function
what code was actually triggering that
that's unrelated to turning a vector2 into a vector3
that would arise from trying to call Move yourself and not giving an argument
This is my script. I added this thing called smooth land. My character is floating and has this spring mechanic as many other controllers have. I just cannot figure out how to do the jump. If the player is lower in the spring he cannot jump as high if he were at the top position. My goal is to make the jump be always the same, to be consistent, so when I jump I know how far I can jump. https://pastecode.io/s/y92vanch
Hi, so I started using the new input system and i've got the movement right but i can't seem to get the mouse input right. Before i was using this
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity;
and with the new delta i now need to use something like this:
private void _inputOnLook(InputAction.CallbackContext context) {
_lookInput = context.ReadValue<Vector2>();
}
Vector2 delta = _lookInput * sensitivity;
but when using the new input system, my mouse basically "jumps" or "increases sensitivity" with each frame drop or increase and I don't know how to fix this, i've searched online but no results about this. This is my InputActions file
You haven't shown the full code involved nor the action setup
But you've also switched from polling to event based
So that will change some things
Show the rest of the code and the action configuration
You only showed the binding
Also show how you hooked up the event listener
this is the full code
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour
{
//variables
private void Awake() {
_characterController = GetComponent<CharacterController>();
_inputActions = new PlayerInputActions();
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = true;
}
private void OnEnable() {
//Subscribe to all input actions
_inputActions.Enable();
_inputActions.Player.Move.performed += _inputOnMove;
_inputActions.Player.Move.canceled += _inputOnMove;
_inputActions.Player.Look.performed += _inputOnLook;
_inputActions.Player.Look.canceled += _inputOnLook;
}
private void Update() {
_handleLook();
_handleMovement();
}
#region Movement
//Input Callbacks
private void _inputOnLook(InputAction.CallbackContext context) {
_lookInput = context.ReadValue<Vector2>();
}
private void _inputOnMove(InputAction.CallbackContext context) {
_movementInput = context.ReadValue<Vector2>();
}
//Movement and Look Handlers
private void _handleMovement() {
_movementDirection = transform.TransformDirection(new Vector3(_movementInput.x, 0, _movementInput.y)).normalized;
_characterController.Move(_movementDirection * Time.deltaTime * moveSpeed);
}
private void _handleLook() {
Vector2 delta = _lookInput * sensitivity;
_smoothedDelta = Vector2.SmoothDamp(_smoothedDelta, delta, ref _cameraVelocity, cameraSmoothing);
transform.Rotate(Vector3.up * _smoothedDelta.x);
_xRotation -= _smoothedDelta.y;
_xRotation = Mathf.Clamp(_xRotation, -90f, 90f);
cameraHolder.localRotation = Quaternion.Euler(_xRotation, 0f, 0f);
}
#endregion
}
Can you try disabling your camera smoothing for a minute?
IE directly use the delta without smoothing.
BTW you can avoid having to subscribe to both Performed and Canceled if you switch your action to a Passthrough action
you will only need performed then
still jumping
okay i'll look into it
Can you also show how the Action is configured?
this?
you can also make this all a lot simpler by getting rid of all the event-based stuff entirely
just make Update look like this:
Vector2 delta = _inputActions.Player.Look.ReadValue<Vector2>() * mouseSensitivity;```
and then it's exactly the same as you had it in the old input system
oh okay
it's still happening
What update mode is your input system set to
You can check in project settings - Input System
its set to frame update, like the default one, not fixed update
what's the current code look like
basically the same except i changed the smoothDelta to just delta on the look function
what about refactoring out the event based stuff?
okay i did it but it didnt fix the jumping
Show code
I dont have code atm, but my character cant jump with the new input system. I have the default setup that comes with unity 6.1 and no matter if I use SendMessages or UnityEvents the public void OnJump(InputValue value) (or callbackcontext) function doesnt trigger the jump. When I use the same jumping functionality with the old system it works just fine
Every other function (OnMove, OnLook, etc.) works just fine
make sure it's typed correctly, make sure you see an OnJump in the playerinput
Its all there and typed correctly
do you even need the inputvalue though?
I tried using it and not using it
Neither worked
Ill get back to my pc and share the code in a moment
But using Input.GetKeyDown(KeyCode.Space worked just fine. Id imagine the OnJump(InputValue _) should fire as well whenever the key is pressed
And the debugger shows the key events too
So im really not sure whats going on
could you show the playerinput component
Ill get back to my pc soon, then I can
But I didnt change anything on it from the defaults
using UnityEngine;
using UnityEngine.InputSystem;
[RequireComponent(typeof(CharacterController))]
public class PlayerController : MonoBehaviour
{
[Header("Movement")]
[SerializeField] private float moveSpeed = 5f, sensitivity = 0.1f, cameraSmoothing = 0.05f;
[SerializeField] private Transform cameraHolder;
private CharacterController _characterController;
private PlayerInputActions _inputActions;
private Vector2 _movementInput, _lookInput;
private Vector3 _movementDirection;
private float _xRotation = 0f;
private Vector2 _smoothedDelta, _cameraVelocity;
#region UNITY METHODS
private void Awake() {
_characterController = GetComponent<CharacterController>();
_inputActions = new PlayerInputActions();
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = true;
}
private void OnEnable() {
//Subscribe to all input actions
_inputActions.Enable();
}
private void Update() {
_handleLook();
_handleMovement();
}
#endregion
#region Movement
//Movement and Look Handlers
private void _handleMovement() {
_movementInput = _inputActions.Player.Move.ReadValue<Vector2>();
_movementDirection = transform.TransformDirection(new Vector3(_movementInput.x, 0, _movementInput.y)).normalized;
_characterController.Move(_movementDirection * Time.deltaTime * moveSpeed);
}
private void _handleLook() {
_lookInput = _inputActions.Player.Look.ReadValue<Vector2>();
Vector2 delta = _lookInput * sensitivity;
//_smoothedDelta = Vector2.SmoothDamp(_smoothedDelta, delta, ref _cameraVelocity, cameraSmoothing);
transform.Rotate(Vector3.up * delta.x);
_xRotation -= delta.y;
_xRotation = Mathf.Clamp(_xRotation, -90f, 90f);
cameraHolder.localRotation = Quaternion.Euler(_xRotation, 0f, 0f);
}
#endregion
}
this is a video of how it looks in slow motion
im moving the mouse at the same speed btw
use screen recordings instead of videos
why
i always use obs but i just wanted to show it in slow motion
my pc would crash if it had more than 60 frames set in obs
you can just slow the mp4 down after the fact
it wouldn't give the same effect tho
oh i see what you're saying
that's.. unfortunate
(doesn't windows let you do recordings natively without third-party apps though)
tried it but it's even worse than obs
rip
smart idea would be to buy elgato capture device and just record my screen using another laptop
to not affect fps in any way on my main pc
you sure this is due to frame rate? what about like, mouse acceleration?
is it like that in a build too?
suprisingly i don't really see that it's jumping in build
yea so must be editor issue then
try enabling vsync in game view
So ive been told to go in here by , Nitku, my mouse isnt being Picked up in the game while running, this is for my script to look around. Also its picking up my controller(Xbox if that matters). Oh and my mouse(in the new Input system(and im unity 6)) is action type is Value and control type is Vector 2, the binding is Delta [mouse]
Code: https://paste.myst.rs/cnw21202
a powerful website for storing and sharing text and code snippets. completely free and open source.
i can make a click event or a mouse move event,
but is there a way to combine click and drag to a single action and fire the event when mouse is held and dragging ?
not really - but what are you trying to handle dragging for exactly? IDragHandler exists
click hold then drag to move the camera
drag up the camera move down
just simple minimap move around thing
or should there another way ?
you can do that with IDragHandler
drag camera? how
private void Pan(InputAction.CallbackContext context) //delta event
{
if (Mouse.current.leftButton.isPressed) // fixed left click hold to pan
{
Vector2 mouseDelta = context.ReadValue<Vector2>(); // mouse pos change each frame
Vector3 move = new Vector3(-mouseDelta.x, -mouseDelta.y, 0) * panSpeed;
mapCamera.transform.position += move;
}
}
here my snippet
Yes something like that but in the DragHandler callback
Not using the input system directly
alr i'll give it a try
this could works, but it doesnt appeal to me, i keep this in mind tho
want the ui controls groupped atm
Sorry to ask again! But my mouse isnt being Picked up in the game while running, this is for my script to look around. Also its picking up my controller(Xbox if that matters). Oh and my mouse(in the new Input system(and im unity 6)) is action type is Value and control type is Vector 2, the binding is Delta [mouse]. Is there a way I can fix this. In the debug input for the input manager my mouse is disabled but when I force enable it still doesn’t work
Code: https://paste.myst.rs/cnw21202
a powerful website for storing and sharing text and code snippets. completely free and open source.
Have you tried debugging the value to check if it isn't being picked up at all or if it's just very small values? I had an issue before where the controller and mouse would have wildly different values because of how each input works, resulting in the controller being much more sensitive
No values are being picked up at ALL
is that a known problem that on the new input system, mouse movements lag when you press LMB or RMB? is there a way to fix this?
I don't even have any input actions bound to mouse buttons, it lags my camera movements regardless
Unity 6.000.0.32f1 and Input System 1.11.2
Is this an Editor bug where if you hit the play button.... no input works at all?
Seems like it varies but a lot of times if my cursor isn't in the window at the VERY MOMENT the playtest starts.... then no input from keyboard, mouse, or gamepad works... (solo or with Multiplayer Play mode)
In addition it seems like sometimes the gamepad wont work at all unless I am using the gamepad immediately before the other clients spawn in (with Multiplayer Play Mode)
first issue is a bigger concern cause I have to just keep restart testing every time just to make sure I have input. Its weird to me though because if it works at start.... and then I tab out.... and tab back in it works. But if it doesn't work at start... then none of it works ever
Doesn't sound normal.
THsoe versions are a bit out of date though - I would try updating your Unity and input system versions
tried updating both to the latest version and still not working
also tried debugging if it would get the raw input or not and it doesn't even get the input
Show your code?
first time I am ever using Input Debug but im not sure why there are 2 users in this case
Because you have two different control schemes
Each control scheme detects a set of devices to assign to a user
PlayerInput assumes a single user per PlayerInput component
That's most likely your issue
how do I force a single user capable of using multiple inputs?
Wait... I think I am seeing the cause
I guess I had a hidden Player Input in my scene.... 😐
and I guess regarding the Keyboard not working at start.... I guess Keyboard is considered different input than GMMK 3 HE... which is weird because GMMK 3 HE is the name of my keyboard but I guess acts differently in terms of inputs?
If this game is single player you should remove all the control schemes
its gonna be for online multiplayer.... but I assume you mean per client?
and why delete all control schemes? isn't one for each device for mapping?
Yes per client
Control schemes are only useful for local multiplayer
If you just want the player to be able to interchangeably use all their devices you don't need or want control schemes
A control scheme is a set of devices the input system assigns to a single local user
How can i add mouse wheel scroll up/down to input map? I've tried to search for wheel, scroll or just listen but it didn't gave me anything
How did you set up the action?
Looks like you maybe have it as a button right now?
It should be an axis to get axis controls
Value/Axis possibly? Don't remember exactly
Yeah, there it is, thank you
the problem seems to have fixed itself lol
quick question, just tried out a few things for prototyping. would this be the equaliant to the old Input.GetAxis("MousX")
float mouseaxisX = Mouse.current.delta.ReadValue().x.normalized;
what axis is that wtf
i'm not seeing that axis in the inputmanager
i don't think it really makes sense to normalize a delta in this case though
floats don't have a normalized prop
should be correct without that part though
(except maybe the smoothing, idk if this axis would have smoothing)
ok so i am able to get the vector2 just need to normalize it somehow ( the float)
normalizing real numbers is called absolute
(why though? doesn't GetAxis also give negative values depending on the direction?)
the problem is delta.ReadValue gives me some really high numbers that is why i wanted to mormalize so i get values from -1 to 1
- is it perhaps just giving them in different spaces?
- the inputmanager seems to specify
Sensitivity: 0.1for the mouse deltas, that might be related GetAxishas smoothing
normalizing doesn't make you get values from -1 to 1
it makes the magnitude exactly 0 or 1
ah, so i messed up
normalizing real numbers is the sign function, not absolute
the magnitude of a real number is absolute
what are you using this for? if you normalize you lose info about how much the mouse moved and you only get the direction
just wanted to reproduce somethign that would be the equaliant to the old GetAxis("MouseX"). This actually does the trick
Vector2 mouseaxis = Mouse.current.delta.ReadValue().normalized;
float x = mouseaxis.x;
Debug.Log(x);
you're telling me GetAxis("MouseX") isn't a delta?
that doesn't really make sense...
like i wanted a soloution that doesnt require any components or action map. jsut something that works with the new Mouse class from the Inputsystem
yeah but an equivalent to Input.GetAxisRaw("MouseX") would just be Mouse.current.delta.ReadValue().x, afaik
well as mentioned the problem is that it is not normalized it gives some really high values
and as you already mentined the float can not be normalized
or also Mouse.current.delta.x.ReadValue(), apparently
it can, it just doesn't make sense
there are tons of ways to use the new Input System to be honest. This is of course against the cross device logic but just for somethign really quick and if you know you wil only work on desktop it is ok
no, that's not what i'm talking about at all
so what are you talking about then, sorry if i missed that one
@oblique raven the discrepency you see is simply the sensitivity setting set in Input Manager.
these two are the inputsystem equivalents other than that
thanks
o/ can someone help
i need to read LBM click. Which Action Type do i need? I can't find where this is explained
in some video the author somehow received a float value and in the code read it and wrote it to a bool variable
it should be a button type, but i mean.. i guess you could probably receive a value? i don't see the point though
and how do I read this? it should be something like ReadValue<bool>();
.IsPressed()
Or .WasPressedThisFrame() depending on what you want
yes
and if I want to read the R [keyboard] in Shooting action? can i use ReadValue<smth> in the same action? or maybe it would be better to make a new action
k i solved it
thanks guys
What would you want R to do? Reload?
Or also shoot?
reload
If it's to also shoot, you don't need to do anything special.
If it's a totally different action (reloading) you should make a separate action called Reload
i actually did this already
new action i mean
thanks
Im trying to use the new unity input system. I have the notification mode set to "Send messages". I use this function below to capture if the user is spriting. However, the game starts as not sprinting, then when I click shift the game recognizes sprinting. But when I let go of shift, it doesn't untrigger and still says its sprinting. Why is this?
public void OnSprint(InputValue value)
{
isSprinting = value.isPressed;
}
have you set interactions to press & release?
if not, with playerinput set to sendmessages, it'll only tell you about the press
i want to get the player's coordinates with
Vector2 playerPos = Camera.main.ScreenToWorldPoint(transform.position);
but they are not (0, 0) at start
the player is in the center of the screen (also where the camera is)
transform.position is a worldpoint, you need to convert that to viewport space
this is also definitely not the right channel
go to #💻┃code-beginner or #💻┃unity-talk
wrong channel sry
Is this how its supposed to be setup?
yeah, that should be right
Do you guys think this is a good idea to have an Action<> for each input phase or whatever its called (started, performed, cancelled), or should I just have one argument and handle the phases in the callback function I pass in?
public void EnableInput(
InputActionReference input,
Action<InputAction.CallbackContext> startedCallback = null,
Action<InputAction.CallbackContext> performedCallback = null,
Action<InputAction.CallbackContext> canceledCallback = null
) {
input.action.Enable();
if (startedCallback != null) {
input.action.started += startedCallback;
}
if (performedCallback != null) {
input.action.performed += performedCallback;
}
if (canceledCallback != null) {
input.action.canceled += canceledCallback;
}
}
public void DisableInput(
InputActionReference input,
Action<InputAction.CallbackContext> startedCallback = null,
Action<InputAction.CallbackContext> performedCallback = null,
Action<InputAction.CallbackContext> canceledCallback = null
) {
input.action.Disable();
if (startedCallback != null) {
input.action.started -= startedCallback;
}
if (performedCallback != null) {
input.action.performed -= performedCallback;
}
if (canceledCallback != null) {
input.action.canceled -= canceledCallback;
}
}
I feel like this isn't really adding anything to the existing InputAction api
What is the general consensus on the new vs old input system? Which is preferred for mid to small scale projects?
I prefer the new system for all projects
As far as I'm concerned the old system is only useful if you're not ready to learn the new one yet
Im trying to make it so enabling an input can be done with just a single function call, instead of having to enable it and sub to events one by one
Since its easy to forget about doing one or the other once or twice when you have a lot of inputs (not to mention the bloat it adds to a script)
But I changed it so it has a singgle callback, not three
You can do this in the new system
But also what do you mean by "enabling an input"?
Sorry nevermind I realized I mistook this conversation for another
like you'd have to do
private void OnEnable() {
someInput.action.Enable()
someInput.action.started += callback;
someInput.action.performed += callback;
someInput.action.canceled += callback;
}
I think the problem here is that sometimes you want to subscribe to all three but sometimes you don't
oh no worries
You're robbing yourself of the flexibility
If you find yourself doing this often I would actually get rid of the second and third parameter and add the same delegate to all three events, no?
It depends on your usage patterns
Since then I changed it to do that
now its just
public void EnableInput(
InputActionReference input,
Action<InputAction.CallbackContext> callback = null
) {
input.action.Enable();
if (callback != null) {
input.action.started += callback;
input.action.performed += callback;
input.action.canceled += callback;
}
}
and I handle the started || performed || canceled cases inside the callback
(If I need to handle them at all)
so like the interaction just looks like this for example
private void OnInteract(
InputAction.CallbackContext context
) {
if (context.performed || context.canceled) return;
OnInteractPressed?.Invoke();
}
Yeah, I mean there's nothing wrong with it per se, so long as you understand the tradeoffs
Well, so far I haven't run into tradeoffs luckily
I'm not using these inputs for anything too complex, so there's not much wrestling with it
But I can imagine running into issues* if I want to have interactions that take x amount of time
thats a problem for future me to figure out
yo how do I get the device tilt like device tilt on mobile or something that can be tilted
I use the player input manager and player input component on my prefab, stick input works fine but keyboard input does not work unless I duplicate the object using keyboard input??
Are you using control schemes?
Control schemes are for local multiplayer. Your game is correctly assigning different input devices to different players.
Mb for very late response, yes I have different control schemes for controller and keyboard
That's your problem.
Unless you're doing local multiplayer, you don't need control schemes. You also should not have more than one PlayerInput component in the scene
But how else would i have local multiplayer?
Disagree. It's useful to have control schemes so the game can react to which input method you're using.
Typically UI doesn't behave the same when you're using a gamepad
You can do this without control schemes
If you're doing local multiplayer then I'm confused by the problem you are having. You want local multiplayer but you also want a single player to use both a keyboard and a gamepad simultaneously?
I want one player to use a game pad and another using the keyboard, but when I use keyboard, move input just does not work
When you have both devices PlayerInputManager will spawn two different player objects
Or at least it will when you press the join action you set up
And each device will control a different player
Yeah that happens already
It’s just that when I connect on keyboard, the move input doesn’t work, the other inputs work fine
Do you have Active Input Handling set to New or Both?
What is your actions asset configuration and how are you using it in your code?
thank you for your help, I tried the input analyzer and the inputs were working, there was a problem with GameMaker
can anyone confirm that the hardware cursor becomes briefly unresponsive after calling WarpCursorPosition?
There seems to be a brief (maybe 1/4 second?) delay after I call WarpCursorPosition where the hardware cursor does not move, even though I’m moving my mouse.
Can simply rig a key to warp cursor to the middle of the screen, then press it repeatedly while moving the cursor in a circle… notice that the cursor seems ‘stuck’ to the place you warp it to briefly, before it resumes tracking the movement of your hand.
Is this intended behaviour? Can’t find any reference to it in any docs or online.
It does not happen to me, using Mouse.current.WarpCursorPosition() in Unity 2021.3.43f1...
The mouse continues to move immediately after the change. Are you sure you don't move the cursor for more frames than you intended at the moment you do the Warp?
seems to only be called on the one frame, yes. but i'm using unity 6? maybe something has changed?
well it will override any mouse movement on the exact frame you call it of course.
yes but i've timed it now, the cursor doesn't move for 15 frames afterwards, despite constant mouse movement
show the code?
lol... pretty straightforward
when I debug.log at this point, it's only called on one frame
the rest of the code
where and when is this function running for example
as it is this is just a wrapper function that adds nothing, so it doesn't tell us much to look at this
yes, i understand that for sure
if other people are able to call that method in unity 6 and the mouse immediately starts moving on the frame afterwards (as long as the physical mouse remains in motion), then it's obviously not a unity bug
that's all i was trying to confirm
because for me there's a period of 15 frames where the hardware mouse cursor does not move despite physical mouse movements
after the one frame where that method is called
as far as I know, yes. My guess is that your code is calling it continuously for those 15 frames or it is calling it once and then again 15 frames later
something like that
I will check again with debug statements, just to be extra sure
also I am on a mac, are you on windows? I know there is some evidence that cursor handling differs at a low level between platforms
can confirm that the code is only being called once
I use Unity on both, but I haven't tested
ok yeah would love someone to confirm if that's the case for them on mac
you guys know how in platformer games you can tap jump for a small hop or hold for the full jump? how would that normally be done?
i think the way that i was doing it originally was halving gravity until the action is registered as performed or cancelled
but i'm not 100% sure if that's a good idea
especially since i might want to do calculations with my jump force to set it to specific heights
and i'm not 100% sure if i should implement jumpsquat
It might be easier to handle that by polling the input in Update rather than using events
wait i've just had an idea that might be extremely stupid
what if i make it so that you jump as soon as you press the button, but for every frame until the maximum force has been reached or the button is released more force is added?
i'll have to change my input system interaction thing
Yes you would do something along those lines, certainly.
wait i'm looking through the docs and i'm not sure how to do this with the input system
i can't see one that's called every frame that the input is held
i'm gonna have to do this a weird way
You would use Update
The input system does not do anything on a per frame basis
am i going to need a bool that's set to true once the input is pressed and false once released or once the jump is finished?
it's doable, it'll just be awkward
Or just poll the input in Update and get rid of the event based handling
how does that work with this input system
i think i've used that before but i just forgot
or not this input system
but you know what i mean, right?
You can call ReadValue() or IsPressed() directly on an InputAction
Can we use new input system with UI buttons?
of course you can
Ok, thx
Hi guys, we are thinking about porting our VR app to 2D, we're hesitating between WebGL & Windows as a platform (right now we're on Android for the Quest)
We're using meta SDK, did any of you did that in the past? Do you have any hints how to do that, assets, tutorial, I take anything!
Well it's not a one way door
You can do both
Just start with the one you want more
Hello everyone.
Does anyone know what's a good way to handle this. So I have a game and I'd like to support keyboard, physical controller and on-screen controller inputs and rebinding of every action on every controller.
So far I added support: there's a player actions class, every action has bindings from keyboard and gamepad, I've also added on-screen controller support: it emulated gamepad left stick and XYAB buttons.
I've also added functionality to rebind actions for keyboard and gamepad.
The question is: how do I handle rebinds for the on-screen controller and the conflicts with the physical controller. Right now the paths it emulates are hard-coded: left stick and XYAB buttons.
how do i add scroll wheel input to the new input system
It's the same as any other control
Just add it as a binding on whatever action you want
which one is it
Mouse ScrollWheel
Make sure you configured your action as an axis first
Looks like this is probably a button action
yeah its a button action
Well that's not correct for ScrollWheel now is it
I'll tell you, it isn't
I just said, it needs to be an axis
Might be Action Type: Value. Control type: Axis
yeah thats the one thanks
yep works wonderfully thanks a lot
so is this the only way to set up button and value input
no. The input system is very flexible. You are using the PlayerInput component in UnityEvents mode.
- PlayerInput has other modes of operation
- You don't even have to use PlayerInput at all.
There are many other ways to do things.
Hi
Anione can explain me how I can make move control for the player 2 in my scene with the new input system
I am creating a simple pong and I need to move the player 2 with your specific 2nd console gamepad
when I move the player 1 the player 2 is moving too
I unable to find out that why Keyboard space is working fine for jump but Jump UI button is not working?:
Script codes attached to Player object:
using UnityEngine;
using UnityEngine.InputSystem;
public class MobileControlsFunctioning : MonoBehaviour
{
private Rigidbody player;
private PlayerMobileControlsInputs mobileInputs;
private void Awake()
{
//Cursor.lockState = CursorLockMode.Locked;
//Cursor.visible = false;
player = GetComponent<Rigidbody>();
mobileInputs = new PlayerMobileControlsInputs();
mobileInputs.Player.Enable();
mobileInputs.Player.Jump.performed += Jump;
}
private void Update()
{
Vector2 moveInputs = mobileInputs.Player.Move.ReadValue<Vector2>();
float speed = 5f;
player.AddForce(new Vector3(moveInputs.x, 0, moveInputs.y) * speed, ForceMode.Force);
}
private void OnDisable()
{
if (mobileInputs != null)
{
mobileInputs.Player.Disable();
}
}
public void Jump(InputAction.CallbackContext context)
{
player.AddForce(Vector3.up * 5f, ForceMode.Impulse);
}
}
you have to switch action maps
But I only have Player action map
You don't have an Event System in the scene
So no UI interaction will work at the moment
does anyone know how to use the new input system so that you only get input when a button is pressed
I tried using a press interaction but couldnt seem to get it working
that's pretty vague. Are you talking about event-based input handling? There are a few ways to do it.
It depends on your workflow
You almost never need to use a press interaction
the default interaction is just fine unless you need to customize the actuation point for a button or something
you know how the old system had Input.GetKeyDown(), thats all I want
new system has almost the same thing
if you really want that
but I wouldn't recommend it
