#🖱️┃input-system

1 messages · Page 27 of 1

stiff sand
#

Can anyone help me with this? The joystick is configured (I think) but the movement is awful, as seen in video

supple crow
#

How are you receiving input in your scripts?

stiff sand
#

this is the part of the code that handles the movement

#

void Update()
{
Vector2 moveDirection = _moveActionToUse.action.ReadValue<Vector2>();
Debug.Log("Move Direction = " + moveDirection);
transform.Translate(moveDirection * 7 * Time.deltaTime);

supple crow
#

That seems okay

stiff sand
#

[SerializeField] private InputActionReference _moveActionToUse;

#

initialized on top of the script

supple crow
#

So you've got an on-screen joystick there?

stiff sand
#

yes\

supple crow
#

I'd log moveDirection just to make sure the values are bad

stiff sand
supple crow
#

I've never used the on-screen stick before, so I'm not sure what I'd poke at first

stiff sand
#

they seem fine

supple crow
#

note that Collapse is on

#

so duplicate log entries will be hidden

#

that could be hiding a bunch of bogus values

austere grotto
stiff sand
austere grotto
#

!code

sonic sageBOT
austere grotto
#

use a paste site^

stiff sand
#

note that the game was originally made for PC, now I'm just adding minor tweaks to make it ready for android

austere grotto
#

I would expect to see that in e.g. OnEnable or Start

#

There's also this code:

    public void OnMoveX(InputAction.CallbackContext ctxt)
    {
        if (dialog || Time.timeScale == 0)
        {
            // If in dialogue or game is paused, set movement to zero
            MoveDir.x = 0;
        }
        else if (Time.timeScale > 0)
        {
            hasmoved = true;
            // If not in dialogue and time is not paused, read input
            Vector2 input = ctxt.ReadValue<Vector2>().normalized;
            MoveDir.x = input.x;
        }
    }

    public void OnMoveY(InputAction.CallbackContext ctxt)
    {
        if (dialog || Time.timeScale == 0)
        {
            // If in dialogue or game is paused, set movement to zero
            MoveDir.y = 0;
        }
        else if (Time.timeScale > 0)
        {
            hasmoved = true;
            // If not in dialogue and time is not paused, read input
            Vector2 input = ctxt.ReadValue<Vector2>().normalized;
            MoveDir.y = input.y;
        }
    }```
#

What's that about?

#

Seems like you have the remnants of some older movement code in here?

stiff sand
#

yes, didn't I comment this?

#

apparently not

#

.Enable is not working

supple crow
#

You need to enable the action

#

not the action reference

#

praetor was missing the .action field there

stiff sand
austere grotto
#

oh yeah my bad - .action.Enable()

#

but yeah it doesn't make sense that would be the problem

stiff sand
#

I think I fixed it by borrowing the joystick from an older game, despite being with the old input system

#

ok now nothing works anymore

#

it only works when I put both here

#

but it gives me a warning when building for android

supple crow
#

are you even using the new input system at all now?

stiff sand
#

I can't even press buttons

#

so this means I use it?

austere grotto
supple crow
#

nothing more, nothing less

stiff sand
austere grotto
stiff sand
#

but now I can delete them as I have the PC project separately

stiff sand
austere grotto
#

The whole point is that you DON'T need to change anything with your input setup

#

you could have continued using your old code just fine

stiff sand
#

smartphones don't have keys?

austere grotto
#

the only thing you needed to change was to add the path for the on screen joystick to the input actions as bindings

#

You could even have had the on screen stick directly feed into the keyboard keys

#

and not changed anything at all

austere grotto
# stiff sand

You see here - you could have just added the left stick bindings to MoveUp and MoveRight actions

#

and changed absolutely nothing else, and it would have worked

stiff sand
#

how would that work?

austere grotto
#

What do you mean? That's how it works

#

the on screen joystick pretends to be whatever control path you give it

stiff sand
#

the joystick controls a vector 2

austere grotto
#

Yes - and feeds it into a control path

#

show the inspector for your OnScreenStick component

stiff sand
austere grotto
#

No, this ^

stiff sand
#

moveUp and MoveRight correspond to the OnMoveX and Y

austere grotto
#

see how it says "left stick"

austere grotto
#

and that was working on keyboard right?

#

or on pc

stiff sand
#

yes

austere grotto
#

or whatever you have it set up with

#

all you had to do was add bindings to the MoveUp and MoveRight actions

#

to use the control that the stick feeds into

#

that's the point of on screen stick working this way - so you don't have to change anything

stiff sand
#

sorry, I still don't understand how

austere grotto
#

What part are you missing

stiff sand
#

I mean, by moving the joystick I'm creating a Vector2

#

correct?

austere grotto
#

Look at this

stiff sand
#

ok

austere grotto
#

the stick feeds data into the "Left Stick [GamePad]" control

austere grotto
#

If you add a binding to your input action that reads from Left Stick [GamePad], it will read data from the on screen joystick therefore

austere grotto
# stiff sand

you could have just created secondary bindings for MoveUp that read from Left Stick [Gamepad]

#

and it would have worked fine

#

You could have made composites just like you did for AD and WS to bind them e.g. to Left Stick[Gamepad] Left and Right and Up and Down

stiff sand
austere grotto
#

On screen stick -> Left Stick [Gamepad] -> your MoveUp action -> to the PlayerInput component -> to call OnMoveY

stiff sand
#

you mean here, instead of the keys, to just replace with the gamepad?

austere grotto
#

not even replace

#

click on MoveUp

#

add a new binding

#

and set up the Left Stick stuff

#

you can keep both

stiff sand
#

and that's it?

austere grotto
#

that's it

#

yes

#

you didn't need to change any code

stiff sand
#

holy hell it actually works

#

thank you

#

now I feel dumb

#

it's usually like this, an extremely simple solution to a difficult problem

austere grotto
#

Eh - the input system can be confusing. But it's very flexible and pretty powerful as you can see - once you get the hang of it.

stiff sand
#

now I just need to figure out why the bounderies don't exist anymore

austere grotto
#

do you still have the input action reference code sitting around?

#

That should get removed.

stiff sand
#

commented

supple crow
#

oh, so it really is that simple! I hadn't done an on-screen joystick before

#

that's how I imagined it working

#

just providing input for a binding

austere grotto
#

Yeah it's actually quite well designed

#

the one issue I have with it is that you need to map it to some existing control - for example keyboard keys or joystick sticks, rather than just creating e.g. a virtual control for it or something

#

there can be weirdness with that

lone drift
#

Audio input (microphone frequency)

wintry wind
#

Hi, I'm having an issue with multiple ActionMaps being enabled at the same time when I don't want them to be. I'm a returning hobbyist and new to this InputSystem so I'm sure I'm just misunderstanding something but I've had no luck debugging this on my own or searching for related questions so far.

I have a very basic scene; camera, light, and some 3d objects. I have a PlayerInput component on my "player" object which references the InputActionsAsset that came with the Project. This came with two ActionMaps, Player and UI. I have added a 3rd called Throwing.

In a script that's also on my player object, I grab a reference to the PlayerInput component and log whether each ActionMap is enabled or not. I have done this in Awake(), Start(), and even Update() but every time all ActionMaps are enabled. If I grab the PlayerInput in Awake() and specifically disable the Throwing ActionMap, it will show as disabled in the Start() method. However, something is re-enabling it as I still get events from Actions defined in it.

#

For example if I remove all code references to the InputSystem from my scripts except for the following,

    // Update is called once per frame
    void Update()
    {
        if (_input == null)
        {
            _input = GetComponent<PlayerInput>();
            Debug.Log($"CurrentActionMap {_input.currentActionMap}");
            Debug.Log($"Player isEnabled {_input.actions.FindActionMap("Player").enabled}");
            Debug.Log($"UI isEnabled {_input.actions.FindActionMap("UI").enabled}");
            Debug.Log($"Throwing isEnabled {_input.actions.FindActionMap("Throwing").enabled}");

            _input.actions.FindActionMap("Throwing").Disable();
            Debug.Log($"Throwing isEnabled {_input.actions.FindActionMap("Throwing").enabled}");

            _input.actions["Toggle"].performed += ProcessToggle;
        }
    }

    void ProcessToggle(InputAction.CallbackContext ctx)
    {
        Debug.Log($"ProcessToggle Called, ActionMap.Throwing.enabled={ctx.action.actionMap.enabled}, ctx={ctx.ToString()}");
    }

Then I still get the following logs

CurrentActionMap InputSystem_Actions (UnityEngine.InputSystem.InputActionAsset):Player
Player isEnabled True
UI isEnabled True
Throwing isEnabled True
Throwing isEnabled False
ProcessToggle Called, ActionMap.Throwing.enabled=True, ctx={ action=Throwing/Toggle[/Keyboard/tab] phase=Performed time=9.55633420000049 control=Key:/Keyboard/tab value=1 interaction= }
#

At this point I'm at a loss. My expectation was that only one ActionMap would be enabled at a time and that I could switch back and forth between them with PlayerInput.SwitchCurrentActionMap and I would not receive events or be able to read inputs for Actions defined in a disabled ActionMap. I have no other InputSystem related components on any GameObjects and in the current iteration the only code that touches the InputSystem is the snippet above. I've made sure to save everything, the scene, the InputActionAsset, my code, etc so nothing should be stale. I'm not sure what I'm missing, any advice?

austere grotto
wintry wind
#

sure, one sec

#

The only things I've touched on this was passing in the InputActionAsset and disabling autoswitch in an attempt to debug the issue

wintry wind
#

Just to follow up on my issue above, I tried creating a new InputActionAsset with two ActionMaps and a single Action in each. Disabled my existing Player, created a fresh GameObject, added a PlayerInput component, linked this new InputActionAsset, and added a new Script which is the same as my Snippet above except I register a callback for each of the two Actions across the two ActionMaps and I didn't call Disable on the map.

After all that, it works as expected. Only the ActionMap marked as Default in the PlayerInput component was enabled and only inputs from the enabled ActionMap were firing events.

I then linked my initial InputActionAsset from earlier to this test script and updated the map/action names but otherwise changed nothing else and I was able to reproduce the issue.

So it seems like whatever is causing all ActionMaps to be enabled is specific to this InputActionAsset, tho I have no idea what it is. But I'm unblocked for now at least

supple crow
#

Is it assigned as your project-wide action asset? I bet all of its maps get turned on automatically

#

That's in the input system section of your project settings

wintry wind
#

Ah that sounds plausible. I'll check when I'm back home. Thanks for the suggestion

void flicker
#

is there a way for player to edit keybinds ingame with the input system?

wintry wind
void flicker
vagrant panther
#

I am trying to setup a Dodge Input that would work by Double Tapping the Direction you want to dodge in. I can set up a double tap if the type is button, but this case would be Vector2, so i can't so the same. is there another way, or am i just missing something?

fierce compass
#

what about controller input?

vagrant panther
#

are you asking me? if so, i am not terribly worried about controllers ATM

neon cedar
vagrant panther
neon cedar
#

None I'm aware of but maybe someone more knowledgeable will correct us

crystal narwhal
#

good morning, learning everything about the new input system, long time wainting for this... i have something working, keyboard, gamepad, touch etc... why i should create a scheme ? its recommended? or only for games with alof of inputs?

#

right now for example my supports on screen touch joystick and also gamepad, when i create gamepad schemecontrol my inputs from keyboard are not longer working also if i made a build touch joystick either, so i have to change the activated control scheme?

austere grotto
uneven timber
#

Hello friends!

#

I'm using Input system v1.11.2

#

Whenever I try to add a device, I get the error: StackOverflowException
Looking at the call stack I see the repeated function call is named InsertControlBitRangeNode, deep within the internals of the Input System. None of this seems to be my code

#

The documentation does not help me solve this issue - all that I can find is that it appears this bug was fixed.... in 1.5 or so, something like 6 versions ago

#

it goes on and on and on. How can I fix this? 🙂

#

None of my code seems to be involved, it comes from NativeInputSystem:NotifyDeviceDiscovered so it seems like that's Unity all the way

muted folio
#

Hey guys,
I wanted to ask for some ideas/suggestions regarding how to design the following input system:
I have a lot of player characters.
They all share some common input actions like movement, jump etc.
But each character also has unique abilities.
Now I need a system, where it's possible to customize the key bindings of the general input actions for every character.
But at the same time it should be possible to customize the input actions (general and unique abilities) for every single character if youd like.
How would you design the InputActions asset for this use case etc.?

Thank you

supple crow
#

I have something similar in my game: each character's "abilities" are entirely provided by the modules attached to them.

I tried to cluster them into groups, like "use" or "hurt", but I wound up with tons of confusing overlap anyway

#

right now I'm band-aid fixing this with a radial menu to pick an ability

lilac bloom
#

ok here's a dumb question, how on earth do you delete a binding or action in the Input Action Editor?? I'm trying to delete this second E [Keyboard] binding but right clicking it or pressing delete isn't doing anything.

#

hmm, seems like I had to run the below in code. Seems a bit strange but worked
GetComponent<PlayerInput>().actions["Mouse_RightSpecial"].ChangeBinding(1).Erase();

supple crow
#

i would restart the editor if it was misbehaving like that

crisp egret
#

Or you could try scolding it.

supple crow
#

i do yell at my computer from time to time

glass ginkgo
#

I've been working on this for hours...

fierce compass
# glass ginkgo

there's 2 number keys on keyboards. according to the scripting docs they're digit[N] for the numrow and numpad[N] for the numpad
maybe try those? ie, <Keyboard>/digit1, etc

glass ginkgo
fierce compass
#

oh SwapWeapons isn't called at all?

glass ginkgo
#

Yup

#

I clicked the numbers, and the function didn't even occur

fierce compass
#

have you tried using the input debugger to see if the input is registering?

glass ginkgo
#

Oh, I have no idea what that is

#

Can you guide me through?

fierce compass
#

one sec i don't remember where exactly it is

#

there should be a button "open input debugger" at the bottom of PlayerInput

glass ginkgo
#

Right. Thanks!

fierce compass
#

0 = numrow, numpad0 = numpad

glass ginkgo
#

Okay, I found the solution. Thank you for helping me out!

devout canyon
#

hi everyone - Can somebody help me to get xr input to work with the new input system? - When I put on my headset (quest2) I can see in the inputs chaning in the "Open Input Debugger" Window! ( i see there that isGripPressed switched to 1 when fully pressing the grip) and so on.

But any actions I assign any of the XR stuff to are not triggered ever. (If I assign keys they trigger no problem).

My scene has the XR Interaction Manager added and a "XR Origin (VR)" - I can look around my scene no problem.

See Image, all the bindings I added do not work - except for mouse and keyboard. (none have checkmarks for a control sceme). Default Scheme is set to any on the Player Input.

fossil spindle
#

Left click works fine on my mouse but only seems to trigger like 1/10 times on my laptop's touchpad left click
What's the right binding or setting for this to work accurately?

austere grotto
#

Also what - if any - processors or interactions are on the Interact action?

fossil spindle
#

Nothing set like that
I haven't had issues getting left click to resister on my laptop regularly either btw

[SerializeField] PlayerTrigger playerTrigger;
[SerializeField] TrashPicker trashPicker;

public void OnInteract(InputAction.CallbackContext context) {
    if (context.performed) {
        //oldPlayerTrigger.SphCast();
        playerTrigger.TriggeredInteractable();

        trashPicker.TrashInteract();
    }
}
austere grotto
#

this would help us make sure it's actually an input system problem and not a problem in the other code being invoked here

fossil spindle
#

The debug messages actually stop triggering when I'm using WASD movement + touchpad left click, maybe it is hardware

devout canyon
austere grotto
fresh galleon
#

Hi, I'm trying to create a simple extension to the default Button, where holding it re-sends the OnClick event every x seconds. Detecting holding the button with a mouse is easy thanks to the IPointerUpHandler, but I can't for the love of god mirror that behavior for keyboard button button presses. There's only the ISubmitHandler, and ICancel and IDrop handlers arent it.

#

Is there a way to detect the "un-pressing" of the submit button similar to IPointerUpHandler?

#

I guess I could check each frame if the button used in OnSubmit is still pressed, somehow?

austere grotto
#

then basically have a script that is listening for that key being released and sending the message

fresh galleon
#

I hear you, the tricky part right now is getting to the current inputsystem's UI action map (???) to get the assigned button to listen to it, unless it's simpler than that

#

I need to somehow query for a specific key based on the action and I dont want it to be that hard-coded

fresh galleon
#

I'm trying really hard to connect the dots here but I still don't quite see it. Does this mean that there should be some static-level access Submit keybind variable, that I could query?

#

Or you mean I could somehow create an additional interface, opposite of ISubmitHandler (IUnsubmitHandler?) that would do exactly what it says

austere grotto
#

i.e. myInputModule.submit.action.canceled += MyCanceledListener;

austere grotto
#

but you don't need to necessarily do it that way

#

as it's a little overcomplicated/overkill I think

fresh galleon
#

ahh, but I would still need to find a reference to the module in the scene, no way to get it statically

austere grotto
supple crow
#

the current input module is available from EventSystem.currentInputModule; you'd need to downcast it to the specific type, of course

austere grotto
#

oh

#

that's even better

fresh galleon
#

ok I think I cooked now

((InputSystemUIInputModule)EventSystem.current.currentInputModule).submit.action.performed+=<eventhere>
austere grotto
#

since you want when it's released

fresh galleon
#

I mean yeah, but the idea is here

#

Thank you, I did not expect it to actually work lmao

#

oh and it does and it does perfectly well, very nice thanks again all

turbid rock
#

First time going from PlayerInput SendMessages mode to generated c# class.. How would you guys organize your input classes / send actions?
I was thinking singleton to this class with the action map asset then other scripts can sub to whatever events they need, maybe class can just handle all the events but then I feel like I'm just rewriting what the action asset does already..
I just added all 3 actions as test but might need scripts where they need either canceled or started/performed.
I'd appreciate any Input :p ..

public class PlayerInputsProcessor : MonoBehaviour
{
    //my c# class generated from inputaction asset
    private InputSystem_Actions actions;
    private void Awake()
    {
        actions = new();
    }
    private void OnEnable()
    {
        actions.Enable();
        actions.Player.Attack.started += OnAttackStarted;
        actions.Player.Attack.performed += OnAttackPerformed;
        actions.Player.Attack.canceled += OnAttackCanceled;
    }```
austere grotto
#

Like you said you don't want to duplicate what the action asset already does

#

just providing central management and access to the instance is all you really need

#

And it's best to only have one instance so that rebinding and action map enabling/disabling works globally

turbid rock
#

okay good this clears up some confusion, I appreciate it !

sinful siren
#

HI, I need help

I have several types of input for my game: mouse click, spacebar, and touch screen for mobile devices. However, the issue is that my game now has UI buttons (like login, logout, and others), and I’m trying to find a way to prevent clicks on these buttons from triggering the game itself.

I found this solution everywhere:
EventSystem.current.IsPointerOverGameObject()

But the problem is that it breaks my game. I have a big tuto texte in the middle of the screen that says “Press Space or Tap the Screen”, and clicking on it prevents the game from triggering.

Do you have any ideas on how to solve this?

Thanks!

austere grotto
#

Actually for that one specific problem you can just disable "Raycast Target" on your big text thing

#

But the overall recommended would be to switch to the event system for all your clicking as stuff

analog junco
#

Hi, I just added the new input systems on Unity with following the quick start on the website of Unity.
The function they give to get the action is InputSystem.actions.FindAction(). But, is there not a better function to give also the action map where is the action we want to get ? Because, with the function they give, the system need to browse all the actions maps to find 1 action

dim cape
#

InvalidOperationException: Action 'UI/Cancel[/Keyboard/escape]' must be part of an InputActionAsset in order to be able to create an InputActionReference for it

Any clue why this error is triggering? I believe this started after updating unity from 2023 OR switching to linux.

next pike
#

Im having a very similar problem... the properties page is empty so I cannot configure bindings and I get this error every time I click it:

#

Ok looks like the bug is caused by having vjoy installed.. makes the package unusable

#

Uninstalling vjoy and restarting fixed it

austere grotto
austere grotto
dim cape
austere grotto
dim cape
#

Well I noticed that it was not set on project settings so I fixed that

#

but it still happens

#

How can I reset the module?

next pike
#

I can't interact with this UI with my mouse anymore, however they keyboard still works

gaunt pond
#

Hey, so in the Unity Input System, mouse movement is inherently frame-based (reset each frame), while controller input provides a time-independent vector (e.g., thumbstick position). Since the Input System bundles mouse and controller inputs together by default, how can I scale controller input by deltaTime without affecting mouse input? Is there a reason Unity bundles them, and should I separate the inputs instead?

verbal remnant
gaunt pond
#

I wonder why they are bundled together in the input system by default.

#

Since they are fundamentally incompatible.

verbal remnant
#

You can control input systems input poll rate entirely independent of frame updates btw

gaunt pond
#

How would that look here?

private void Update()
{
    CameraMovement();
} 

private void CameraMovement()
{
     Vector2 lookInput = InputManager.Look() * LookAroundSpeed;

    // Rotate player when looking left or right
    transform.Rotate(Vector3.up, lookInput.x);

    // Rotate camera when looking up and down while clamping the camera to not allow full rotation
    _verticalRotation -= lookInput.y;
    _verticalRotation = Mathf.Clamp(_verticalRotation, -maxVerticalAngle, maxVerticalAngle);
    _playerCamera.transform.localEulerAngles = new Vector3(_verticalRotation, 0f, 0f);
}
#

I guess I'll just separate the systems. Pretty weird that they're bundled by default, but oh well.

verbal dust
#

How can I change the starter asset control of my third person character to aligned with the camera, like W goes up, E goes down, etc., and stop rotating the player with the mouse?

azure void
#

!ask

sonic sageBOT
azure void
#

oh, wait that command doesn't mention code

#

anyway, can you send the code?

verbal dust
inner anchor
#

I'm trying to make a custom wrapper around the input manager. Is the input manager meant to be used as a singleton waiting for events on each component that needs it? Im a bit lost on this part

verbal remnant
inner anchor
#

InputSystem sorry

austere grotto
inner anchor
austere grotto
fresh galleon
#

Hey so uum, I wanted to abstract a minigame system to make each minigame a seperate scene, loaded at some great distance from the main scene/level, and rendered into a raw image inside a special panel. Got the rendering alright, even keyboard input works with the setSelectedGameObject.... but....

Mouse events are not properly registered, as the minigame sub-canvas is rendered in a completely different place and put through the RendererTexture. Any ideas on how I could easily have pointer events transfered via that render texture? Or perhaps I could "capture" those events and translate them through the offset to the actual minigame-scene

austere grotto
#

Why not just use culling masks?

fresh galleon
#

cause so far if I do not offset it it is influecned by the dark overlay of the "default" level scene and some of the elements are rendered over it still

#

as in like that

austere grotto
#

I don't really know what I'm looking at tbh

fresh galleon
#

this probably has to do with playing with the stencil shader, so it can somehow ignore the default order with UI rendered last

#

like I want each minigame to be a seperate scene, with its own canvas and a simple camera to render into a texture

#

to be used to fill this blank space when u interact with some object for example

#

thing is I need a seperate camera just for creating the rendertexture, and a simple texture cant really react to mouse input events, so that's where the problem is currently. If I could somehow capture the global position of a mouse down/up I could offset it by the constant of that rendering camera to perhaps re-enact them... not sure if that's even possible though

#

and yes, I kind-of need it to not cover the entire screen, and the game is not paused in the background while it is opened, so two cameras is a must

austere grotto
#

this isn't really an input system question. More #📲┃ui-ux and you're not the first person to do something like this

fresh galleon
#

well that's comforting, thanks!

austere grotto
#

And then when you have the localPoint you can use that in Camer.ViewportPointToRay for the secondary camera

supple crow
#

you need to get a very firm grasp on what your coordinate spaces are

#

ideally, you'll just move between them using Transform methods or by directly constructing a Matrix4x4

#

no method that involves things like "add an offset" or "switch X and Y around" will work reliably

marsh mulch
#

Sorry if this has been asked before, I tried searching using the search tool but couldn't find anything. I'm having an odd issue with my input module not working after a scene change. I have my EventSystem component on a DontDestroyOnLoad object, and opted to use my custom handling, so I've removed the default input module. Is this a bug?

#

disabling and enabling the input module fixes it, but I'm not sure where I should be implementing that. OnSceneLoaded seems to be entirely hit or miss.

austere grotto
#

Presumably some other code of yours is disabling it or something along those lines

marsh mulch
marsh mulch
marsh mulch
#

hmm can't seem to replicate it

#

im curious if it has to do something with how this network library im using is handling scene transitions

#

cause the action map just straight up disables every time a scene change happens

austere grotto
#

Is the actions asset managed from a DDOL object too? What's managing it?

marsh mulch
#

its on a DDOL object yeah, Im 90% sure this is related to the network library at this point

#

im speaking to the dev rn and he said there was a scene loading issue a couple months back and to try latest update

marsh mulch
#

turns out it was related tot that

#

essentially it was unload scene A, load scene B, then a bug would cause it to Load scene A, Unload scene A

#

causing weird behaviour internally, latest pull everything works how you'd expect it

teal sapphire
#

Hey guys! I have a peculiar problem. Anyone with experience with the new input system?

My problem is that two buttons triggers the same trigger even though they are mapped to two different buttons. I have checked my code, and as far as I can see, all events are separated to their respected button, but these two still trigger each other for some reason. 🤔 I am testing it with a controller.

The way I have set up the system is that I have a script that sees all inputs, and triggers respected events in my game brain(Game manager.) that other methods can subscribe too. As you see there is nothing here triggering the event except for the button I have linked with it. Still both the select button and the throw button gets called when I press one of them

fierce compass
#

!code

sonic sageBOT
fierce compass
#

anyways, have you tried debugging the input to make sure the buttons aren't triggering when they aren't supposed to?

teal sapphire
teal sapphire
#

I only pressed one button once here

fierce compass
#

ah, no, with the input debugger

austere grotto
#

What's inside these methods @teal sapphire ?

fierce compass
#

it's a button at the bottom of PlayerInput

teal sapphire
teal sapphire
austere grotto
#

let's shortcut this and show/explain the whole chain of events here

teal sapphire
austere grotto
#

and where you subscribe them

teal sapphire
#
    {
        print("Select was performed from inputs");
        gameBrain.TriggerSelectPressed();
    }
  private void ThrowPerformed(InputAction.CallbackContext obj)
    {

        print("Throw was performed from inputs");
        gameBrain.TriggerThrowPressed();
    }
``` This is where they are written, they are subscribed to the input system like so 


```    private void OnEnable()
    {
        controls.Player.Select.performed += SelectPerformed;
        controls.Player.Select.canceled += SelectCanseled;
        controls.Player.Throw.performed += ThrowPerformed;
        controls.Player.Throw.canceled += ThrowCanceled;
        controls.Player.MoveSelectorRight.performed += RightTriggerPerformed;
        controls.Player.MoveSelectorRight.canceled += RightTriggerCanceled;
        controls.Player.MoveSelectorLeft.performed += LeftTriggerPerformed;
        controls.Player.MoveSelectorLeft.canceled += LeftTriggerCanceled;
        controls.Player.SelectTwo.performed += NorthButtonPerformed;
        controls.Player.SelectTwo.canceled += NorthButtonCanceled;
        controls.Player.MenuUp.performed += menuUpPerformed;
        controls.Player.MenuUp.canceled += menuUpCanceled;
        controls.Player.MenuDown.performed += menuDownPerformed;
        controls.Player.MenuDown.canceled += menuDownCanceled;
        controls.Player.QuitTurn.performed += westButtonPerformed;
        controls.Player.QuitTurn.canceled += westButtonCanceled;



        controls.Player.Select.Enable();
        controls.Player.Throw.Enable();
        controls.Player.Movement.Enable();
        controls.Player.MoveSelectorRight.Enable();
        controls.Player.MoveSelectorLeft.Enable();
        controls.Player.SelectTwo.Enable();
        controls.Player.MenuUp.Enable();
        controls.Player.MenuDown.Enable();
        controls.Player.QuitTurn.Enable();
        controls.Enable();
    }```
austere grotto
#

we're past this part

austere grotto
austere grotto
#

and then I wanted to know about the subscribers to those events

#

and where they are registered

teal sapphire
#

Ok, so just to get accouple of things clear, this is a older project and I'm in the process of redesigning and cleaning up a lot of systems, many of these methods are not used atm, and the scripts calling them are not active in the scene. I can try to find post the relevant scripts I guess. But i will try to debug the inputs firstly just to see if the problem lies there.

austere grotto
#

SO maybe do a similar analysis for SelectPerformed and ThrowPerformed

teal sapphire
#

Ok, so I tested it with another D-Pad, and the problem disappeared, so hardware was at fault I guess 🤷‍♂️

fierce compass
#

well trying the input debugger wouldve told you that

teal sapphire
#

Yepp! And that was what worked! Thank you 😆 I now know how to use it

#

The thing is, (It seems like it at least) One of my controllers registered both as a nintendo controller and a xbox controller, where the positioning of the buttons are registered at two different places for some reason, and therefore triggering the same action at two different button clicks?? If that makes sense

fierce compass
#

that's terrifying

teal sapphire
# fierce compass that's terrifying

Yeah! It was a lower model 8BitDo, in case anyone else runs into this. Also, my other controler is also a 8BitDo, but with 2.4G and it works just fine

grim creek
#

it dont get and touches

fierce compass
#

could you convert to mp4 so it embeds in discord

grim creek
#

how

grim creek
#

i fixed it now

#

the problem was input mode on build settings

ruby needle
#

any ideas why both player and ui actions work even though only player is set to enabled by default?

#

I even switch to player action map, still x key from ui map works

#

for some reason removing my input asset from project-wide Actions (Edit > Project Settings > Input System Package) fixed the problem

paper bolt
#

Hello, I am using Unity 2022.3.41 and the New Input System. Controller support works fine on all platforms, including SteamDeck, except for one specific issue: the D-Pad does not work at all on SteamDeck. All other controls work fine.

I have Steamworks .NET set up with the correct app ID. In Steamworks → Application → Steam Input, I set the Default Configuration to Generic Gamepad. Has anyone else encountered this issue and know how to fix it?

paper bolt
empty shore
sonic sageBOT
pliant scarab
#

can anyone help me ral quick with a little problem with the player input behavior

#

i got the bahavior on send messages and everything works fine with movement but my own implemented input function gives out that it wasnt found but it does what it should so very weird. when i change it to invoke unity events my implemented actions work but no movement(im trying to add controller inputs in general and switch the input.... code into the input system)

#

any kind of help helps :)

austere grotto
#

What are you talking about here?

#

Are you getting some kind of error message in the console?
Can you share the actual full error?

pliant scarab
#

yes thank you

#

i have it on send messages because its the first person start 3d thing from Unity to start a 3d game. i added my own little force mechanic to control a ball and it works with the right trigger on controller and left mouse button per script. but when i press it on controller i get this error MissingMethodException: Method 'InfiniteRebound.OnThrow' not found.
System.RuntimeType.InvokeMember (System.String name, System.Reflection.BindingFlags bindingFlags, System.Reflection.Binder binder, System.Object target, System.Object[] providedArgs, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParams) (at <20a025bba6874f73adca28fec451f638>:0)
UnityEngine.SetupCoroutine.InvokeMember (System.Object behaviour, System.String name, System.Object variable) (at <5a87366a6dc74b3aa0e0421cf80e3ae5>:0)
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)

#

basically method not found

#

but it works xD

#

like it does what in onThrow i wrote but the error is given out and i dont like errors and i wann know what is going on there :)

sonic sageBOT
pliant scarab
#
cs private PlayerInput _input;  // Reference to PlayerInput component

    private void Awake()
    {
        // Get the PlayerInput component
        _input = GetComponent<PlayerInput>();
    }

    private void OnEnable()
    {
        // Subscribe to the Throw and ResetBall actions correctly
        if (_input != null)
        {
            _input.actions["Throw"].performed += OnThrow;
            _input.actions["ResetBall"].performed += OnResetBall;
        }
    }

    private void OnDisable()
    {
        // Unsubscribe to avoid memory leaks
        if (_input != null)
        {
            _input.actions["Throw"].performed -= OnThrow;
            _input.actions["ResetBall"].performed -= OnResetBall;
        }
    }

    // This method is called when the "Throw" action is triggered
    public void OnThrow(InputAction.CallbackContext context)
    {
        ThrowController();
    }

    public void OnResetBall(InputAction.CallbackContext context)
    {
        Debug.Log("HELLLOOIMUNDERHEWATER");
        ResetBall();
    } ```cs
austere grotto
#

``` not '''

pliant scarab
#

o im sory

austere grotto
#
    public void OnThrow(InputAction.CallbackContext context)
    {
        ThrowController();
    }```
#

you are using the wrong parameter type here

#

If you're using SendMessages mode the parameter should be InputValue

#

not CallbackContext

#

Same for your OnResetBall method

pliant scarab
#

ok lemme try that...

austere grotto
#

Are you sure you're using SendMessages mode?

pliant scarab
#

yes

#

ehm

austere grotto
#
    private void OnEnable()
    {
        // Subscribe to the Throw and ResetBall actions correctly
        if (_input != null)
        {
            _input.actions["Throw"].performed += OnThrow;
            _input.actions["ResetBall"].performed += OnResetBall;
        }
    }

    private void OnDisable()
    {
        // Unsubscribe to avoid memory leaks
        if (_input != null)
        {
            _input.actions["Throw"].performed -= OnThrow;
            _input.actions["ResetBall"].performed -= OnResetBall;
        }
    }```
pliant scarab
#

[{
"resource": "/D:/Cube Smash/Assets/Scripts/Infinite Rebound.cs",
"owner": "DocumentCompilerSemantic",
"code": {
"value": "CS0123",
"target": {
"$mid": 1,
"path": "/query/roslyn.query",
"scheme": "https",
"authority": "msdn.microsoft.com",
"query": "appId=roslyn&k=k(CS0123)"
}
},
"severity": 8,
"message": "No overload for 'OnThrow' matches delegate 'Action<InputAction.CallbackContext>'",
"startLineNumber": 38,
"startColumn": 4,
"endLineNumber": 38,
"endColumn": 48
}]

austere grotto
#

I just saw this

#

basically you are confused

#

you are mixing up two different things

#

The OnEnable and OnDisable code you have is manually subscribing those functions to the actions

#

so you're not actually using the SendMessages feature at all

pliant scarab
#

i dont know man

austere grotto
#

You should revert the code to how it was and change the mode to "Invoke C# events" or "Invoke Unity Events"

pliant scarab
#

im using it in the different script with the movement

austere grotto
#

and leave it alone

#

Yeah you're just - you're confused and mixing two different things up

#

you're not actually using the SendMessages stuff

#

so turn it off

pliant scarab
#

i do

austere grotto
#

trust me, you are not using it

#

Revert the code and change the mode

#

it will be good that way

pliant scarab
#

but then i cant move the player xD

#

when i change it

#

im using it in this script

austere grotto
#

Ok so - then your problem is that the starter assets code IS using SendMessages

#

but you added your own code which is using a different approahc

pliant scarab
#

yeeeeeees

austere grotto
#

you're trying to mix and match approaches

#

which is not good

pliant scarab
#

how to make my thing work with send messages

#

is my question

austere grotto
#

You need to change your code to actually use SendMessages then - by switching to InputValue parameters like I said before, and getting rid of all that code in OnEnable and OnDisable that subscribes to events

pliant scarab
#

just like this ```cs private PlayerInput _input; // Reference to PlayerInput component

private void Awake()
{
    // Get the PlayerInput component
    _input = GetComponent<PlayerInput>();
}

// This method is called when the "Throw" action is triggered
public void OnThrow(InputValue value)
{
    ThrowController();
}

public void OnResetBall(InputValue value)
{
    Debug.Log("HELLLOOIMUNDERHEWATER");
    ResetBall();
} ```
#

OMGGGGGGGGGGGGGGGGGGGGGG

#

IT WORKS

#

YESSSSSSSS

austere grotto
#

probably like:

    public void OnResetBall(InputValue value)
    {
        if (value.isPressed) {
           Debug.Log("HELLLOOIMUNDERHEWATER");
           ResetBall();
        }
    } ```
pliant scarab
#

SITTING AT THIS FOR 5hours

pliant scarab
#

btw ignore the debug thats driving me insane so im getting creative by implementing memes to check things hahahah xD

#

thank you so much @austere grotto

#

cs ```private PlayerInput _input; // Reference to PlayerInput component

private void Awake()
{
    // Get the PlayerInput component
    _input = GetComponent<PlayerInput>();
}

// This method is called when the "Throw" action is triggered
public void OnThrow(InputValue value)
{
    if (value.isPressed)
    {
        ThrowController();
    }
}

public void OnResetBall(InputValue value)
{
    if (value.isPressed)
    {
        Debug.Log("HELLLOOIMUNDERHEWATER");
        ResetBall();
    }
} ```cs
#

thats howq it works

#

cool :)

