#🖱️┃input-system

1 messages · Page 30 of 1

uncut yacht
#

Yes, you can probably have it working in FixedUpdate.

misty swan
#

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?

misty swan
#

Thank you, I think I should also stop being so gung ho on always trying to use the new input system😂

alpine dock
#

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.

austere grotto
mystic hearth
#

Guys how to make multiplayer

#

I have a linux server

austere grotto
#
  1. Pick a network framework
  2. Go through their getting started tutorials to learn the basics
  3. Apply those learnings to your game, being ready for a lot of trial and error
cold lark
#

Is it possible to use XInputController with an ESP32 ?

mystic hearth
#

Multiplayer easy I just dont know how in unity

austere grotto
#

Also it has nothing to do with the input system

cold lark
alpine dock
iron dune
#

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...

fierce compass
# iron dune i have input handler script, and button. when i hold the button, attackInput bo...

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 isPressed in OnAttack - 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

iron dune
#
    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;

    }
fierce compass
#

if you're using the actions directly then you don't need the playerinput

iron dune
#

uh...
lol

fierce compass
iron dune
# fierce compass 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?

fierce compass
#

no, not at all

iron dune
#

yes, i mentioned it

fierce compass
#

how does this fit into any of the options i mentioned lol

iron dune
fierce compass
#

no, that's pretty unnecessary

fierce compass
#

why are you ignoring them lol

iron dune
fierce compass
#

that's not "consuming" the buffered input though

iron dune
#
    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...

fierce compass
#

what i'm referring to is something like this:

bool shouldAttack;

attackAction.performed += () => shouldAttack = true;

void Update() {
  if (shouldAttack) {
    // do actual attacking
    shouldAttack = false;
  }
}
fierce compass
iron dune
#

uh ...

fierce compass
#

you're really overcomplicating it

fierce compass
#

ok, how do you plan to attack?

#

as in, where are you going to do the actual attack logic

iron dune
#

on key down, player will attack

fierce compass
#

where do you want to put that logic

fierce compass
#

and you already have a method to call for that?

#

then just call the method directly

attackAction.performed += () => melee.Attack();
iron dune
#
    private void Inputs()
    {
        _moveInput = ih.moveInput;
        _lookInput = ih.lookInput;
        _attack = ih.attackInput;
    }

its just copy inputs from Handler and just use this

fierce compass
iron dune
#

i dont know how to use this input action maps...

#

my code is terrible because of that

fierce compass
#

you don't need a variable to do that then

iron dune
#

and tutorials doesnt helps

fierce compass
#

just a public bool attackInput => attackAction.WasPressedThisFrame();

fierce compass
#

sure

#

though theoretically i guess you could have moveInput and lookInput be properties too

iron dune
#

wth... this actually works

#

thanks

fierce compass
#

that's up to you if you want it though

iron dune
fierce compass
fierce compass
#

again, you don't have to tell me that

#

just go ask

#

i'm not your personal assisstant lmao

iron dune
#

ok

crude ravine
#

Hey, would this be the appropriate place to ask for help with a problem Im having relating to buttons?

fierce compass
crude ravine
#

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

fierce compass
#

uh well let's start with that, are you using the input system

austere grotto
ember apex
#

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

ember apex
minor pebble
#

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

verbal remnant
# minor pebble im having a hard time making a touch input action that correctly calls `performe...

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

Get the Fingers - Touch Gestures for Unity package from Digital Ruby (Jeff Johnson) and speed up your game development process. Find this & other Input Management options on the Unity Asset Store.

minor pebble
#

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

minor pebble
verbal remnant
austere grotto
#

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

heady minnow
#

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?

austere grotto
#

don't crosspost

oblique elm
#

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.

upper mantle
#

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.

austere grotto
upper mantle
austere grotto
# upper mantle 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.

upper mantle
austere grotto
#

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.

upper mantle
tough moat
#

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

austere grotto
tough moat
#

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

fierce compass
#

you should probably just let deadzones govern that

austere grotto
fierce compass
#

and you should probably cache the value that you read

tough moat
#

Okay so it looks like there might be something else going on, I'll get to profiling

cosmic venture
#

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.

austere grotto
#

and how you determined it's "not working"

solid niche
hazy coral
#

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

timid dagger
# hazy coral ```c-sharp public class BodyController : MonoBehaviour { [SerializeField] p...

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.

misty swan
hazy coral
hazy coral
#

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

austere grotto
#

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

hazy coral
hazy coral
#

OK problem fixed, I guess the solve is just revert the whole project to my last patch. Thanks for the insight!!

zealous falcon
#

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

zealous falcon
#

Nevermind guys... I fixed (most of it at least).. I was forgetting this reference.

silent shadow
#

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...)

verbal remnant
silent shadow
#

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

verbal remnant
silent shadow
#

I tried to change the "Control Type" to : Analog, Stick or Axis. but they still don't fix it..

verbal remnant
# silent shadow the input action asset ?

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.

silent shadow
#

I have not touched the global settings.. and even when grabbing the inputAction itself, so wihout the generated class. it doesn't pick it

verbal remnant
shy bramble
#

What happened to my characters face?

austere grotto
shy bramble
#

whoops

hearty terrace
#

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

hearty terrace
#

getting the pressed key and checking if its in a list

#

aka if its a letter and not a random character

hearty terrace
#

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

austere grotto
hearty terrace
#

i was misreading it really bad :P

polar carbon
#

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

austere grotto
#

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

polar carbon
polar carbon
austere grotto
#

you just put the actions in an array in your code

#

But I get what you mean

polar carbon
velvet ivy
#

OnMove calls just fine
OnLook created the same way does not

Both are properly assigned in my gameobject

any ideas?

fierce compass
velvet ivy
#

Yes

#

The method is not called