fierce compass
pliant scarab
#

ok thanks

tepid thistle
#

I am having problems with this. I thought adding the multitap interaction would make it so it only triggers when double tapping. But it's doing the leap even when I only press the button once

#

When I use performed as a condition it always returns 0 for some reason

austere grotto
#

Only buttons really

#

You may have to write the logic yourself

tepid thistle
#

Oh, I see

#

When I use performed it always returns 0 so the leap doesn't go either way. Like it receives the input on the started phase but not on the performed phase

#

Yeah, I will need to write the logic myself

#

Thanks

austere grotto
tepid thistle
#

I am trying to fix this thing. Because when I hold the left button and then press the right button 2 times while the left button is still pressed it jumps to the left. Any ideas on why that happens?

verbal dust
#

How can I make the camera rotate along with the character using the A and D keys? I'm using the third person character from the starter asset.

glass ginkgo
#

Anyone know why this doesn't work? I clicked with my mouse click, and it somehow didn't call. I already ensured that the problem was not with my code, because I attached another binding for this action (which was my F key), and it worked.

Input.GetMouseButton(0) works, and when I checked it on my Input debugger, it was indeed registering my left clicks.

Is there something wrong with my input system? Is "Left Button [Mouse]" not the left click?

vagrant panther
#

seems like it should have worked. perhaps it is in the code