#
public void OnLook(InputAction.CallbackContext context)
    {
        UnityEngine.Debug.Log("OnLook called");
        lookInput = context.ReadValue<Vector2>();
    }```
fierce compass
#

have you tried the input debugger, to make the input system is picking up the input?

velvet ivy
#

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

fierce compass
#

what control type have you set OnLook to?

velvet ivy
#

Vector 2

fierce compass
#

shouldn't it be Delta?

velvet ivy
#

uhhh perhaps but its not calling the debug log regardless

#

ill try setting it to delta

#

no log still

#

so confused lol

fierce compass
#

-# man what do those control types even do

velvet ivy
#

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

quasi chasm
#

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

ebon aurora
toxic lintel
#

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.

quasi chasm
#

your best bet, is submit a bug to unity about it

toxic lintel
#

Hmm, yeah. Haven’t had great experience with that unless I told them the exact line of code that needed fixing 😅

But thanks.

molten cradle
#

Hello, I am looking for a template for an open world game with a car ride and arrival system.

#

It is free

proper berry
#

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?

austere grotto
fierce compass
#

!code

sonic sageBOT
proper berry
austere grotto
proper berry
# austere grotto You're trying to do a physics Raycast to interact with UI components. That doesn...

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.

austere grotto
#

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?

honest stump
#

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

austere grotto
#

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

honest stump
#

ah sure

austere grotto
#

I'm also about to board a flight so I likely don't have time to look at more code at the moment

honest stump
#

lemme see if i can show a bette.....NOOOOOOOOOO

#

damn

austere grotto
#

InputAction.WasPressedThisFrame() is largely equivalent to GetKeyDown

#

Or GetButtonDown

#

I would consider using that

#

(assuming you are using the default interaction

honest stump
#

oh, there is something like that

honest stump
austere grotto
#

Sure but that will be a drastically different workflow than using GetKeyDown so you'll need to adjust things

honest stump
#

when i started i watched about 5 videos and each of them had diferent implementations

honest stump
#

or rather a reference to

proper berry
# austere grotto What kind of game is this

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.

austere scaffold
#

Help, my joystick isn't working...

fierce compass
#

is AndroidJoystick a composite?

austere scaffold
fierce compass
#

in the input actions editor, select the Stick [AndroidJoystick] binding and show the right side

#

if it shows "show derived bindings" expand that first

austere scaffold
fierce compass
#

you've set On-Screen Stick to be hooked up to Left Stick [Gamepad], that's not the same as Stick [AndroidJoystick]

austere scaffold
#

Mhm, I changed that to android joystick

#

Someone please help... T_T

fierce compass
#

did it not work or what

austere scaffold
#

Nope

fierce compass
#

you said you changed it and then didn't say anything else

#

can you show the current joystick setup

austere scaffold
#

Okkk

fierce compass
#

can you show the inspector of the event system

austere scaffold
fierce compass
#

well that seems correct...

austere scaffold
#

🥲

#

Did I find a new bug?? 😭 😭

honest stump
#

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?

proper berry
austere grotto
#

if you're in a version lower than 1.4.0, you will need to handle it yourself with two separate bindings.

glass plaza
#

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?

proper berry
glass plaza
glass plaza
# proper berry <@165158777178423297>
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.
glass plaza
# proper berry

make another one in play mode (of the instantiated instance) to see if the button has any onClick events.

honest stump
#

i was sick so i didnt work in the project untilnow

#

i will check it out asap

brazen pewter
#

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

austere grotto
tough moat
#

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

toxic lintel
#

I remember having issues with the DS4 in the past but now it just works

vague wedge
#

Is is possible to add a deadzone to a touch/pointer input so that small changes don’t cause an input?

austere grotto
#

Are we talking about an onscreen stick or something?

vague wedge
#

just touching the screen

#

touching and dragging from point a to point b

austere grotto
vague wedge
#

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)

vague wedge
#

the one that sends CallbackContext

austere grotto
#

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

austere grotto
#

not really directly useful for a deadzone thing

vague wedge
fierce compass
#

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?

vague wedge
#

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

austere grotto
#

You could do this with an invisible onscreen stick probably

vague wedge
#

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

austere grotto
#

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

radiant mauve
#

doesn't know the difference

vague wedge
#

that's why you add a deadzone

#

if the drag is too small, ignore it

fierce compass
#

(though tbh i tend to use rolling to get small positioning shifts sometimes lol)

radiant mauve
#

that's what I'm saying

untold valve
#
    {
        // 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
grizzled slate
#

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

grizzled slate
#

yes i wasnt getting a reply and there were ppl active on that chat so i posted there

#

ill keep in mind

proper jungle
#

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

vague wedge
#

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

gilded pelican
#

hi, i was following the beginner coding tutorial on unity learn, but that still uses the old input manager. how different are the two?

timber robin
#

Very 🙆

gilded pelican
#

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?

timber robin
#

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.

silent shadow
# silent shadow Hello ! I have a big problem with unity's input system. It doesn't register whe...

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 ?

radiant mauve
radiant mauve
silent shadow
#

I have not set any InputActionMap. I am using the Gamepad.current

radiant mauve
#

oh i see

#

the reason you're seeing values over 1 is because of trig

silent shadow
#

but with a different controller it does not..

radiant mauve
#

uno momento

silent shadow
#

so the range of the nintendoswitch controller's stick is more limited than another controller..

radiant mauve
#

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

silent shadow
radiant mauve
#

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

silent shadow
#

UnityChanThink 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 UnityChanSalute

radiant mauve
#

nah you just can't rely on raw values like that

silent shadow
#

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..

radiant mauve
#

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?

silent shadow
#

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?)

radiant mauve
#

okay still waiting to see how it's setup lol

silent shadow
#

ah give me a min

radiant mauve
#

gotta work with me here lol i need infoz

silent shadow
#

sorry I thought the old screnshot where enough

radiant mauve
#

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

silent shadow
#

and the project setting part :

#

creating the settings asset does not fix or change anything, I tried

radiant mauve
#

can you add deadzone and normalization processors

#

and see what that does

radiant mauve
#

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

silent shadow
radiant mauve
#

something like this

silent shadow
radiant mauve
#

yeah

#

see what that does

silent shadow
#

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.

radiant mauve
#

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

silent shadow
#

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)

radiant mauve
#

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

silent shadow
#

yes I did : that's why I showed the Awake() part

#

It is created on the root of the asset folder :

radiant mauve
#

what happens if you hook into the actual input action event and read the value there?

silent shadow
#

you mean doing the .performed ?

radiant mauve
#

yeah subscribing to the event

silent shadow
#

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 :

radiant mauve
#

do you have the action on the appropriate control scheme

#

you should see it when you select gamepad in the dropdown

silent shadow
#

I have changed : but same result..

#

UnityChanFrustrated I can't beleive the Input debugger does display the correct value but somehow I can't have them..

radiant mauve
#

did you save the asset

#

you can also remove the processors that was just checking something

silent shadow
#

yeah that's why I take so long.. saving asset and waiting for unity to finish loading

radiant mauve
#

are you actually receiving the events when you push left

silent shadow
radiant mauve
#

not what im asking

#

the event you subscribed to. log when it fires

silent shadow
#

sorry I posted it too late, give me 5sec

radiant mauve
#

oh np

silent shadow
#

it act as if the input was canceled

radiant mauve
radiant mauve
#

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

silent shadow
#

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.

radiant mauve
#

as you go from left to up-left or what?

#

take of the normalization processor

silent shadow
#

upleft is the problem, from where I go to upleft is irrelavent (I did checked rn don't worry)

radiant mauve
#

you said it acts as if it was let go

#

let go after what

silent shadow
#

as if my thumb did left the stick

#

while my thumb did not leave the stick, it still push the stick

radiant mauve
#

i don't understand

#

does it act as if you let go or does it act like you never pushed it

silent shadow
#

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

radiant mauve
#

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

silent shadow
#

yeah it does that, when I move it to the top left it return 0

radiant mauve
#

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

silent shadow
#

you can do that ?

radiant mauve
#

its just a scriptable object basically

#

all scriptable objects are json files

silent shadow
#

ah

radiant mauve
#

open it in a text editor you'll see

silent shadow
#

I removed the gamepad checkbox for the leftStick and added it to each input of the 2Dvector :

radiant mauve
#

kk

#

lemme know what they show. should show 0-1 values for each

silent shadow
#

running the game like this I have this result :

radiant mauve
#

that looks correct no?

silent shadow
#

I have no longer the upleft problem with that setup it seem UnityChanThumbsUp 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

radiant mauve
#

do you still have the deadzone set

silent shadow
#

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 :

radiant mauve
#

that's what digital input does. change it to analog

silent shadow
#

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 UnityChanOkay

#

I guess I can't do anything for the second issue if even unity's input debugger miss that...

radiant mauve
#

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

silent shadow
#

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

radiant mauve
#

it's not debugging incorrect values

#

you're specifically trying to accommodate the switch pro controller yeah?

silent shadow
#

for now yeah, since it's a widely common use controller I wish it could work

#

oh

radiant mauve
#

Add a control scheme. call it switch pro or whatever

#

add swtich pro controller

#

now under move, add binding

#

give that a shot

silent shadow
#

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 UnityChanThink

radiant mauve
#

what missing range

silent shadow
#

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 :

radiant mauve
#

so you want to UNDO the correct value?

#

there's no missing range. it's normalized

silent shadow
#

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

radiant mauve
#

surplus value?

#

you're saying words that don't make sense

silent shadow
#

I know it's so hard to describe.. wait 2 sec

radiant mauve
#

there's no surplus input. it's not coupon day KEKW

silent shadow
#

you'll get what I mean in a sec

radiant mauve
#

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

silent shadow
#

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

radiant mauve
#

yeah you're doing it wrong if you're just checking magnitude

#

that's what i'm saying

silent shadow
#

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

radiant mauve
#

its. not. unused

#

i don't know how else to explain it lol

#

it's not surplus or unused. it's processed

silent shadow
#

it's missing a big part of the stick

radiant mauve
#

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

silent shadow
#

I set it to 1, and setting it to 1.4 did not solve that issue..

radiant mauve
#

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

silent shadow
radiant mauve
#

i thought we were testing just adding the switch pro left stick as an input

silent shadow
#

the same problem as before happened. so I made it into a 2D vector again

radiant mauve
#

WHAT SAME PROBLEM jfc

silent shadow
#

the problem where upleft didn't worked

radiant mauve
#

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

silent shadow
#

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

radiant mauve
#

kk. so what are you seeing with this

silent shadow
#

I'm generating a c#class and creating a monobehaviour to create the event .perfomed and .cancelled

radiant mauve
#

(keep in mind i just want to see what the baseline for this is, likely it's not what you want right now)

silent shadow
#

the same problem of the up left part of the stick not responding happen :

radiant mauve
#

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?

silent shadow
silent shadow
radiant mauve
#

if you add a normalization processor to it, it works tho?

#

(yes i know this will force the values to 0 or 1)

silent shadow
#

It did not force to a 0 or 1 ? I did double checked and saved the asset..

radiant mauve
#

remove normalize. try inverting it just for funsies. see if it flips the quadrant where you're having the issue

silent shadow
#

It did inverted the value, but not the problem, it's still upLeft

radiant mauve
#

yeah idk. controller issue or something. makes no sense

#

happens on left and right stick?

silent shadow
#

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

radiant mauve
#

what if you're only displaying the performed logs and not the canceled logs

#

or better yet debug drawing

silent shadow
#

the performed logs just stop happening..

radiant mauve
#

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

silent shadow
#

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

still blade
#

Do I need another input actions map to navigate pause screen?

austere grotto
#

You don't generally need to do anything to set it up

still blade
#

Ig this is more #📲┃ui-ux talk so let's move to there if you can

livid glade
#

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] 
quasi chasm
livid glade
fierce compass
#

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?

austere grotto
toxic lintel
#

But I settled on using strings and filling it automatically

toxic lintel
toxic lintel
#

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.

azure void
azure void
#

yup, that's the one UnityChanThumbsUp

fierce compass
graceful ore
#

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.

honest stump
#

is there a way to create on-screen button with modifiers inbued?

loud light
#

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)

spice wadi
#

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

mellow berry
#

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

mellow berry
lilac hawk
#

onjumpcanceled is not being called automatically
is there something wrong with the setup
behaviour of player input component is set to send message

fierce compass
#

@lilac hawk that's not what i said to do

lilac hawk
#

can you please tell me what i did wrong, i will try again after fixing

fierce compass
#

with Press & Release, OnJump will be called for both the press and the release, just that it'll have isPressed at different values

lilac hawk
#

so what should i do

fierce compass
#

check isPressed

#

did you read my message at all lmao

lilac hawk
#

i am checking it in OnJump()
am supposed to check in in OnJumpCanceled as well

#

oh i got it

meager ginkgo
#

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?

austere grotto
#

So I would not expect any kind of consistent abstraction between them

#

Stick to one input system or the other

meager ginkgo
#

Yeah I'm using the new one. Thanks, I'll just use only the Touchscreen class.

solemn tapir
#

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?

fierce compass
#

@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

#

so you can go down that path:
TouchScreen.primaryTouch (Manual, Docs) is a TouchControl
TouchControl.press (Manual, Docs) is a TouchPressControl, which inherits ButtonControl

limpid jolt
#

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?

fierce compass
#

what do you mean by "via a node"?

#

oh are you using visual scripting?

limpid jolt
#

this one here

#

Yea, I'm coming from a fullstack webdev background but I wanted to try unity using the visual scripting route once

fierce compass
#

ah, haven't touched unity's visual scripting before...

limpid jolt
#

However I feel like visual scripting is more complicated than just writing a C# script lol

fierce compass
#

what's the goal right now exactly?

limpid jolt
#

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)

fierce compass
#

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)

limpid jolt
#

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

austere grotto
#

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

hasty yoke
#

Helpppp!!!! WTF is going on???? I make a new action and this happens???

#

i dont have and OnPause member

tulip tartan
#

Duplicated the Action asset?

hasty yoke
#

youre right tysm but how did this happen? i just mad a new action and it makes a whole new script?

austere grotto
livid glade
#

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.

austere grotto
#

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

livid glade
#

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

austere grotto
#

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

livid glade
#

how do you poll it in update? I thought the new input system was completely event based.

austere grotto
#

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>();```
livid glade
#