#

or maybe you have to select a control scheme that it is used in

#

did your F test have a Scheme selected @glass ginkgo ?

glass ginkgo
#

Oh, I'm using the Keyboard control scheme

vagrant panther
#

ok, notice your mouse one does not have Keyboard selected

glass ginkgo
#

Like this?

glass ginkgo
vagrant panther
#

ok. i am out of ideas then. i do not have a lot of experience with it. just started a tutorial on it

glass ginkgo
#

There are two mice here. What do I do?

#

@vagrant panther it worked flawlessly. Thank you man

vagrant panther
#

you're welcome 🙂 +1 for guesses! 😁

glass ginkgo
#

Hehehe, I spent hours on that

vagrant panther
#

Ouch

gusty crest
#

Heya, quick question regarding the "new" input system:
I'm making a car game, and want to have an input for accelrating. Simple enough.
However, I want to have input options for both gamepad and keyboard.
I already worked with the input system once, but only for a game that was only playable with a controller.
So, now that I want to utilize both keyboard and controller input, I have two questions:

  1. If I get the input like in the first attached image, can I still read how far down the controller trigger is pressed?
  2. If I want to get a value of the input of the left stick of the controller, would I also be able to put the keyboard input bindings in the same action? If so, how? (If I want A to be -1 and D to be 1)
austere grotto
#

Make sure the action type is value and the control type is axis

#

Which is what you have in your screenshot 👍🏻

gusty crest
austere grotto
#

the positive/negative binding here

rapid nexus
#

I am trying to execute 2 different methods for a hold action. I bound one to canceled and one to performed

  1. when I tap the button the method for canceled should be called (works)
  2. when I hold the button long enough it should call the method bound to performed (works partially)
    The weird thing is that, even though performed gets called, the canceled method gets called too (after I release the key). Why is that? Is that how it's supposed to work or is my setup faulty?
fierce compass
#

that's how it's supposed to work, apparently

#

i mean that kinda makes sense; how else would you know how long it's held?

rapid nexus
#

I thought it's just performed if it held long enough (successful) and if it's not held long enough it's canceled. Makes a lot more sense to me

white pawn
#

I read in some discussion that that was the first approach. It, however, changed and now canceled is always triggered, regardless if performed was triggered

rapid nexus
#

Ok, how am I supposed to add that logic so that I have one method bound when the hold time was long enough (without calling the canceled)?

fierce compass
#

i mean this problem is here

how else would you know how long it's held?
which couldve been solved by adding another callback, but then that doesn't really make sense for everything

rapid nexus
#

I guess I add a check in the canceled if the duration was > then the threshold?

fierce compass
#

im not sure what the elegant/intended way would be

rapid nexus
#

hm... I'm looking at some comments and SlowTap might work somehow. I'll experiment. Thanks for the diagram

white pawn
#

I'm making a simple look around script with the input system using the normal Look action (Delta pointer). I update the x with the following script;

private void Start()
    {
        lookAction = InputSystem.actions.FindAction("Look");
    }
    void Update()
    {
        Vector2 mouseDelta = 10f * Time.deltaTime * lookAction.ReadValue<Vector2>();
        playerBody.Rotate(Vector3.up * mouseDelta.x, Space.World);
    }