ah okay thanks let me try doing it that way

fierce compass
#

you can also poll on the device directly, Mouse.current

brave shore
#

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?

halcyon jolt
#
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.
halcyon jolt
#

nevermind, i decided to try another method

fierce compass
halcyon jolt
#

i had put it in the public void move function

fierce compass
#

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

past isle
#

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

torpid schooner
#

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

austere grotto
#

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

torpid schooner
# austere grotto You haven't shown the full code involved nor the action setup

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
}
austere grotto
#

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

torpid schooner
austere grotto
torpid schooner
austere grotto
#

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

torpid schooner
#

oh okay

austere grotto
#

You can check in project settings - Input System

torpid schooner
austere grotto
torpid schooner
austere grotto
torpid schooner
#

okay i did it but it didnt fix the jumping

austere grotto
formal blade
#

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

fierce compass
#

make sure it's typed correctly, make sure you see an OnJump in the playerinput

formal blade
#

Its all there and typed correctly

fierce compass
#

do you even need the inputvalue though?

formal blade
#

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

fierce compass
#

could you show the playerinput component

formal blade
#

Ill get back to my pc soon, then I can

#

But I didnt change anything on it from the defaults

torpid schooner
# austere grotto Show code
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
}
torpid schooner
#

im moving the mouse at the same speed btw