``` However, when I run this script the screen first follows the mouse like it should but also tries to go back to the original rotation immediately. What am I doing/using wrong?
fierce compass
rapid nexus
rapid nexus
white pawn
rapid nexus
#

Hm... sounds to me like it isn't your input then. You using cinemachine or something? what if you comment out the lines and manually change the rotation while playing? If it then still returns to the default rotation it must be something else

cursive oxide
#

what's going on with Axis 4 and 5? Why would Joystick 2 Right and Down share the same axis as the triggers instead of being their own axis?

#

oh, they're not doing double duty, J2 U/D is just bound to random other axes?

fierce compass
#

are they perhaps the triggers? for example R2/L2 on playstation, those are analog

cursive oxide
#

oh, Joystick 2 is actually a third joystick

#

there's a Joystick 0 😂

#

whoopsie. All clear now.

#

all the "right stick left" vs. "left stick right" may have broken my brain a bit

high forum
#

how can I make a local coop on 1 keyboard, but with different inputs? For example, I need the 1st player to control with WASD, and the 2nd player to control with arrows

austere grotto
#

use an array and a for loop

#

But I also recommend using input actions

unreal birch
#

recently i was trying to make a dynamic on screen joystick( the joystick will move to the touch position and when touch will be lifted, joystick will be disabled)...now i am using the new input system. The problem is, now when i touch the screen, the joystick moves there and works fine, but if i touch with another finger anywhere else on the screen, and then lift my first finger(which was controlling the joystick), the joystick still stays at the position of the first touch....what's wrong here?

hardy abyss
austere grotto
opal salmon
#

hi guys

if i have a click to destroy function on a clickable object....button or othervise

i get 200 of these bad boys


MissingReferenceException: The object of type 'UnityEngine.GameObject' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Object+MarshalledUnityObject.TryThrowEditorNullExceptionObject (UnityEngine.Object unityObj, System.String parameterName) (at /home/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnityEngineObject.bindings.cs:815)
UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException (System.Object obj) (at /home/bokken/build/output/unity/unity/Runtime/Export/Scripting/BindingsHelpers.cs:61)
UnityEngine.GameObject.get_transform () (at <70925de717734fab9f0593c446e74c55>:0)
UnityEngine.InputSystem.UI.InputSystemUIInputModule.ProcessPointerMovement (UnityEngine.InputSystem.UI.ExtendedPointerEventData eventData, UnityEngine.GameObject currentPointerTarget) (at ./Library/PackageCache/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs:476)
UnityEngine.InputSystem.UI.InputSystemUIInputModule.ProcessPointerMovement (UnityEngine.InputSystem.UI.PointerModel& pointer, UnityEngine.InputSystem.UI.ExtendedPointerEventData eventData) (at ./Library/PackageCache/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs:402)
UnityEngine.InputSystem.UI.InputSystemUIInputModule.ProcessPointer (UnityEngine.InputSystem.UI.PointerModel& state) (at ./Library/PackageCache/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs:352)
UnityEngine.InputSystem.UI.InputSystemUIInputModule.Process () (at ./Library/PackageCache/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs:2257)
UnityEngine.EventSystems.EventSystem.Update () (at ./Library/PackageCache/com.unity.ugui/Runtime/UGUI/EventSystem/EventSystem.cs:530)

fierce compass
#

use backticks, not quotes, for a codeblock: !code

sonic sageBOT
austere grotto
#

You'd have to show how you set things up

opal salmon
#

i didnt even bound it to anything

ui element has a

public void OnPointerClick(PointerEventData eventData)
{
}
on it thats it

austere grotto
#

What exactly is happening that triggers the error? It's just happening each frame?

#

Or when you move the mouse? Or Click on something? Or What

#

Also trying to square the code you just sent with your statement:

i have a click to destroy function

#

Basically, we need more context.

opal salmon
#

basically when i click on the object...it gets destroyed and for a good one or two secound i get these error messages and then they stop

#

but i managed to circumvent the issue by using an another solution instead of destroy

austere grotto
#

you showed nothing so far that would make it get destroyed

#

Show your setup

opal salmon
#

already found an another way and the code is too long to paste

#

but basically if you want to replicate it just place a button and a script on its parent object when you call it it destroys the button itself

#

you will get the same errors i did

fierce compass
#

fyi, !code

sonic sageBOT
blissful furnace
#

Hey so i am making a 2d 2 player ragdoll fighting game. for inputs and all, I use the unity input manager to spawn the players. I was wondering if there was a way to set the spawn point for the players when you clicked a button to join.

austere grotto
#

I would say the best practice is to basically make the PlayerInput prefab a "stub" object that spawns in the actual player object from its own script and then you can control it however you wish

blissful furnace
#

okay

#

thank you

heavy jewel
#

is there a way to write a custom interaction for the input system?

austere grotto
heavy jewel
#

Yeah. For some reason i cant seem to have it appear in the dropdown menu for interactions.

#

Right now i am just trying to get the example in the documentation (MyWiggleInteraction) to work

austere grotto
heavy jewel
#

Yeah i am confused as to where this would go when it says "Now, you need to tell the Input System about your Interaction. Call this method in your initialization code:"

#

What does it mean by that? Again this is my first time trying to do this so I wanted to start with just the example in the documentaation

#

I would sort of just want to have an example from the docs I could copy/paste and just work from there in terms of figuring out how to write my own

austere grotto
#

Yeah the docs are not great there

austere grotto
#

The static constructor should work yeah

heavy jewel
#

awesome thanks, @austere grotto , will try it tomorrow

split bear
#

If I have a composite binding for an axis input (either 1D or 2D) that I made in the GUI, how can I access each binding through code? I want to make a button prompt that shows the different buttons for each direction.

white veldt
#

Are Joystick Buttons the same for ps controllers and xbox?

austere grotto
rugged vector
#

I'm having issues trying to setup multiple controllable objects. Each object has a PlayerInput on it. I try to assign/remove the same InputActionAsset object when I switch from one controllable object to another. My issue is that only one of the objects present act on the inputs. If I change to another, it won't respond. It does print received events in the console though. If I switch back to the first object, it can still be controlled. What am I doing wrong?

rugged vector
austere grotto
#

If you have more PlayerInputs than human players, you're doing something wrong

rugged vector
austere grotto
#

Use a different workflow

rugged vector
#

What's the intended way for having multiple controllable objects then? A static global object that has the PlayerInput component on it?

austere grotto
#

But yes that is one option

#

Not sure about "static global"

#

But certainly a centralized input handler

rugged vector
#

Persistent, if you will. Thanks though. It does seem to work fine now though, even if its not the intended method.

tough moat
#

Hi, currently having an issue with input rebinding right now and could use some help. https://www.youtube.com/watch?v=csqVa2Vimao&t=1792s I'm using the system from this video (I'm pretty sure) and while it works for keyboard, once I try to change inputs for specifically a playstation controller, it doesn't seem to overwrite the input, but instead just add a new one.

Make a complete rebinding system using Unity's New Input System and Rebinding UI Sample. This video will show you how to implement the rebinding menu, disable and enable controls before rebinding, add constraints to the rebinding process, remove duplicate rebinding including composite actions (2D vector as an example), implement a Reset All bind...

▶ Play video
#

This is what a typical input looks like, if that helps. I would love to just have gamepad as an input instead of dualshock and xbox separately but that seems to just make playstation controllers not work at all

vital orbit
#

how do you make it so when using SendMessage() with PlayerInput (new input system), that the method gets called both onpress and onrelease?
right now, it only gets called when i first press the button, and never when i release the button

#

its set as a button both jump and sprint

turbid rock
strange lichen
#

Hmm I've never used SendMessages, it doesn't look like there's anything in the docs talking about canceled state with Send Messages

vital orbit
#

button is only for stuff you want specifcally ONLY onkeydown if im understanding right?

strange lichen
turbid rock
#

Setting action type to value will give you both .isPressed = true and isPressed = false on released

strange lichen
#

Not with SendMessage though

vital orbit
#

yeah, ill switch it. i just want to know what to use button for when using a playerInput component

turbid rock
#

Button in SendMesseges works as 1 frame only Performed

strange lichen
#

Looks like there is a OnCancel message, not sure if that's the right thing though

turbid rock
#

in events you can just get the same behavior with Started/Cancled

vital orbit
#

oh ok, switch to events would give me better control then this way, thank you nav

#

and nathan

split bear
heavy jewel
#

Hey i want to write a custom input interaction that basically works as Hold, but can fire multiple times. ie there are two thresholds for when "performed" is called instead of just one, to have two different "levels" of being held.

Is this even possible to do? ie after calling performed once is it possible for it to keep checking the hold time? Or is the event stuck waiting for canceled to happen?

austere grotto
heavy jewel
#
    public void Process(ref InputInteractionContext context)
    {
        switch(context.phase)
        {
            case InputActionPhase.Waiting:
                if (context.ControlIsActuated(pressPoint))
                {
                    timePressed = context.time;

                    context.Started();

                    // Set the timeout to cancel to be the second hold threshold
                    context.SetTimeout(secondThreshold);
                }
                break;


            case InputActionPhase.Started:


                if (!firstPerformedFired && context.time - timePressed >= firstThreshold)
                {
                    firstPerformedFired = true;
                    context.PerformedAndStayStarted();
                }

                if(!secondPerformedFired && (context.time - timePressed >= secondThreshold))
                {
                    secondPerformedFired = true;
                    context.PerformedAndStayPerformed();
                }

                if (!context.ControlIsActuated(pressPoint))
                {
                    
                    context.Canceled();
                }
                break;

            case InputActionPhase.Performed:
                if (!context.ControlIsActuated(pressPoint))
                    context.Canceled();
                break;

        }
    }

My goal is just to get Performed to fire twice. Once when it hits the first threshold,. and a second time if it is still being held at the second threshold.

My issue is i am only seeing Performed occur when the timeout is reached or if I cancel (ie, it is not automatically firing performed whenit is just being held down)

any clue on why?

austere grotto
#

Process only runs when the value changes

heavy jewel
#

@austere grotto When which value changes?

austere grotto
#

the input value

#

although thtat doesn't make as much sense to me now that I think of it because how does the hold interaction work?

heavy jewel
#

basically just one of those if statements and a PerformedAndStayPerformed

#
public void Process(ref InputInteractionContext context)
{
    if (context.timerHasExpired)
    {
        context.PerformedAndStayPerformed();
        return;
    }

    switch (context.phase)
    {
        case InputActionPhase.Waiting:
            if (context.ControlIsActuated(pressPointOrDefault))
            {
                m_TimePressed = context.time;

                context.Started();
                context.SetTimeout(durationOrDefault);
            }
            break;

        case InputActionPhase.Started:
            // If we've reached our hold time threshold, perform the hold.
            // We do this regardless of what state the control changed to.
            if (context.time - m_TimePressed >= durationOrDefault)
            {
                context.PerformedAndStayPerformed();
            }
            if (!context.ControlIsActuated())
            {
                // Control is no longer actuated so we're done.
                context.Canceled();
            }
            break;

        case InputActionPhase.Performed:
            if (!context.ControlIsActuated(pressPointOrDefault))
                context.Canceled();
            break;
    }
}
#

^Thats the default one

loud light
#

guys, i'm having some issues with the input system in linux here. i made an input system in a project on the windows of my dual boot (windows + Linux) and when i switch to linux, the input system just don't work anymore. it shows the letters of the keyboard on windows like "( "W", "A", "S", "D" )" with the "". but in linux they don't work and when i try to add new ones, they're only "(W, A, S, D)" without the "". it seems like unity is in EN-US keyboard mode, but i use "BR-ABNT2", as i did on windows. i'm using the same version, it's the same project from my github. any ideas?

thick imp
#

Did anyone try to use InputSystem.onEvent to block inputs through eventPtr.handled = true; ?
It works fine in-editor, but in-build only the keyboard and mouse are blocked, the gamepad actions go through regardless.

strange lichen
thick imp
austere grotto
thick imp
thick imp
strange lichen
#

Don't know if it is considered in the background though when steam overlay is up

#

I think disabling the action map is probably the best option. If there are other things that enable and disable it, you essentially need a system that can overwrite those and enable and disable those at a master level

thick imp
#

so the problem is resolved

#

thanks a lot for the help though, the device activation/deactivation would've been a great alternative

strange lichen
thick imp
heavy jewel
unreal geode
#

Buttons is not working only in build (new input system)

austere grotto
austere grotto
#

It's likely related to tthat

#

possibly you are disabling it or something along those lines

unreal geode
unreal geode
#

what interactions should there be here?

thick imp
# strange lichen I wonder if the `onEvent` "hack" could cause slight issues though, for example s...

so, this is kind of funny; it does fix the issue you mentioned
~~however, iterating over InputSystem.devices does not work; the gamepad is not in the list of devices !
so the gamepad remains active in this case.. ~~
I guess I will combine both techniques, ignoring devices that are not in the device list with the onEvent interception, and disabling the others

it works, i had another exception.. bad day 😅 , sorry for the notification

unreal geode
austere grotto
#

First off are the buttons reacting at all to the mouse (tinting etc)?

unreal geode
unreal geode
austere grotto
#

make a development build and check your logs

#

there's probably an error happening in the click handler code

undone fiber
#

Need some advice on this. So I want to use a virtual mouse for the current Mouse itself so that I can set up its bounds easily. I've tried using the virtual mouse system with the new Unity Input System module. The virtual mouse does move perfectly well with the input of the current mouse delta, however, none of the UI actions like hover or click seem to work. I have also set the raycast target for the virtual mouse image as false so there should be no issue with the raycasting. P.S : I tried replicating the virtual mouse from gamepad (video from CodeMonkey ), the only difference being it uses the Mouse for its movement, event handling.

#

Main goal: I want the virtual mouse to interact with the UI

undone fiber
#

Fixed it

unreal geode
soft crystal
#

okay how are you supposed to use the generated C# file for input actions? because I keep getting this the moment I new() an instance. even if I disable and/or dispose it in OnDisable, it seems

soft crystal
#

in a singleton monobehavior on access

austere grotto
#

So is the error happening when you instantiate, or later? Looks like the error is coming from a finalizer?

soft crystal
#

but I think I found the issue, my UI code was referencing it, so it created a singleton in editor time

austere grotto
#

Ah yeah that lazy load stuff can bite you if you're not careful!

soft crystal
#

me: [ExecuteAlways] 😎
unity: thonkError Destroy may not be called from edit mode! Use DestroyImmediate instead.
me: SCWWcrying

#
void OnDisable() {
    if( inputs != null ) {
        inputs.Disable();
        if( Application.isPlaying )
            inputs.Dispose();
        else
            DestroyImmediate( inputs.asset ); // this is all Dispose does anyway
    }
    instance = null;
}```
![conflicted_large](https://cdn.discordapp.com/emojis/1092822406256664596.webp?size=128 "conflicted_large")
#

anyway hoops successfully jumped through

vapid lantern
#

Any ideas as to why my controller would work in the editor but not in a build?

#

I'm using the new input system

austere grotto
vapid lantern
#

how would I debug this?

austere grotto
#

First off check logs to make sure there's no errors
Second add some logs to make sure input is really not getting processed

#

Are you using control schemes?

vapid lantern
austere grotto
vapid lantern
#

Nope, completely singleplayer

austere grotto
#

Then there's not really a good reason to use control schemes

#

and they often cause trouble

#

control schemes are there to group input devices so the PlayerInputManager can assign sets of devices to different human players in a local multiplayer game

vapid lantern
#

I just deleted the control sceme and that didn't solve anything

vapid lantern
#

So it looks like it does work, you just have to disconnect and reconnect the controller a couple times for some reason

vapid lantern
#

Does anyone know why unity takes like a minute to actually start using my controller?

inner coral
#

anyone any idea why this always returns true? I have recently disabled the old input system in my project settings and since then everything is screwed because of this method always returning true 😄

        // Check using the pointer ID from the new Input System
        if (EventSystem.current != null && EventSystem.current.IsPointerOverGameObject(-1)) {
            Debug.Log("GetIsMouseOverUI() is TRUE");
            return true;
        }

        // Check if a UI drag operation is in progress.
        if (UI_DragAndDropManager.Instance != null && UI_DragAndDropManager.Instance.IsDragging()) {
            return true;
        }

        Debug.Log("GetIsMouseOverUI() is FALSE");
        return false;
    }```

funny thing is, that even switching back to the old input alongside the new one in project settings does not fix my issues. However, when hardcoding return false into my method, everything works as normal. 
Anyone got any idea what I am missing here?
austere grotto
#

That seems like the logical first step

inner coral
austere grotto
inner coral
#

I just noticed that the Physics Raycaster component on my main camera was the issue. Event Mask was set to every Layer. Changing it to only my "clickable" layers fixed it

austere grotto
#

yep

austere grotto
inner coral
#

yea I have the feeling that I reached a state now where I should centralize my input logic somewhere instead of having individual logic across multiple scripts

heavy jewel
#

Hey got a question with the Hold Itneraction in unity's input system.

I am trying to (foir the time being) re-create the hold interaction in unity. The following is quite literally the code from the HoldInteraction.cs (the default one)


    public void Process(ref InputInteractionContext context)
    {
        if (context.timerHasExpired)
        {
            context.PerformedAndStayPerformed();
            return;
        }

        switch (context.phase)
        {
            case InputActionPhase.Waiting:
                if (context.ControlIsActuated(pressPoint))
                {
                    timePressed = context.time;

                    context.Started();
                    //context.SetTimeout(secondThreshold);
                }
                break;

            case InputActionPhase.Started:
                // If we've reached our hold time threshold, perform the hold.
                // We do this regardless of what state the control changed to.
                if (context.time - timePressed >= 1f)
                {
                    context.PerformedAndStayPerformed();
                }

                
                if (!context.ControlIsActuated())
                {
                    // Control is no longer actuated so we're done.
                    context.Canceled();
                }


                break;

            case InputActionPhase.Performed:
                if (context.ControlIsActuated(pressPoint))
                    context.Canceled();


                break;
        }
    }
#

What i am noticing is that the default hold interaction doesn't actually fire performed unless its SetTimeout value has been set (ie the commented out line). Otherwise it waits for you to release the actuated button before saying it was performed. Is the Performed supposed to be fired while it is being held down or only ever when it is let go (after being held for a certain amount of time)?

#

My initial thought was the Performed would be fired the moment you cross the threshold. However, like i mentioned above, it only fires performed if you let go of the actuator after it has crossed the desired threshold. Is this intended?

#

My goal is to make an itneraction that fires Performed at different time thresholds while it is being held down still

austere grotto
#

release is not required

heavy jewel
#

Thats not what Ive been seeing, even with the default hold code copy and pasted into mine. It only fires performed because the timeout value has been reached

#

If you uncomment the timeout code it will not fire anything until you release

austere grotto
#

let me test because that doesn't match my expectations

heavy jewel
#

Thanks, let me know. Its not doing what I expect either

#

The highlighted line is what I am refering to ^

#

I am also in unity 2022 if that helps

austere grotto
#
            a.action.Enable();
            a.action.performed += ctx => Debug.Log("Performed");```
heavy jewel
#

Hmmm. Is there a way to edit the default Unity HoldInteraction.cs? Any time i make a change to it and save it resets it back to what it was before (hence why i just copy and pasted the code to a custom interaciton)

austere grotto
heavy jewel
#

How can I do that?

heavy jewel
#

If you set the timeout to something really long (or comment it out), does it still work?

austere grotto
heavy jewel
#

I think by default it uses the press duration as the timeout value

austere grotto
heavy jewel
#

Yeah but what I was saying before is that I think that it "Seems" to be doing it properly becasue its actually the SetTimeout() that is being hit, and not actually the code chunk that checks if the time has passed the duration

#

ie this is actually never being the cause of the action going into performed

austere grotto
#

I'm not sure I understand the difference or significance of "timeout" vs "hold time" here

heavy jewel
#

theres a timeout that gets triggered regardless of how long the duration is set that triggers it to go to performed

#

My goal is to make a mutli-stage hold that fires at multiple points as you are holding it down. I found this issue because it never acutally fires besides when the timeout in SetTimeout() gets hit

austere grotto
#

but it's using the set duration for the timeout

heavy jewel
#

Yeah, but my expectation is taht it would fire without that

austere grotto
#

it won't because the Process function never actually runs except when:

  • the input control actuation changes
  • the timeout expires
#

it doesn't run every frame, for example

heavy jewel
#

Do you have a reccomondation to achieve what I am trying to do then?

austere grotto
#

Can you explain it in detail?

#

perhaps just setting multiple timeouts?

heavy jewel
#

essentially just something that as i hold it down it will fire perfomed at multiple desired thresholds

austere grotto
#

if setting multiple timeouts simultaneoously works - do that

#

otherwise, set a new timeout when the first one expires

#

third option - just use the default interaction and do the logic in a script in Update

heavy jewel
#

So whats the point of the time threshold check in the default unity code then?

austere grotto
#

remember Process might run on the timeout or when you release

#

so if you started the interaction (phase is Started) you need to check whether the time has passed or if we released

heavy jewel
#

But like i said, it never seems like it is checking if the time has passed

#

the context.performed never seems to call from the if(context.time - m_timePressed ... ) check