fierce compass
torpid schooner
#

i always use obs but i just wanted to show it in slow motion

fierce compass
#

they're far easier to look at

#

you can make screen recordings slow motion too

torpid schooner
#

my pc would crash if it had more than 60 frames set in obs

fierce compass
#

you can just slow the mp4 down after the fact

torpid schooner
#

it wouldn't give the same effect tho

fierce compass
#

oh i see what you're saying

#

that's.. unfortunate

#

(doesn't windows let you do recordings natively without third-party apps though)

torpid schooner
#

tried it but it's even worse than obs

fierce compass
#

rip

torpid schooner
#

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

fierce compass
#

you sure this is due to frame rate? what about like, mouse acceleration?

torpid schooner
#

i have it turned off afaik

#

also, wouldn't unity use raw mouse inputs?

vale barn
torpid schooner
vale barn
#

try enabling vsync in game view

torpid schooner
#

yup this works

#

but im more concerned if it would work on other pcs in build

wheat charm
#

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

dapper spear
#

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 ?

austere grotto
dapper spear
#

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 ?

austere grotto
#

you can do that with IDragHandler

dapper spear
#

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

austere grotto
#

Yes something like that but in the DragHandler callback

#

Not using the input system directly

dapper spear
#

alr i'll give it a try

dapper spear
#

this could works, but it doesnt appeal to me, i keep this in mind tho
want the ui controls groupped atm

wheat charm
#

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

real prairie
wheat charm
haughty fractal
#

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

latent juniper
#

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

austere grotto
#

THsoe versions are a bit out of date though - I would try updating your Unity and input system versions

latent juniper
#

also tried debugging if it would get the raw input or not and it doesn't even get the input

latent juniper
latent juniper
#

first time I am ever using Input Debug but im not sure why there are 2 users in this case

austere grotto
#

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

latent juniper
#

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?

austere grotto
latent juniper
latent juniper
austere grotto
#

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

onyx sandal
#

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

austere grotto
#

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

onyx sandal
#

Yeah, there it is, thank you

haughty fractal
oblique raven
#

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;

fierce compass
#

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

oblique raven
#

let me rephrase it sry

#

so this actually works as it shoudl be

fierce compass
#

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)

oblique raven
#

ok so i am able to get the vector2 just need to normalize it somehow ( the float)

fierce compass
#

normalizing real numbers is called absolute

#

(why though? doesn't GetAxis also give negative values depending on the direction?)

oblique raven
#

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

fierce compass
#
  • is it perhaps just giving them in different spaces?
  • the inputmanager seems to specify Sensitivity: 0.1 for the mouse deltas, that might be related
  • GetAxis has 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

oblique raven
#

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);
fierce compass
#

you're telling me GetAxis("MouseX") isn't a delta?

#

that doesn't really make sense...

oblique raven
#

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

fierce compass
#

yeah but an equivalent to Input.GetAxisRaw("MouseX") would just be Mouse.current.delta.ReadValue().x, afaik

oblique raven
#

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

fierce compass
fierce compass
oblique raven
#

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

fierce compass
#

no, that's not what i'm talking about at all

oblique raven
#

so what are you talking about then, sorry if i missed that one

fierce compass
#

a direction is not the same as a delta

#

normalizing a delta gets you a direction

fierce compass
oblique raven
#

thanks

soft rune
#

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

fierce compass
soft rune
austere grotto
#

Or .WasPressedThisFrame() depending on what you want

austere grotto
#

Do you mean "LMB" though?

#

Left mouse button?

soft rune
soft rune
#

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

austere grotto
#

Or also shoot?

soft rune
austere grotto
#

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

soft rune
#