fickle wharf
#
public void OnJump(InputAction.CallbackContext value)
    {
        if (value.started)
        {
            Debug .Log ( "Value started = " + value.started);
            animCtrler.SetFloat("VeloMag", veloMagnitude);
            isJump = true;
            jumpTimer = jumpCD; // Start the jump timer
            Debug.Log (jumpForce + "JumpForce");
            rb_.AddForce(new Vector3(0f, jumpForce, 0f), ForceMode.VelocityChange);


            Debug.Log("OnJump" + isJump);
        }

    }```
Everything runs except for the rb_.Addforce() , any ideas?
austere grotto
#

What makes you think it doesn't?

fickle wharf
#

It seems to be calling the function on another script??? My player jumpforce is now 999 but it prints as my default 15

#

Ohh i accidentally set the input event to call the jumpscript on the prefab =.=

#

Whoops.

vale meadow
#

Hey all. I'm sure this has been answered somewhere, yet I couldn't find it. Was hoping someone could answer my questions, or link me to a good writeup!

  1. I'm wondering if there is a functional difference between using the input system through a player input script, or through C#. Any performance benefits or downsides? Any limitations?
  2. I'm playing around with a little prototype where the player can control different types of vehicles. For this, I need different input maps for each type of vehicle (e.g. a plane vs a car). What would be an industry standard way of doing this? Keep the player input and cycle between maps depending on vehicle? Use C# input classes, disable the player on vehicle enter, and enable a separate inputaction instance?

(Please feel free to ping me if you respond, I'd really appreciate it!)

supple crow
#

I don't understand the first question

#

Are you talking about the "Player Input" component?

#

and I'm not sure what "through C#" would mean

#

maybe the "Generate C# Class" feature of an input action asset?

verbal remnant
vale meadow
vale meadow
vale meadow
#

Was curious whether the ideal really is making a middle layer between / event bus for the generated C# class.

verbal remnant
vale meadow
vale meadow
#

I've dabbled with those a little bit. I'm curious as to why they'd be more ideal?

#

As far as the inspector goes, it seemed potentially more clutter

#

Though I'm probably being a tad overdramatic there 😅

#

In what way would it solve my need for multiple different controllers? E.g. the basic player movement controller, a car input controller, a plane input controller, etc...

#

I was curious whether it wouldn't just be more convenient to place a player input component on the prefab, disable it by default, set it to the correct map, and bind it to the vehicle's event handlers.

#

And then toggle the player's and the vehicle's input component on entry/exit.

verbal remnant
vale meadow
#

How would they be bound to the specific vehicle's event handlers though?

#

E.g. if there are 3 cars.

verbal remnant
vale meadow
#

And then enabling those on entry / disabling on exit?

verbal remnant
#

the actions are part of an action map on entry/exit you toggle the action map

#

which toggles all the contained actions

vale meadow
#

Is the input object active regardless of being attached to e.g. a player input component?

#

i.e. if it exists as a file, it's active

verbal remnant
#

what input object?

vale meadow
#

Apologies, wrong wording. The Input Action file.

#

Forgot the exact name for the file itself.

verbal remnant
#

you mean the inout actions asset?

vale meadow
#

Yes.

verbal remnant
#

thats just a bunch of json

#

its not ever active

#

but if you reference an input action, that action's events will be called

vale meadow
#

That's what I was wondering, yeah

#

If the asset exists, and I use an input action reference, it will work

verbal remnant
#

yes

vale meadow
#

I don't need to instantiate anything or do any management of a persistent object.

#

Neat.

verbal remnant
#

if you dont have the asset you also can't use action references since then there would be no actions to reference

vale meadow
#

I can see the benefit of using the input action reference, yeah.

#

Only have the actions you specifically need, no clutter with the player input component

verbal remnant
#

yes

#

and no unity events

#

just c# events

#

also easy to rename, rebind and move things around

vale meadow
#

I guess I do need to manually subscribe

verbal remnant
#

basically allows you to make input completely abstract

vale meadow
#

I'll play around with it a bit tomorrow. Thanks!

verbal remnant
#

there is no way input magically connects to your controller

vale meadow
verbal remnant
vale meadow
#

You have to assign the event, I guess that kind of counts.

#

I did enjoy the code removal it brought with it, but it's a super minor thing

verbal remnant
#

also unity events are about the easiest thing to break in a unity project, its best to not use them for anything thats improtant or needs to survive a refactoring

vale meadow
#

And I don't really need flexibility in the event bindings tbh

vale meadow
verbal remnant
#

then you have never refactored a project

#

try renaming a unity event 😛

vale meadow
#

I do use Rider, and it has so far been pretty good at integrating with Unity for any minor refactorings.

#

But I'd lie if I said I had done any significant refactoring related to UnityEvents

verbal remnant
#

rider cannot migrate unity events to new names

#

if you rename the method a unity event calls, that event is then broken

vale meadow
#

I'll have to give it a try tomorrow

verbal remnant
#

and nothing warns you about it, there is no error, no warning, its just silently not working anymore

vale meadow
#

Kind of curious now

#

I'll rename my movement event handlers and see what happens

#

Will need to rework it anyway to use the input action refs

#

Thanks for the solid advice and discussion! Have a fantastic rest of your day!

supple crow
#

InputActionReference is great. I use it for everything now.

glass yacht
verbal remnant
vale meadow
#

@verbal remnant question:

  • Would IARs from different maps work together? Or would I need to still switch the global input actions asset between maps?
  • Does the IAR approach still automatically switch between input device?
verbal remnant
# vale meadow <@544260011430248467> question: - Would IARs from different maps work together?...
  • there needs to be only one asset holding all the maps and actions. Idk what you want to switch here. Maps are just a container for actions to modify them together. Whether there are limitations caused by this that affect your game code depends on what you do with the references and how you toggle them individually, globally or via maps.
  • actions dont switch between input devices, they merely trigger events based on what bindings you have configured. If you use input schemes you need to set these up correctly so that valid input-device-combinations exist.
vale meadow
verbal remnant
#

If you use player input to enable/disable them, that will then also affect your action references.

#

since in most games you will need a state machine to control inputs and other things for each of your fundamental game states/modes, you should toggle the action maps there. Whether you do that via Player Input or directly is up to you.

bright magnet
#

so i want to write a class for input to have all in one place. but i have to repeat each input with basically the same code:

        public void UseSpring(InputAction.CallbackContext context)
        {
            if (context.action.WasPressedThisFrame())
            {
                EventManager.UseSpring.OnSpringEvent.Filter()?.Invoke();
            }
        }

        public void ExitMenu(InputAction.CallbackContext context)
        {
            if (context.action.WasPressedThisFrame())
            {
                EventManager.UpdateUI.OnCloseUICall.Filter()?.Invoke();
            }
        }

so I thought I just work with a switch to reduce the code produced...

        public enum InputVariants{
            UseSpring,
            ExitMenu,
        }

        public void CallInputAction(InputAction.CallbackContext context, InputVariants inputAction)
        {
            if (context.action.WasPressedThisFrame())
            {              
                switch (inputAction)
                {
                    case InputVariants.UseSpring:
                        EventManager.UseSpring.OnSpringEvent.Filter()?.Invoke();
                        break;
                    case InputVariants.ExitMenu:
                        EventManager.UpdateUI.OnCloseUICall.Filter()?.Invoke();
                        break;
                    default:
                        break;
                }
            }
        }

problem now is....
the method doesnt show up in inspector as an event to be called:

#

i guess its because the player input component only accepts callback context events?

austere grotto
#

But you can make a wrapper function that passes in the constant if you want

bright raven
#

Hello, I am trying to create a main menu for my game.
For some reason my buttons are not clickable.

I have done the following:

  • created an event system in my scene
  • My buttons are inside a canvas object, the canvas does have a raycaster
  • All butons are interactable, have Raycast Target On
  • The TextMeshPro component objects dont have RayCast Target On
bright magnet
bright raven
inner anchor
#

What's the right way to handle OnMouseOver etc etc with the input system while using a cursor (for controllers)? I can't seem to find any documentation

#

Do I really need to do it with raycasts?

inner anchor
#

This is implying only UI components, I think I really have to raycast on update when dealing with gameobject

austere grotto
supple crow
#

as I just discovered yesterday, you can use the event system with colliders, too!

verbal remnant
ruby tusk
#

I'm getting this error when trying to build for Linux

The type or namespace name 'Switch' does not exist in the namespace 'UnityEngine.InputSystem' (are you missing an assembly reference?)

How can I fix this? Why isn't Switch supported for Linux builds?

distant raptor
supple crow
#

Physics Raycaster!

rugged pasture
#

I've got an InputAction mapped.

#

I've seen some references to implementing ICancelHandler, but I'm not sure where, and my attempts so far haven't been very fruitful.

#

I'm also running into a weird thing where the Submit button works without activating the canvas, and after running the game, I can't change the Submit button to a keyboard shortcut without closing the project and re-opening it...

Unity 2023.3.0b5 for what it's worth.

turbid rock
#

i think there is an error in the example code

#

cancelAction isn't a thing inside InputSystemUIInputModule

#

just says its cancel

rugged pasture
#

Oh. So I just need to assign that action.

glad sinew
#

my unity game uses the player input manger for local multiplayer. The script I have calls its child objects and moves them based on controller input, but when the second controller joins in and clones the player, both players are controlled by the second controller. How can I get the script to call its children separately?

turbid rock
#
  inputActions = new();   ((InputSystemUIInputModule)EventSystem.current.currentInputModule).cancel =
    InputActionReference.Create(inputActions.UI.myCancelButton);```
turbid rock
#

idk how you do it in VS though
in code example would be

if(!isOwner){
myinputscript.disable();
return;
}```
rugged pasture
#

Ah, I don't have a cancel button. It's all just using buttons to cancel. 😄 I'm going to give a try at hooking into that event though. Thank you for pointing me down the right direction.

#

Maybe. 😛 We'll see if it works.

turbid rock
golden oar
#

hi everyone quick question. Does anyone know how to get unity to request permission to access the microphone on MacOS? I want players to use their voice to trigger something but cant get the microphone to access unity

#

from what im seeing input system is primarily designed for keyboard, mouse, gamepad, and touch input, and does not natively support speech recognition.

vague cosmos
#

Hello everyone. Does anyone have an example of a controller for 3rd person vehicles? I want to create a game with controls similar to this Star Conflict or War Thunder Provides control of both the equipment and the turrets on it, but I found almost no necessary information

atomic galleon
#

hi there
i have a USB HID gamepad (the one that Unity recognizes as Joystick) and i would like to add bindings for its buttons and both sticks but for some reason Unity doesn't recognize right stick, in the Input debugger it is shown as two separate axises
other buttons just can't be found in Joystick tab, i can add them only as binding for my gamepad specifically
is this possible to add a support of this gamepad?

verbal remnant
atomic galleon
ashen apex
#

whats the best method of introducing an interact button for FPS? ive got movement down and just have to figure out how to frankenstein in an input

#

all tutorials assume youre using a different input script

opaque light
#

Hi there! Unfortunately it seems that the new Unity Input System does not work with Steam Remote Play. Are there any future plans to add support? Thanks!

verbal remnant
frigid ridge
kind ginkgo
#

I have a TextMeshPro input field for the player to enter a name. I have it working for a keyboard / PC but how do I incorporate a HUD keyboard for players using a gamepad?

verbal remnant
digital sphinx
#

make unity animation stop after keyframes over

brazen gorge
#

Is there an easy solution to clear a selected object when pointer clicks on empty space? All of my current input logic is on the gameobject.

austere grotto
#

It basically catches all the clicks that don't hit anything else

brazen gorge
austere grotto
#

Anything that needs to be clickable can be in the mask

#

Anything else can be in other layers

brazen gorge
#

Cool. I will get right on that. Thanks! 🤘

vital orbit
#

hello, i have a PlayerAction component on my player. I changed the default Scheme name to Normal, and added a Build mode. Problem is, i cannot change the action map by passing "Normal" and "Build", and when the game starts up i get this error, even when i set default action map to normal.

austere grotto
#

Probably a different PlayerInput

#

(it's called PlayerInput not PlayerAction)

#

Look for other PlayerInput instances in your scene

#

PlayerController line 309 also has a Null reference exception

vital orbit
#

heres my input switching code if that matters. "Player" Is what the initial action map is if you do not rename anything yes. the problem with that is i removed EVERY reference to player in the inputActions asset, the PlayerInput Component, and the code.

austere grotto
vital orbit
#

Trying to search for it, but coming up empty. i have nothing else that i remember tieing to the player, because i imported my prefab from another scene. the prefab defo doesnt have more then one input

#

yeah the player is the ONLY instance of PlayerInput in my scene

vital orbit
#

Fixed it btw, bug come up when modifying InputActions, and you have to delete library and reload project for it to reconize change if it comes up

smoky spade
#

hello guys i want help i cant find a delta mouse in the binding?

austere grotto
#

Assuming this is for zooming a camera it should be:
Action Type: Value
Control Type: Axis

smoky spade
#

i want to make sim souls like game the right and mouse controlling the camera

austere grotto
#

And the mouse binding would be totally separate from your gamepad binding

austere grotto
#

you might want it to be 2D too

#

In which case you'd do:
Action Type: Value
Control Type: Vector2

#

It seems like right now you're trying to make this a composite or something

#

which is not correct

#

For example here's the default Look action. It's Value/Vector2 and then one of the bindings is Delta[Pointer}

smoky spade
#

like this right

#

@austere grotto

austere grotto
#

Assuming you set the Camera action to Value/Vector2, sure

smoky spade
#

yes

glad sinew
#

Ive been having problems with the input system, first both players were being controlled by one gamepad and then when i set the controller values to variables and then each player to be controlled by those variables, the gamepads are controlling the opposite player, while the triggers are still controlling the original players.

austere grotto
glad sinew
#

im using visual scripting

#

here let me show on video

austere grotto
# glad sinew

I'm not sure how this intereacts with Visual Scripting. Are you using InputActions defined directly on the script?

#

Or are these InputActionReferences?

#

Or what

glad sinew
#

the script gets the input actions from each prefab and puts it into variables only accesible within the script

#

but somehow its swapping the joystick inputs when the new player joins in

austere grotto
#

right that's what I'm saying - "input actions from each prefab" - meaning you just defined input actions on the script itself?

#

And you configure them in the inspector on the script?

#

Usually for local multiplayer you use an Input Actions Asset and PlayerInputManager / PlayerInput components.

#

Otherwise you have to handle player connection / device mapping yourself

glad sinew
#

when the new player joins in the original first player is controlled by the second gamepad when the new player joins in

austere grotto
glad sinew
#

alright give me a second

forest badger
#

Has anyone ever seen this issue?
One specific menu is spawning another menu, then this error happens and the input system no longer works.
This specific menu is the only one causing it yet it's changing menus the same way all my other menus do.

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
  at UnityEngine.InputSystem.Utilities.InlinedArray`1[TValue].get_Item (System.Int32 index) [0x00018] in .\Library\PackageCache\com.unity.inputsystem@1.7.0\InputSystem\Utilities\InlinedArray.cs:68 
  at UnityEngine.InputSystem.UI.InputSystemUIInputModule.RemovePointerAtIndex (System.Int32 index) [0x00001] in .\Library\PackageCache\com.unity.inputsystem@1.7.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:1861 
  at UnityEngine.InputSystem.UI.InputSystemUIInputModule.Process () [0x000c6] in .\Library\PackageCache\com.unity.inputsystem@1.7.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:2177 
  at UnityEngine.EventSystems.EventSystem.Update () [0x000f6] in .\Library\PackageCache\com.unity.ugui@1.0.0\Runtime\EventSystem\EventSystem.cs:530 ```
austere grotto
glad sinew
forest badger
#

All other menus in my game use this system. It's only ONE menu that causes this error

austere grotto
#

Did you modify the input module in some way?

austere grotto
# glad sinew

This isn't helpful either.

I'd love to see what components are on the prefab(s) and with what settings and how the actions are configured etc.

#

When I say I want to see the components I mean show the inspector

glad sinew
#

ah i see

forest badger
# austere grotto Yeah but what about your event system

The event system is attached to the Menu's object, which is deleted first, then the new UI object is spawned.
Here is the code:

public void NewUIScreen(string path, bool transition = false, bool freezePlayer = false)
{
    if (freezePlayer)
    {
        Player.Freeze(true);
        Player.gameObject.SetActive(false);
        currentLevel.SetActive(false);
    }

    if (transition)
    {
        StartCoroutine(TransitionUI(() => NewUIScreen(path)));
        return;
    }

    // Temp ref to old UI
    DiestUI oldui = currentUI;
    string oldUIPath = currentUIPath;

    // Destroy old UI
    if (oldui != null)
    {
        previousUIPath = oldUIPath;
        Destroy(oldui.gameObject.transform.root.gameObject);
    }

    UnityEngine.Object o = UnityEngine.GameObject.Instantiate(Resources.Load(path));
    DiestUI newui = o.GetComponentInChildren<DiestUI>();
    if (newui == null)
    {
        Destroy(o);
    }
    else
    {
        // Replace current UI variables
        currentUI = newui;
        currentUIPath = path;
    }
}```
austere grotto
#