new action i mean

#

thanks

still burrow
#

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;
}
fierce compass
#

if not, with playerinput set to sendmessages, it'll only tell you about the press

soft rune
#

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)

fierce compass
#

transform.position is a worldpoint, you need to convert that to viewport space

#

this is also definitely not the right channel

soft rune
#

wrong channel sry

still burrow
fierce compass
#

yeah, that should be right

formal blade
#

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;
    }
}
austere grotto
vital yoke
#

What is the general consensus on the new vs old input system? Which is preferred for mid to small scale projects?

austere grotto
#

As far as I'm concerned the old system is only useful if you're not ready to learn the new one yet

formal blade
#

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

austere grotto
#

But also what do you mean by "enabling an input"?

#

Sorry nevermind I realized I mistook this conversation for another

formal blade
#

like you'd have to do

private void OnEnable() {
  someInput.action.Enable()
  
  someInput.action.started += callback;
  someInput.action.performed += callback;
  someInput.action.canceled += callback;
}
austere grotto
#

I think the problem here is that sometimes you want to subscribe to all three but sometimes you don't

formal blade
#

oh no worries

austere grotto
#

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

formal blade
#

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();
}
austere grotto
#

Yeah, I mean there's nothing wrong with it per se, so long as you understand the tradeoffs

formal blade
#

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

fathom wraith
#

yo how do I get the device tilt like device tilt on mobile or something that can be tilted

thorn pulsar
#

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??

austere grotto
#

Control schemes are for local multiplayer. Your game is correctly assigning different input devices to different players.

thorn pulsar
austere grotto
#

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

thorn pulsar
#

But how else would i have local multiplayer?

toxic lintel
#

Typically UI doesn't behave the same when you're using a gamepad

austere grotto
austere grotto
thorn pulsar
#

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

austere grotto
#

Or at least it will when you press the join action you set up

#

And each device will control a different player

thorn pulsar
#

Yeah that happens already

#

It’s just that when I connect on keyboard, the move input doesn’t work, the other inputs work fine

austere grotto
#

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?

little slate
buoyant chasm
#

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.

uncut yacht
buoyant chasm
austere grotto
buoyant chasm
buoyant chasm
#

lol... pretty straightforward

#

when I debug.log at this point, it's only called on one frame

austere grotto
#

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

buoyant chasm
#

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

austere grotto
#

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

buoyant chasm
#

I will check again with debug statements, just to be extra sure

buoyant chasm
#

can confirm that the code is only being called once

austere grotto
buoyant chasm
#

ok yeah would love someone to confirm if that's the case for them on mac

steep idol
#

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

austere grotto
steep idol
#

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

austere grotto
#

Yes you would do something along those lines, certainly.

steep idol
#

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

austere grotto
#

The input system does not do anything on a per frame basis

steep idol
#

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

austere grotto
steep idol
#

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?

austere grotto
steep idol
#

yeah that makes sense

#

thank you

ornate star
#

Can we use new input system with UI buttons?

oblique raven
#

of course you can

ornate star
icy wind
#

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!

austere grotto
#

Well it's not a one way door

#

You can do both

#

Just start with the one you want more

meager ginkgo
#

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.

vocal swallow
#

how do i add scroll wheel input to the new input system

austere grotto
#

Just add it as a binding on whatever action you want

vocal swallow
#

which one is it

austere grotto
#

Mouse ScrollWheel

#

Make sure you configured your action as an axis first

#

Looks like this is probably a button action

vocal swallow
austere grotto
#

Well that's not correct for ScrollWheel now is it

vocal swallow
#

im not sure

#

what action type do i use for scroll wheel

austere grotto
#

I'll tell you, it isn't

#

I just said, it needs to be an axis

#

Might be Action Type: Value. Control type: Axis

vocal swallow
#

yeah thats the one thanks

#

yep works wonderfully thanks a lot

#

so is this the only way to set up button and value input

austere grotto
#

There are many other ways to do things.

vocal swallow
#

cool

shell heart
#

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

ornate star
#

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);
    }
}
brazen crescent
ornate star
austere grotto
#

So no UI interaction will work at the moment

lost moon
#

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

austere grotto
#

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

lost moon
austere grotto
#

if you really want that

#

but I wouldn't recommend it