Honestly that's very odd

#

normally the Event System should be a completely separate object form any UI

glad sinew
#

basically each joint is a hinge joint and the main torso has the actual script attatched too it

austere grotto
#

and you should just leave it be

glad sinew
#

the script gets the input from the gamepad and moves the children accordingly

austere grotto
glad sinew
austere grotto
#

The InputSystem_Actions asset

glad sinew
#

its the input manager thats causing the issue, less so the input system

#

it works fine for one player

#

sorry thats just nintendo controller buttons lol

#

left trigger and right trigger

austere grotto
#

so what's going wrong here exactly? parts of the gamepad are controlling the wrong character?

glad sinew
#

here let me get a video so i can better show you what the actual issue here is

#

hold on wrong video

#

i press start to add in the first player and never stop moving the stick on that player. When i press start and add the second player in, the first gamepads stick is controlling the second player, while the trigger still controls the original player.

#

forgive me if its a bit confusing

#

basically the stick movement swaps with the second player

austere grotto
#

The waving arm is the thing being controlled by the stick?

glad sinew
#

yes

austere grotto
#

What does the trigger do?

glad sinew
#

the trigger is a grab button

#

im basically recreating the movement of "a difficult game about climbing" if you have heard of it

austere grotto
#

Where's the part of the code that reads the MoveX and MoveY?

austere grotto
# glad sinew

because this code seems to read "LookX" and "LookY"

#

but the input handling code is setting MoveX and MoveY

glad sinew
#

movex and movey is for the left stick, look is for the right stick

austere grotto
#

Is the right stick the one that's broken?

#

Or both of them?

glad sinew
#

I can add the code back in for the left arm but itll still do the same thing

#

let me show u a better look hold on

austere grotto
#

Well the code you showed for input handling doesn't set the LookX and LookY

#

so it would be good to see the code that does set it

forest badger
austere grotto
#

What do you mean by it losing the device exactly?

glad sinew
#

you can see in the code that the values for the right stick switch from reading from gamepad one, to gamepad two when the second player adds in

austere grotto
#

God I despise visual scripting lol

forest badger
glad sinew
#

i dont blame you 😭

#

i thank you for at least trying

austere grotto
#

Yeah I'm not sure. this looks to me like it should work, but I don't use VS so maybe I'm missing something there.

My understanding is the Graph variable should be only within that script right?

#

So I'm not seeing how data could be jumping from one instance to another

#

My initial thought was maybe you were setting it as a global variable or something but that seems not to be the case

glad sinew
#

its not that the data is jumping from one instance, its when the second gamepad comes in the first player object starts pulling from the second gamepad instead of the first

austere grotto
forest badger
austere grotto
forest badger
#

I'm making a mobile game so the onscreen controls are mimicking a gamepad

austere grotto
#

Some wire is getting crossed somewhere

austere grotto
#

are they part of the object that got destroyed?

forest badger
#

yes as they are the on screen buttons in the menu

austere grotto
glad sinew
#

and the weirdest thing is if i dont set that graph variable in the script, both players are controlled by the same gamepad

#

its honestly so frustrating its insane

tame oracle
#

does anyone know a good tutorial of using new Input System with Unity 6?

glad sinew
#

at this point im just gonna manually set everything idk man 😭

austere grotto
# glad sinew

I think one weird thing is your use of OnUpdate here

glad sinew
#

yeah thats true i should just used fixed update

austere grotto
#

If I understand things correctly you can/should wire the green arrow event directly from the Input System Event nodes into the Set Variable nodes

#

nah not FixedUpdate

glad sinew
#

well wait actually no

#

i dont do that because it would only activate then when the "on hold" part is true

#

it wouldn't give data for zero

austere grotto
#

you'd have to make a separate event for release i guess?

glad sinew
#

yep

#

its useful in some cases like the grab, but for just putting the raw data into a variable i do it like this

crisp iris
#

hey yall, I need some help with setting up my input system to differentiate between two actions that share one input.
For example I have action called Dash and if hold down the A/D key , it will do a dash. However I would like to also make a different action call Parry and if Hold down the S key + A/D key it will initate a parry. Current I have both set up and when ever i go to do a Parry , it will both dash and parry at the same time.

#

oh and i would like for only one to happen based on the input

fickle wharf
#

For the player input manager's instantiation of the player prefab, how do i adjust the instantiated position?

blissful lotus
#

Hey, does anyone know if CursorMode.ForceSoftware is unsupported by Input System?

dull topaz
#

what is input system

blissful lotus
# dull topaz what is input system

Check out UnityEngine.InputSystem namespace in the docs. It replaces the legacy system under UnityEngine.Input with more managed features.

nocturne arch
#

Hello, can I ask a question about how do you connect bluetooth device to windows system in unity?
I checked lots of articles and most of the ones I got were about using a mobile device to connect to a Bluetooth device.
It really discourages me.UnityChanBugged
Also I have found adabru's BleWinrtDll, is that a way or not? Lots THXUnityChanSalute

glad sinew
#

the player input system manager is genuinely such a headache

#

everytime a player adds in it mixes up gamepad inputs between players and its so frustrating

#

even though I clearly define which gamepad goes to which player here

#

if anyone has any idea how to fix this issue it would be so greatly appreciated

onyx sandal
#

Hello, not sure if it's correct chanel for this but how can i remove microbounciness of player while moving? I've replaced boxcollider2d to cylindercollider2d to remove random stucking in the ground but now it just bounce player instead. I've tried to add 0 bounciness material but it had no effect

austere grotto
fierce compass
onyx sandal
#

It's less noticeable on video but if u would see to rigidbody velocity u will see unconstant y-axis spikes

rugged pasture
#

Hmm... I have a tank game that I'd like to operate via old traditional tank controls, with the left stick of the game pad using the Y axis for the left treads, and the right stick doing the same for the right treads. I've got a Value action with type of Axis. I've tried both a Composite of Left Stick/Up and Left Stick/Down, and mapping it to the Left Stick/Y, but neither seem to register as input. The corresponding keyboard commands do. I'm currently using ReadValue to get the value in my code. I had also tried removing the keyboard commands on the off chance that they're "overriding" things by giving me an artificial 0 value. No dice...

verbal remnant
rugged pasture
#

Certainly. Here's my Input settings (currently set with the left tread doing the composite binding and the right tread mapping to Right Stick/Y).

#

And I haven't created an Input System Settings Asset, so I assume it's on the default.

supple crow
#

e.g. just create an action that produces a Vector2 and see if the "left stick" binding works for it

rugged pasture
#

I'm at work now, so it will be a bit before I can do that. I can see the input in the debugger.

burnt atlas
#

I switched to the new input system in my fps game
but the mouse axes in the new input system are MUCH more sensitive
like 12x or so

#

Is this not how its supposed to be done?

austere grotto
#

but this is ok too

#

the real question is what does your code look like

burnt atlas
# austere grotto the real question is what does your code look like
    private void DoFpsCamera()
    {
        float mouseX = _inputX * mouseSensitivity;
        float mouseY = _inputY * mouseSensitivity;

        _xRotation -= mouseY;
        _xRotation = Mathf.Clamp(_xRotation, MaxUpwardRotation, MaxDownwardRotation);
        transform.localRotation = Quaternion.Euler(_xRotation, 0f, 0f); //euler gets converted to quaternion

        
        _yRotation += mouseX;
        _playerBody.rotation = Quaternion.Euler(0f, _yRotation, 0f);
    }