#🖱️┃input-system

1 messages · Page 3 of 1

olive mortar
#

its a big hurdle though, but ez once you know what you're doing

upper tapir
#

yeah I started working with the new one and you're right

#

it's a ton better

upper tapir
#

I'm slowly learning it and it's slowly becoming easier and easier to understand for me

upper tapir
olive mortar
#

thank you ❤️

upper tapir
#

but I'll support you with a wishlist

olive mortar
#

no problem, thank you 🙂

amber ruin
#

So bit confused as to what is going on here, it will register the right trigger input for this action but not the left mouse click input. It is picking up the mouse position just fine though. Did I set something up wrong here?

Of note, I setup 2 control schemes one for gampad and one for Keyboard&Mouse

#

also Action Type is Button

amber ruin
#

apparently the problem is that my UI event system uses leftclick, I read I can bypass it with a lambda event, but I lose my "hold to continually fire" functionality

amber ruin
#

Found the issue, I needed to add mouse as a device to my controlscheme

mental juniper
#

Another quick question, I use inputs from the input manager which is great for controller but when using a keyboard it tends to have a quick ramp up and down when that isn't necessary (in other words, I don't stop walking when I let go of a key as the axis takes a half sec to ramp down). Is there any way to avoid this or disable it?

Please @ me.

proven elm
#

Hi, for a long time, when connecting the controller, I get such an error, it prevents me from further work on the code to the controller, can anyone help me with this error?

pallid gale
#

Question: there's an Editor/Click action that's defined and works fine when you first load the game. When you then load in another scene on top, it doesn't work any more, and the action has disappeared from the list of actions in the Input Debugger. All other actions are still there. Anyone got any insight into that?

torpid star
#

Why would I use the Invoke C Sharp Events behaviour? for my input component?

austere grotto
#

Don't. It's not what you think it is.

royal stream
#

Question: How do you receive different keys from the keyboard, into one script, with the Input System? I'm trying to set up a different action when the user presses one of key 1, 2, or 3 (I only need one key at a time). I think the process should work similarly to using WASD, where the one script accepts one of the keys, and then takes action. I've got it working pressing the 1 key, but I need it to activate the script for the other keys, and for the script to determine which key was pressed. Any help, or direction to a webpage with this would be greatly appreciated. Thank you!

vocal jay
#

Why not just set up one action for each key?

royal stream
#

@vocal jay Thanks. If I understand you, it would mean a separate method for each key. It may be up to 10 keys. I don't want 10 methods. I'm very new to the new Input System.

vocal jay
#

Do all the keys do the same thing?

royal stream
#

@vocal jay Each key will change several variables, to different numbers.

vocal jay
#

You can read the control from the callback parameter

#

Probably best for what you are attempting

royal stream
#

I tried to read it, but I think it's not getting sent, because I don't have it set up right in the Action Map. Here's my Action Map:

vocal jay
#

The gravity speed change action?

royal stream
#

Yes.

austere grotto
vocal jay
#

You should be able to define as many bindings as you want, and then check the actual control from the CallbackContext

vocal jay
#

Mainly for rebinding purposes, but @royal stream already knows of that solution and doesn't seem to want to go that direction

austere grotto
#

I've been down this road

#

it's not worth it

vocal jay
#

Personally I find reading the path / name / whatever from the callback to be iffy

austere grotto
#

everyone's got to make their own mistakes though ¯_(ツ)_/¯

vocal jay
#

Since it doesn't seem to work at all from what you mentioned

royal stream
#

It's possible that I'm misunderstanding, because I'm so new on the Input System. To be clear, do I set up separate actions, like GravitySpeedChange1, with the 1 key, then a GravitySpeedChange2, with the 2 key, etc.

vocal jay
#

That's how I would do it, but I feel like having 10 controls for this is a bit much. Some other input method would seem more appropriate

royal stream
#

The 2 key is not calling the script, which shows a Debug.Log.

vocal jay
#

But I depends on your project

austere grotto
#

Depending on the way you actually listen to the input actions, it should be relatively easy to dedupe the code for actually handling the input

royal stream
#

public void GravitySpeedChange(InputAction.CallbackContext context)
{
Debug.Log("1 or 2 was pressed.");
string numberKey = Keyboard.current.ToString();
Debug.Log("Pressed: " + numberKey);
}

torpid star
#

Having a seperate method of each key is a good thing.

vocal jay
#

e.g. not something like control schemes interfering

royal stream
#

@vocal jay I haven't, thanks. I'm checking it now.

#

Good news. The 2 key, which I could have sworn wasn't doing anything, is activating this script, along with the 1 key. I think I just need to have the script figure out which key is pressing it now. So the code I posted, I think (he adds confidently), is the problem.

#

It's showing this in the Console:

vocal jay
#

Keyboard.current is the current keyboard device

#

It has nothing to do with the callback

#

Information pertaining to the triggered event is inside the CallbackContext parameter

hollow cradle
#

Drag Touch Controls Are Clunky on Builds Using Touch Samples Code

royal stream
#

Oops.

#

Ok, can you tell me which parameter I need. I can't find the right one. I'm assuming I need string numberKey = context. but then what? Thanks.

austere grotto
#

go to the docs and look at what CallbackContext contains

royal stream
#

Thank you. I'm reading it now.

vocal jay
#

If you really want to only use a single action, a cleaner solution would be to use an input processor

royal stream
#

That's what I'm trying to do. I just need to read the key pressed, and the rest is obvious after that.

#

Although I think I need a composite binding, like WASD, but I haven't figured out how to set that in the Action map.

vocal jay
#

I don't think Unity supplies a composite binding of the type you are looking for

royal stream
#

That would be annoying. Although, unlike WASD, I don't need to read 2 keys pressed at the same time, so do I still need a composite binding?

vocal jay
#

The composite binding can read multiple keys and then decide what to do with them, outputting a final value

#

Whether or not you need to read multiple keys or not isn't really important for a composite binding

royal stream
#

I think I just need to know what key was pressed. This was simple in the old system.

vocal jay
#

I'll write you an example, that should explain it better

royal stream
#

Thank you. I'm having trouble finding an example on the Internet.

vocal jay
#

This obviously isn't super tested or anything, but the gist of it is something like this:

#
#if UNITY_EDITOR
[InitializeOnLoad]
#endif
[Preserve]
public class TenWayCompositeBinding : InputBindingComposite<int>
{
#if UNITY_EDITOR
    static TenWayCompositeBinding()
    {
        Initialize();
    }
#endif

    [InputControl] public int _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;

    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
    private static void Initialize()
    {
        UnityEngine.InputSystem.InputSystem.RegisterBindingComposite<TenWayCompositeBinding>();
    }

    public override int ReadValue(ref InputBindingCompositeContext context)
    {
        if (context.ReadValueAsButton(_0)) return 0;
        if (context.ReadValueAsButton(_1)) return 1;
        if (context.ReadValueAsButton(_2)) return 2;
        if (context.ReadValueAsButton(_3)) return 3;
        if (context.ReadValueAsButton(_4)) return 4;
        if (context.ReadValueAsButton(_5)) return 5;
        if (context.ReadValueAsButton(_6)) return 6;
        if (context.ReadValueAsButton(_7)) return 7;
        if (context.ReadValueAsButton(_8)) return 8;
        if (context.ReadValueAsButton(_9)) return 9;
        return -1;
    }
}
#

This lets you define a new input composite type

royal stream
#

Thank you. I will test it right now.

vocal jay
#

You will have to adapt the ReadValue function to determine how pressing multiple keys at the same time is handled, but you would have to do that regardless

#

The reason why your initial implementation of reading the CallbackContext.path field inside the callback isn't the best is because the point of the input system is to decouple the control used from the code executed, or you may run into nasty issues, as Praetor mentioned earlier

royal stream
#

Makes sense, but I wonder how people uncouple it for things like this. The number keys could be used for vehicle speed changes, or lots of things in games, so something is needed.

vocal jay
#

I mean it depends heavily on the context doesn't it?

#

You can do pretty much anything with a combination of composites, input processors and interactions

royal stream
#

Makes sense.

vocal jay
#

The idea is that the input system supplies the final "input value" generated by the whatever input device is supposed to be the input for the gameplay code in question, which the gameplay code can then consume

royal stream
#

Yes, I understand that this is the purpose of the new Input System, and it seems like a good idea, which is why I'm using it for this game.

#

Your code makes sense, and I think will be very useful, however I have a dumb question. Where do I put it, which script, or in a new script?

vocal jay
#

Inside a new script called TenWayCompositeBinding

royal stream
#

Thank you.

vocal jay
#

Note that you will only see the composite binding for the generic type you registered it for, in this case int, so make sure the action type and control type are set correctly.

#

e.g.

royal stream
#

Ok, it's looking better. It gave a few errors, which it suggested I add these:

#

using UnityEditor;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Layouts;
using UnityEngine.Scripting;

#

Which I did, and it is happy for the moment.

vocal jay
#

Yes, I omitted the imports earlier

royal stream
#

No problem. I mentioned them mainly so anyone else following this later, will have them handy.

#

I've got something screwed up here. It's not showing the Add Ten Way Composite Binding Composite, in menu with the Add Binding, like it shows in the image you sent. Here's what it's showing:

bold jackal
#

Hey for some reason, MenuDisplay works fine but the action map never gets disabled

vocal jay
royal stream
#

Action type is Button. There is no Control listed.

vocal jay
#

It needs to be value

#

Since a button is just an on / off state

royal stream
#

Makes sense, now. Control Type is set to Any. Still no Ten Way...

vocal jay
#

Control type needs to be Integer, since that's what the composite binding was registered as

#

InputBindingComposite<int>

royal stream
#

Sorry, I forgot - you said that above.

vocal jay
#

No worries, it's not very intuitive at first

royal stream
#

I've still got something screwed up.

vocal jay
#

Hit add a binding

#

Then right click the generated binding

#

The reason it works this way is that you might have a different input device that doesn't even require the composite

#

Similar to how the four way binding for WASD works, that's mainly since keyboards aren't very good at creating analog directional input for games

#

But a gamepad won't require the composite, you could just use a control stick (a single binding) to generate a Vector2

royal stream
#

Makes sense. Unfortunately this is what I've got now:

vocal jay
#

Let me check real quick

royal stream
#

Thanks.

vocal jay
#

Do you have any compile errors?

royal stream
#

No compile errors.

vocal jay
#

Odd, the InitializeOnLoad attribute is on the class?

royal stream
#

It's exactly as you typed it, except for the 4 using statements.

#

Do I have to put this script in a particular folder?

vocal jay
#

Not as far as I know, but you should have 5 using statements

#
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Layouts;
using UnityEngine.Scripting;
royal stream
#

Yes, I have all 5. The first one was already in. I just added the 4. But not with the condition of UNITY_EDITOR. I'll put that in.

vocal jay
#

That's just to stop your build failing, it won't make the composite appear

#

The only other suggestion I have is to restart the editor, maybe something broke with the input system registration

royal stream
#

The Ten Way is showing up now!

vocal jay
#

I'm off to bed, good luck on getting it working

royal stream
#

If you have time for one more question. How do I read the value in my code now?

vocal jay
#

The same as you would any other input action. Set up the callback, and if you perform the action (pressing any of your composite keys), the callback will be called, letting you read the value returned by the composite using the CallbackContext.ReadValue<int>() method

royal stream
#

Thank you. I'm still very new to Input System. I tried this:
int x = context.ReadValue<int>();
Debug.Log("Pressed: " + x);

#

@vocal jay If you've gone to bed, I hope you get this in the morning. I'll figure out the last part. THANK YOU! very much for all your help. I hope this discussion here helps others, too. Have a great day!

vocal jay
royal stream
#

The code above is not working to print x.

#

It's giving errors.

#

InvalidOperationException: Cannot read value of type 'int' from control '/Keyboard/1' bound to action 'Player/GravitySpeedChange[/Keyboard/1,/Keyboard/2]' (control is a 'KeyControl' with value type 'float')
UnityEngine.InputSystem.InputActionState.ReadValue[TValue] (System.Int32 bindingIndex, System.Int32 controlIndex, System.Boolean ignoreComposites) (at

#

It seems to think it's a float.

vocal jay
#

Are you sure you registered your function to the correct input action?

royal stream
#

I missed setting the "Path" here:

#

It's set now, but still errors:

sullen lintel
#

make a thread

royal stream
#

InvalidOperationException: Cannot read value of type 'int' from control '/Keyboard/1' bound to action 'Player/GravitySpeedChange[/Keyboard/1,/Keyboard/2]' (control is a 'KeyControl' with value type 'float')
UnityEngine.InputSystem.InputActionState.ReadValue[TValue] (System.Int32 bindingIndex, System.Int32 controlIndex, System.Boolean ignoreComposites) (at

vocal jay
#

Did you save the asset?

royal stream
#

Nope. 🙂

#

It still gives errors. Seems to think it's a float. I tried changing my code to float, and got no errors, but it still didn't work. ??

#

This is the code:

#

int x = context.ReadValue<int>();
Debug.Log("Pressed: " + x);

vocal jay
#

Is the GravitySpeedChange action correctly set up as Value and Integer?

royal stream
#

Yes.

vocal jay
#

Try defining bindings for all parts, not sure if that's an issue

royal stream
#

Okay.

vocal jay
#

Actually, I think the issue is that you are reading GravitySpeedChangeOLD

royal stream
#

I don't think so, however, I deleted the OLD one and am re-running it.

#

I think you are right.

#

Cannot find action 'Player/GravitySpeedChange[/Keyboard/1]' with ID '19dff998-6209-45e4-af6f-b2de8d037fea' in 'MyInputActions (UnityEngine.InputSystem.InputActionAsset)
UnityEngine.InputSystem.PlayerInput:OnEnable () (at

vocal jay
#

You'll need to update the action on the PlayerInput component in your scene

tame oracle
#

what is the right way to set set input button to false after it is pressed. Is that something that should be done in the StarterAssetsInputs? (I am extending the starter assets third person controller).

For example I have an item pickup, so I would have

if (starterAssetsInputs.pickup)
{
  PickUp();
}

but it would end up detecting that it was true even after I let go, I guess maybe it was in a completed state or something?
so I cleared the input after the action to fix that.

private void Update() 
{
  if (starterAssetsInputs.pickup && inRange)
  {
    PickUp();
    ClearInputs();
  }
}

private void ClearInputs()
{
  starterAssetsInputs.pickup = false;
  starterAssetsInputs.drop = false;
}

but then the issue I ran into is, the input is only cleared if if pickup the item, which I only do if I am inRange. So I can press the button while out of range, then walk into range and it auto-picks up.

so I ended up just moving ClearInputs() at the end of my Update()

but I get the feeling that is more of a workaround and not actually the correct way to use the input system?

vocal jay
tame oracle
#

correct

vocal jay
#

I would do that with a callback instead of polling the input

#

InputAction.performed

#

Subscribe your handler to that

royal stream
#

@vocal jay I'm working on it.

tame oracle
#

So I would just do starterAssetsInputs.pickup.performed?

vocal jay
#

I'm not sure what type pickup is, but if it is an InputAction, then yes

#

This is the example from the docs:

    // Create an Action that binds to the primary action control on all devices.
    var action = new InputAction(binding: "*/{primaryAction}");

    // Have it run your code when the Action is triggered.
    action.performed += _ => Fire();

    // Start listening for control changes.
    action.Enable();
#

Fire would be your Pickup in this case

tame oracle
#

ahh I see

#

thank you

royal stream
#

@vocal jay YES! YES! YES! It works!

#

@vocal jay The Input component wasn't updated, probably when I renamed the actions to point at my old method. Thank you very much! Have a great day!

vocal jay
#

You too, glad I could help

dense gale
#

why might it be that even though I have if(context.performed) in my methods for input, I get double input?

austere grotto
#

for example a joystick input will fire the performed event every time the actuation amount changes to a new non-zero value from any other value.

dense gale
austere grotto
#

pass thrugh will always give you performed

#

whenever anything changes

#

you should use Control Type: Button

dense gale
dense gale
austere grotto
#

Just bind it to Pointer/press

#

that will work for both mouse click and touch taps

dense gale
austere grotto
#

better to use pointer

#

as it works for both mouse and touch

dense gale
jade aspen
#

How do i get drag to work with the new input system on UI?

#

please i need some help getting this to work

#

iguess ill just stick to the janky bybrid system for now

#

im out of time to figure out how to get touch working for this

#

there doesnt seem to be much information on it and im concerned about affecting other systems

jade aspen
#

please I need some help to get started with this

junior spade
#

is there a way to display an input binding path as a dropdown or context menu inside of my own class?
i.e. public InputBindingPath path;

#

I want to avoid having to manually type paths as strings inside of my custom class

junior spade
#
var devices = InputSystem.devices; // Only gets currently connected devices.
var controls = devices[0].allControls; // Only gets controls for selected currently connected device.```
I could build a path based on values fetched from these in a custom inspector but this limits me to only the devices I currently have connected in the editor which could have issues on disconnection of a device you're working with or at runtime.
#

unity is able to pull off this context menu, I don't see why they can't open up the functionality :/

junior spade
#

is there a way to find a list of all supported devices?

stone oriole
#

How I can fix this error? /* Doesn't work

sullen lintel
stone oriole
#

I tired man but its doesn't work

sullen lintel
stone oriole
#

How can I find out?

#

Or how can I fix it

sullen lintel
stone oriole
#

Built in

sullen lintel
# stone oriole Built in

right so you may have something trying to access a Shader graph param which builtin has no clue about.. You could delete the offending asset/package and refresh cache or you could maybe switch it to URP and rebuild again, n see if that fix.. regardless backup your project before making changes

#

@stone oriole don't forget to backup the project before switching pipeline

stone oriole
#

I created a backup im going to do it now

junior spade
#

but gets all layouts, then gets their controls, then allows you to filter based on input layout type, i.e. vector2/delta/button etc.

late girder
#

Can somebody help. I have a movement script and a variable doesn’t want to show up.

#

Editor: 2021.3.6f1

austere grotto
#

InputMaster is most likely your generated C# class from your input actions asset right?
That class is not serializable

late girder
#

Yes

austere grotto
#

you're supposed to create it with new

#

go look at whatever tutorial you followed

junior spade
austere grotto
#

nah you can't

#

the callback needs a parameter

#

that's not relevant to their immediate problem either

junior spade
late girder
austere grotto
#

You still have to follow it properly

late girder
#

Is it outdated?

#

I did

austere grotto
#

yes somewhat but not enough that it will matter

#

you didn't

#

you're missing a line of code

#

there should be somewhere they are assigning controls to a new instance

late girder
austere grotto
#

ah ok

#

yes it's just an outdated tutorial

#

you need controls = new InputMaster(); in Awake

junior spade
austere grotto
#

yes it's an event

junior spade
junior spade
austere grotto
#

so it can't be subscribed to performed directly

jade aspen
#

is there a way to get touch input working with the new input system on UI elements?

#

I have the input system UI Input module attached to the event manager and in scene

#

the problem is that this only seems to work when im not simulating touch screens

#

but I need to be able to test the UI out with touch input to ensure it is all working correctly when the project is built and that whatever touch interactions im building work correctly

jade aspen
#

it does work when touch simulation is off

#

but turning touch simulation off breaks the parts of the project that rely on the new input system

#

so I need to get the touch system of the new input system to work with the ui

#

is there a way to get the new input system touch input to connect to events like on pointer down?

#

sorry i know im probably missing quite a bit here

#

Im still learning about the new input system and it does feel like the touch section of the new input system while powerful lacks some inportant information about how it should work

#

granted I probably have not read up on it fully, but i am having trouble locating a section on the touch input

jade aspen
#

is enhanced touch compatible with the new input system?

#

cause I think that simulated touch does not work with the new input sytem touch, but that enhanced touch works with that

#

that is atleast what I can see in the editor

tame oracle
#

I'm using the old unity input system on 2021.3.2f1, and my inputs work only in the editor. When I build the game it doesn't detect any controller input. I tried upgrading the input system, which didn't work either

#

Is this a common issue?

junior spade
#

new input system is generally done via a subscribing class that sits on some object in scene and listens to events

#

---- For my own question, anyone know how I can setup my own input binding etc. without creating an action map in the "Player Input Actions (Input Actions)" inspector window and auto generating a template class.

torpid star
#

No idea whats causing this error

#

Only happens when I activate the button

#
yield return new WaitUntil(() => playerActionAsset.Player.Interact.triggered);```
#

Comes from this line

#

[SerializeField] private PlayerInputScript inputScript; im sure its the correct script.

tame oracle
#

Hi ive been making a game and i wanted to know why i cant see the edit aspect in the inspect

#

this is what its ment to look like

#

this is what it looks like

red widget
# tame oracle this is what it looks like

Edit Asset*
The stuff in the Inspector changes depending on what's selected in your project. In the tutorial you're following, the dude has the Input Actions Asset selected in their project files, that's why it's appearing in the Inspector.

red widget
#

I wonder why you need it to appear in the Inspector in the first place, but here goes
Go in your Assets and search where you put the "Playerimput" asset, and select it by clicking on it

tame oracle
#

omg

#

im stupid

#

sorry

red widget
#

Btw you really should make the names exactly as the tutorial does it, as names will be really important in the near future (you'll use them in code)

real shell
#

Anyone who notices that the callbacks for the new inputsystem takes a lot of cpu time on android? With my current game it can easily take 30-40ms when it process inputs and I use the supplied on-screen button/joystick scripts but I don't think that is the bottleneck

real shell
#

Connected my device to my computer with a cable and did av development build and ran the unity profiler. In the build window you have theee checkboxes. I think it is development build, start profiler and autoconnect profiler and then you are running 😉

faint oak
#

is it better to select unity or c sharp events when deciding the input action behavior?

austere grotto
#

You mean PlayerInput

#

You select whatever you want to use

torpid star
#
inputScript.playerInputActions.Player.Interact.triggered```
#

This seems to be triggering multiple times.

#

I don't know how to make it similar to GetKeyDown

#

im trying to do this

#
void Update(){
        if(inputScript.playerInputActions.Player.Interact.triggered){ //seems to be triggering multiple times.
            DisplayNextSentence();
        }
    }```
#

But it just skips to the end

#

Yeah, it seems like Im triggering it twice.

#

How do I get it to only trigger once?

#

Is my settings wrong for the player control map?

torpid star
#

When I press the space bar it triggers and then I let go, it triggers again.

#

How do I stop this!

torpid star
#

Huh?!

somber star
#

Is there something special I need to do to see the InputRecorder class?

#

No matter which version of the InputSystem I install, it doesn't exist, despite being in the docs

#

never mind! Figured out it's one of the samples, and I needed to bring that in

gleaming oar
#

huh I haven't had issues with the input system being buggy and triggering multiple times

#

all issues related to that have been my own user error

gleaming harness
#

Hello, is it possible to hit two different colliders at the same time with the new input system? I have a sphere and a cube, both with a script that will print something on pointer hover, with the IPointerEventHandler interface.

They work fine until I put the sphere into the cube (photo), is there anyway to trigger both colliders with the new input system?

olive mortar
#

though, your original question isnt related to Input manager / System at all

austere grotto
cold reef
# torpid star

It's supposed to work that way. The triggered function can take a CallbackContext argument, which you can use to check if the button was just pressed, released, or being held down.

#

    public void SomeInputChanged(InputAction.CallbackContext context)
    {
        if (context.canceled)
        {
            // Button was just released
        }
        else if (context.performed)
        {
            // Button was just pressed
        }
        else
        {
            // Button is being held
        }
    }
#

But yeah this feels pretty bloaty for me too, I mostly stick to the old Input system. You can use both in your project btw.

spring agate
#

I'm using the new input system and all of my of my vector2 composite inputs stopped working on one of my two action maps. I recently upgraded my project from 2021.3.2f1 to 2021.3.9f1 which might be the cause, except it has been a week and I don't know if the issue actually showed up at the same time. Can someone help me troubleshoot this? What settings should I review? My game's code seems to be fine, I haven't changed any of the input handling code since a while before I noticed the problem.

spring agate
#

Oh, looks like this is a known issue in input system 1.4.1

lament roost
#

How can I get this binding?

sharp holly
#

anyone know why I cant find the InputSystem.Flightsticks class anywhere in my project? I have a functional Joystick setup, but I want to implement Flightstick instead so I can have access to throttle etc

lament roost
austere grotto
#

Make sure you look at docs for the correct version

lament roost
#

This annoying shit bugs me sooo much. How can I avoid it?

#

nvm fixed

crimson crater
#

I'm using an on screen joystick for mobile input (that i added into a normal game that wasn't meant for mobile, just wanted to test it and it runs surprisingly well) but if i use it, i can't look around at the same time. IE if i start using the joystick first, the camera will move too. How do i handle that? How do i make a zone where the touchscreen doesn't work?

bright rock
#

I dont know if this belongs here but i'm getting crazy trying to figure why my input field (TMP) clears the content when i press back button on mobile (i already uncheck the "Restore on ESC Key" in case that counts as "ESC" but it stills clears the content)

sharp holly
#

@austere grotto when browsing docs using the drop, I can only access 1.4, google points me to 2.0 and manually subbing 3.0 just doesnt give me any docs

austere grotto
sharp holly
#

aaand im a massive drongo

#

my brain really caught onto that being 2.0

#

That helps a lot thank you. Looks like they removed 'flightstick' at somepoint, so i'm back to square one on finding a way to access my stick throttle, but looking in better areas now at least

knotty estuary
#

Hey all, Im using the unity input system implementation from the 3rd person controller. Ive managed to get hold to work from sheer luck but tap isnt working.

Ive added a debug to the state but it always, not matter the interval i give, returns a false new state. Any idea how to fix this ?

public void DodgeInput(bool newDodgeState)
        {
            dodge = newDodgeState;
            Debug.Log("Dodge :" + dodge);
        }
#

the dodge action type is value and control type is any

austere grotto
knotty estuary
#

If I change it to button it is the same problem. It only ever sets the dodge to false, never true

knotty estuary
austere grotto
#

that's the thing that will call your OnDodge method

austere grotto
#

remove all interactions and processors and use action type button

knotty estuary
#

could it be that both the dodge and sprint use teh same binding ?

austere grotto
#

shouldn't matter

knotty estuary
#

Once again I really appreciate the help you are providing

austere grotto
#

what happens if you do Debug.Log($"val is {value.Get<float>()}"); inside OnDodge?

#

(also do you have any interactions/processors on shift?)

knotty estuary
austere grotto
#

although I wonder if that affects things 🤔

knotty estuary
#

So i removed the hold interaction on shift within sprint.
I then added your code to on dodge, and the output was only ever :" val is -1"

#

I changed it to passthrough , any and it then gave -1 (on press), and 0 (on release)

austere grotto
#

Does that change anything?

#

-1 is strange - should be 1 usually for a keyboard press 🤔

knotty estuary
#

Ngl im so imbarrased to say this, but there was an invert modifier. It was small so i didnt notice it, im so sorry.
So should I now try button with tap processor ?

austere grotto
#

you shouldn't need any processors

#

or interactions

#

or modifiers

knotty estuary
#

So should I hard code for tap ?
As I want the player to roll on tap and sprint on hold, similar to warframe.

austere grotto
#

wdym hard code

#

the problem here is you're using SendMessages mode which only gives you an InputValue which is a vastly simplified data structure than you get using other methods

#

your best bet without changing that is to perform the roll directly inside OnDodge

#

rather than having it set a bool value which you check later

#
void OnDodge(InputValue v) {
  if (v.IsPressed()) {
    PerformDodge();
  }
}```
knotty estuary
knotty estuary
austere grotto
#

I see

#

Idk it's kinda hard with SendMessages

knotty estuary
knotty estuary
austere grotto
#

unity events will be better

#

you'll get a CallbackContext which will have more information

knotty estuary
kind helm
#

I want for the player to need to hold shit to sprint, what should I do ?

austere grotto
#

simple set a bool to true when the action is started and false when it is canceled

mild vortex
#

Is there an IPointerClickHandler equivalent for the new system?

sullen lintel
#

you just want mouse clicks you mean?

mild vortex
#

Yeah, I was under the impression it wasn't working with it. I have a UI item that uses it but its not picking up any clicks, so I was under the impression it just wasn't working because of the input system.

sullen lintel
mild vortex
sullen lintel
mild vortex
#

I'm guessing you're talking about the "Add Default Input Modules"?

#

..Nevermind, I got it. Thanks.

sullen lintel
pine lake
#

just going through the player movement guide in the pinned post, up to the part where i test it all and i have no player movement, i also have no errors. Is there a common mistake thats made? or things to check

#

only thing i couldnt do is set my projects api to .NET 4.x as it only shows .NET or .NET 2

pine lake
#

the pinned post

#

ive got it moving, sort of haha, ill finish the whole guide and see how it turns out

pine lake
#

Every guide i find is all different to each other, so confusing xD

austere grotto
#

There are many valid ways to use the new input system, which makes it confusing for newcomers.

mild vortex
#

I need some help debugging; as with my earlier problem, I'm using IPointerClickHandler and my monobehaviour isn't receiving and function calls. I gave it a Debug.Log statement to show if it was called at all, and its not being called. Its attached to a game object with an image component that is enabled and has a sprite with a positive alpha. The event system has the updated input and has mapped player actions to a "Pass through - Button" for both the left and right clicks, as well as a "Pass through - Vector2" for the Point field.

austere grotto
#

Also generally the default input actions asset is sufficient for the action mappings in the input module unless you have special needs

mild vortex
mild vortex
austere grotto
#

Make sure Raycast target is enabled on your image as well and that it's not blocked by any other objects

mild vortex
mild vortex
mild vortex
#

Hold on, that may be it. I have a textfield that only shows at the bottom portion of it, lemme see if thats the issue.

#

That was it, thanks @austere grotto !

#

How might I keep it from blocking the raycast though?

kind helm
pine lake
#

Every video i watch on the input system, it is coded differently, is there a "best" way to do it or does it not matter which method is used? such as events or using the send messages way

#

my game will be including multiplayer if there is a way optimal for that

austere grotto
#

"including multiplayer" is quite vague

late inlet
#

I reall thought i had this whole "new input system" down and understood it. I used it for my whole project and everything worked fine. I've been using several Control Schemes, binding joysticks, gamepads, keyboard, mouse, virtual joystick. I recently decided to change something in the way my touch input worked. Instead of just reading the value in the Update loop, i decided to subscribe to started canceled and performed events so i could keep track of an offset (instead of moving under the mouse/finger you could touch somewhere on the screen and that would be the offset - your movement would be based off the "starting position".

        private void OnEnable()
        {
            // TouchSimulation.Enable();
            // EnhancedTouchSupport.Enable();
            _camera = Camera.main;
            _actions = new PlayerControls().PlayerPointer;
            _actions.Position.started += TouchStarted;
            _actions.Position.canceled += TouchCancled;
            _actions.Position.performed += TouchPerformed;
            _actions.Enable();
        }

I played around with the Actions trying to get it to work but i can't seem to get any of those events to fire...
My action type is Value (i tried passthrough and button as well) and my Control Type is Vector2 (i tried any as well)
My binding is Position [Mouse] but i tried a lot of different types...
I sometimes get a single started - many performed but never a canceled - meaning the first touch will be the offset - if i lift the finger/mouse it won't fire a new started.
Right now, no events ever fire.
I can't help thinking i'm missing something important but i can't seem to grasp what that is?

north rapids
#

hey i just started using unity a couple days ago and wanted to make an fps shooter so i followed this tut
https://www.youtube.com/watch?v=rJqP5EesxLk&ab_channel=NattyCreations
i followed it step by step but at 8:12 he does the code "playerinput = new PlayerInput();"
and when i wrote it it gave me error cs0029. anyone know how to get it fixed?

The first video in a series where we are creating a First Person game!
In this video we look at setting up our characters movement.

I've setup a Discord!!! and I would love to have you help me start up a friendly community where we can all help each other grow as game developers!

Discord invite link:
https://discord.gg/xgKpxhEyzZ
Can't wait t...

▶ Play video
sturdy zephyr
late inlet
#

If i press my finger on the phonescreen and then drag that finger around - how do i know when and where i started the movement and how do i know when i lifted my finger again? How can i also read it, if the process is repeated somewhere else on the screen. This sounds like a simple and common use case. I watched several videos about the subject but none showed me how to capture the first touch point and how to to know when the finger is lifted. Is it not possible in unity with the new input system?

#

Or do i need two actions? One to track the movement/position and one to track the finger press and lift?

trim hollow
#

Hi any idea where this performance issue can come from ?

#

I get this 30ms spike pretty often

high seal
#

Could anyone help me with a Inspector referencing issue with my array of a custom class? The second item I add in the inspector window seems to be referencing the first item in my array and when I go to edit the second item, it seems to be editing the first item as well.

wind sandal
#

Hey. What's way to get a character to rotate to mouse position in 3d with the new input system?

tame oracle
#

Is the new input system more fast and optimised than the classic GetAxis

lyric mountain
olive mortar
#

I only get these errors when i connect to the game and a remote player is playing. If i join solo i dont get these errors. The input's are only active for the local player, as i destroy the components for remote players. does anyone know why this would be happening/

        if (GetComponent<Player>() == null) //`Player.cs is local player
        {
            Destroy(GetComponent<FirstPersonController>());
            Destroy(GetComponent<CharacterController>());
            Destroy(GetComponent<UnityEngine.InputSystem.PlayerInput>());
            Destroy(GetComponent<InputHandler>());
            Destroy(GetComponent<GamePadInputEvents>());
        }```
#

Destroy(GetComponent<UnityEngine.InputSystem.PlayerInput>()); this line is causing the three errors

#

perhaps i need to disable it first? idk

olive mortar
#

any time i destroy an object with the component on it, it just spams the console, Why is this a thing

alpine umbra
olive mortar
#

which is the destroy line

alpine umbra
dim sinew
#

So I'm having an issue with the Multiplayer Input System where the first player is not getting UI inputs but the second player is. I'm not understanding what is going wrong

My set up
I have the PlayerInput component on a Player GameObject and I have the Multiplayer Event System on a child object of the Player GameObject. What is weird is if I have 1 player this set up works. But when I add a second player only player 2 gets UI inputs.

#

Hopefully someone can help me out because I'm super confused as to why this doesn't work as described in the docs

dim sinew
#

After messing around with it a bit it seems that it is only letting me process input for the last player that was joined through the Player Input Manager 😕

dim sinew
#

After more testing it seems the Canvas Group that gets attached during player joining has its interactable state set to false when a new player joins 😕

#

Not understanding why that is

glossy cargo
#

Anybody have a script for brackeys 2d movement converted to the new input system?

hallow solstice
#

How can I get mouse movement?

austere grotto
#

By binding an input action to mouse delta

hallow solstice
#

This makes very snappy rotation

austere grotto
hallow solstice
#

This is where it actually rotates

austere grotto
#

mouse input is already framerate independent

hallow solstice
#

ah

#

Now the problem is that it snaps to angles vertically

#

it's not smooth rotation

#

Oh it was just high sensitivity fucking it up

austere grotto
#

it'll be as smooth as you move your mouse... and as fast as your sensitivity allows

olive mortar
#

using a mac and input system isnt recoginising the built in keyboard, input.devices length is zero

#

anyway around that?

#

no input is recognised on mac at all. no mouse no nothing

valid aspen
#

I'm not sure if my problem is with the input system or something else but after I changed from the old input system to the "new" one my movement has completely broken down. I can only move sideways and even after I look anywhere else the A and D keys move on the same axis as they did when I was facing forward. It almost seems like there's a wall behind and in front of the player. Has anybody else had this problem before or can anybody help.

#

I have made the scripts for movement and mouse and checked through them multiple times but can't figure out what's wrong

cobalt ivy
#

i am having some issues with my code that will not recognise my vector input for my second action map. i change to my new actionmap and the vector input stops working. buttons per se works though which is strange

#

i seem to be able to get vector debug output from the input context but it does not register into the variable i am trying to store it into

#

oh... just figured out that i was instancing the thing that i wanted to switch action map to use. this is a no no, because of it not being the same entity

#

i feel silly 🤔

knotty estuary
#

Heyo, Im trying to subscribe to an action event. Do i have to do it through the generated c# class, or can I not do it through the input actions asset ?

olive mortar
#

PlayerInput component

#

you pass in events like you would like a button OnClick

#

you can use the generated class, or the player input component

#

example

austere grotto
unreal crane
#

Could someone explain to me what's happening under the hood?

#

I understand that the InputActionReference calls the function Fire with context when the key bound to it gets pressed

#

But why the += syntax? What really is m_Fire.action and m_Fire.action.performed?

lyric mountain
#

The += syntax is a delegate subscription to a method in your script called Fire. When performed is triggered, it will call your Fire method and execute what's in there, along with giving you a CallbackContext struct datatype, which contains some helpful information like what action got triggered.

m_fire is your action map, it contains a list of actions. You can have multiple action maps which help you sort your actions, and allows you to easily disable and enable a set of actions depending on the situation. Your actions are your buttons which you assign an input to.

Oh, and performed is the trigger method, and in this case is used in a trigger once scenario.

midnight swallow
#

Hey guys i am trying to use the new Unity Input System and want to Check in which direction i am moving. currently i am checking like this:

    {
        playerMovement = value.Get<Vector2>();
    }

    public void ThrusterMovement(Vector2 playerMovement)
    {
        
        if (playerMovement == new Vector2(0,1))
        {
            transform.GetComponent<Rigidbody2D>().velocity += playerMovement * 5f * Time.deltaTime;
            thrusterEmmision.enabled = true;
            thrusterEmmisionIdle.enabled = true;
            thrusterAudio.enabled = true;
            if (thrusterTwo)
            {
                thrusterEmmision2.enabled = true;
                thrusterEmmision2Idle.enabled = true;
    
    
            }
            else
            {
                transform.Rotate(new Vector3(0, 0, (rotationvelocity * 0.8f) * Time.deltaTime));
            }
        }
        else
        {
            thrusterEmmision.enabled = false;
            thrusterEmmision2.enabled = false;
            thrusterEmmisionIdle.enabled = false;
            thrusterEmmision2Idle.enabled = false;
            thrusterAudio.enabled = false;
        }
    
        if (playerMovement == new Vector2(0, -1))
        {
            transform.GetComponent<Rigidbody2D>().velocity -= playerMovement * 1f * Time.deltaTime;
        }
    
        if (playerMovement == new Vector2(1, 0))
        {
            transform.Rotate(new Vector3(0, 0, -rotationvelocity * Time.deltaTime));
        }
    
    
        if (playerMovement == new Vector2(-1, 0))
        {
            transform.Rotate(new Vector3(0, 0, rotationvelocity * Time.deltaTime));
        }
    
    } ```

The Problem is that if i want to move to left or right while moving upwards the player doesnt do both.

I am currently checking with a "new Vector2(x,y)
But i would like to check it with the Input i am doing like "W" "S" "A" "D"
unreal crane
#

Read some docs for delegate and events and I think I now get it. Thanks

pulsar mist
#

What is a clean way of disabling an action map through an input manager while using 'Player Input' components? I read that they all have their own inputActions script instance so simply calling inputAction.Enable() won't work, and yes, I've tried....

low summit
#

help i got an error with the new input system

vast sonnet
#

im trying to make a cod like movement system, how do i do that?

jagged wyvern
vast sonnet
#

?

jagged wyvern
#

movement system != input

vast sonnet
#

yeah but like

#

sliding

#

and fast paced

#

and sprinting

jagged wyvern
#

we need more specific qurstions

vast sonnet
#

okay fair

frigid kernel
#

Why does InputActionTrace stop recording values once you call .Clear() on it? Am I being dumb and misunderstanding what Clear() is supposed to do? As far as I can tell it just completely breaks the InputActionTrace causing it to just sit around and record nothing. I also tried resubscribing to my InputAction after the Clear() but it just sits there and records nada. I thought that method is for resetting the internal buffer in order for the memory to not balloon forever. Or are you supposed to just, Dispose of it and new it again every 5 seconds or something to get rid of the memory?

Context:
I'm using the new InputSystem and currently have the need to lookup past inputs of buttons/sticks to disambiguate between "letting go of the stick" and "flicking past the deadzone".
Basically I'm trying to make an input buffer that lets me record and lookup the past X values for an InputAction to drive my input logic.

So when looking around I came across InputActionTrace which does the recording part and getting out the values is ez pz.... if you don't call Clear() on it.

Anyone have any pointers for clearing the memory of an InputActionTrace without breaking it or any other onboard construct to use?
Please someone tell my I'm a baka before I just start manually dumping the values into an array and wrap it with my own class or give in and new the InputActionTrace every n-th frame

upper echo
austere grotto
upper echo
#

yes as you can see I compared the mousePositions and linePositions count they're not the same. mousePosition count are always greater

austere grotto
#

well you're only adding to the line positions if your raycast hits

#

presumably sometimes the raycast is not hitting

upper echo
austere grotto
#

see if there are times when the raycast doesn't hit

#

that's where I'd start

tame oracle
#

for some reason I cant figure out why the new input system doesn't seem to work (probably me just dumb) every time I run I get a compiler error saying
INPUTASSETNullReferenceException: Object reference not set to an instance of an object
PlayerMovement.Update () (at Assets/scripts/PlayerMovement.cs:59)
what I'm trying to do is to recreate the old input system's get key function here is my code
https://paste.myst.rs/p5xdr3pn (sorry if its bad kind of new to unity) i get the error on line 59

delicate parcel
#

I am trying to figure out the proper way of implementing the "new" input system in a multiple-scene game. In runtime have DontDestroyOnLoad where I keep project context stuff and scenes like Combat, Exploration, and so on. I want to keep PlayerInput in DDoL since I want just one instance of it for one player and subscribe/unsubscribe input callbacks in specific scenes (combat-related in combat, exploration in exploration, and so on). Because UI interaction is common for all of those scenes I wanted to subscribe UI input only once, in DDoL init.
Here are my questions:

  1. Since I want to keep PlayerInput in DDoL I shouldn't be using new InputActionAsset() ctor in every scene, right? That would bypass the concept of PlayerInput actually controlling the input, switching maps, and so on because every scene would have its own input action asset. From what I understand these runtime-created input assets are not connected to PlayerInput and are not controlled by it.
  2. If so, how to properly pass a reference to PlayerInput to different scenes? I am using DI in my project and injecting PI causes weird problems either with unsubscribing actions in OnDisable or when using FindAction(string) in OnStart().
granite tree
#

The New Input System keeps referring to Events and Actions. Behind the scenes, are these C# and/or Unity Actions and Events?

lyric mountain
#

Yep, the input system is built around C# events and subscribing to methods, reducing amount of input polling you'd do otherwise.

scarlet scarab
#

Heya,

So im currently trying to do some stuff with VR.

I was wondering if there was any documents/examples about connecting Input devices (e.x Joysticks, Gamepads, huggable pillows) with USB-A to USB-C converter or bluetooth.
Or if it was possible to use a different input system and having the game on a VR.

Also is it possible to get the amount of input buttons on an input device and the name of the button?

Anyone have any tips?
Thanks in advance!

thick fossil
#

How do I use InputAction.ApplyBindingOverride(0, ""); to bind a key to "None"?
Or I suppose, is there an InputAction path for "none"
Or another way to unbind an action?

dire quartz
#

Hi, i'm having trouble canceling an action (for example walking) with the same button press when the action is being performed

#

here's my Awake() code

    private void Awake() {
        _playerActionControls = new PlayerInputActionControls();
        _playerActionControls.Player.Move.performed += ctx => _movementPressed = _movementInput.x != 0 || _movementInput.y != 0;
    }

so what's the logic behind canceling an action that's being performed

somber dirge
#

How do I spawn an UI under the mouse with the new InputSystem? O.o'

#

a tooltip, in my case... I don't get how to convert the coords 😕

#
    {
        Vector3 tdPosition = Camera.main.ScreenToWorldPoint(Mouse.current.position.ReadValue());
        Vector2 position = new Vector2(tdPosition.x, tdPosition.y);

        float pivotX = position.x / Screen.width;
        float pivotY = position.y / Screen.height;

        rectTransform.pivot = new Vector2(pivotX, pivotY);

        transform.position = position;
    }```

The tooltip still get positioned on the bottom left 😕
#

Ok transform.position = Mouse.current.position.ReadValue();
Fixed the issue now I need to find a way to keep it always on screen 😅

lament roost
#

Is this how the input system should be used?

austere grotto
#

you should not be subscribing to an event every frame

lament roost
#

how should it be used then?

austere grotto
#

either subscribe to the event once

#

Or poll the value of the action in Update

lament roost
#

poll?

austere grotto
#

read

#

check

#

same thing

lament roost
#

I am rn.

austere grotto
lament roost
#

isn't that the same as

austere grotto
#

reading the value would be like playerControls.Player.DropPickupLeft.WasPerformedThisFrame()

austere grotto
lament roost
#

?

austere grotto
#

reading the value each frame like my example is similar to that, yes

#

just replacing Input.GetKeyDown(somekey) with playerControls.Player.DropPickupLeft.WasPerformedThisFrame()

lament roost
#

I thought it was more organized to create a function for only input.

austere grotto
#

it's up to you

lament roost
#

what does .performed even do?

austere grotto
#

it's an event

lament roost
#

I know.

austere grotto
#

that gets fired when the action is performed

lament roost
#

and performed means?

#

to me it sounds like down.

#

(getkeydown)

austere grotto
#

it depends on how the particular input action is configured

lament roost
#

getkey?

austere grotto
#

for a button action, it's very similar to GetKeyDown, yes

lament roost
#

so what should I do?

#

what lines of code should I remove/add?

austere grotto
lament roost
austere grotto
#

Can you think of any way to only run code one time at the beginning of your script's life?

lament roost
#

awake or start.

#

although won't that mean that you must hold the button when the game is loading?

#

and then you can't trigger it anymore?

austere grotto
#

no

#

you're not understanding how events work

#

it would be subscribing to the event at the beginning

lament roost
#

oh

austere grotto
#

that subscription lasts forever

lament roost
#

like this?

austere grotto
#

sure

lament roost
#

or this?

austere grotto
#

doesn't matter

dire quartz
#

Hi, i'm having trouble canceling an action (for example walking) with the same button press when the action is being performed
here's my Awake() code

#
  private void Awake() {
        _playerActionControls = new PlayerInputActionControls();
        _playerActionControls.Player.Move.performed += ctx => _movementPressed = _movementInput.x != 0 || _movementInput.y != 0;
    }
#

_movementPressed bool stays true when i'm moving so how do i cancel it with the same button press when i'm moving to stop

austere grotto
dire quartz
dire quartz
austere grotto
#

?

dire quartz
#

let me share the sprint code

austere grotto
#

I'm confused about what the Move action actually is

#

is this a sprint button? Or joystick input?

dire quartz
austere grotto
#

I know it's the new input system...

#

How can joystick input be both a sprint button and move input

#

which is it

dire quartz
austere grotto
#

ok so Run is the sprint action

#

that's different, and not mentioned above

dire quartz
#

yeah

austere grotto
dire quartz
#

it works great but the problem i don't know how to cancel the action with the same button press that activated it

#
_playerActionControls.Player.Run.performed += ctx => _runPressed = ctx.ReadValueAsButton();
austere grotto
dire quartz
#

here's the run

austere grotto
#

something like this

dire quartz
#

i forgot to share it my bad

dire quartz
austere grotto
#

it doesn't really matter

dire quartz
#

because it gets activated only once right ?

austere grotto
#

that's not an important detail here

#

Awake only runs once

#

OnEnable runs every time the script is enabled

dire quartz
#

yeah at script run ok then

#

i'll try that

austere grotto
#

just a C# syntax error

dire quartz
#
        _playerActionControls.Player.Run.performed += ctx => _sprinting != _sprinting;
austere grotto
dire quartz
unreal crane
#

Hey could someone explain to me what purposes are "scheme" and "map" supposed to serve?

austere grotto
unreal crane
#

From my understanding, it's to put the actions under a two-layer categorical structure

#

But why do we need these two layers?

#

Say, why can't I just use one scheme and many maps for everything?

unreal crane
austere grotto
#

a scheme is like "mouse and keyboard" or "gamepad"

#

they are completely parallel to the concept of action maps and actions

unreal crane
austere grotto
#

why would you be stopped from doing it

unreal crane
#

Oh I mean

#

These two are under one scheme

austere grotto
#

no

#

well I mean

#

they can be

#

if you want

unreal crane
#

I made them so. The question is why would it be a bad thing?

austere grotto
#

It's up to you to define which devices/device types are part of a given scheme

unreal crane
#

Why should I consider using the scheme feature to separate them?

austere grotto
#

Several reasons:

  1. it gives a way for unity to automatically split up players by devices in local multiplayer games
  2. It makes it a lot easier to show contextual on screen prompts like "Press X to climb" vs "Press Space to climb"
unreal crane
#

How do I use a joystick push as a button?

#

I can read the Vector2 value of a joystick, I get it. But what I'm trying to implement is to set a deadzone, and once the joystick gets pushed beyond the deadzone, it's registered as a one-time event, like a button press

hybrid bay
#

Anyone ever heard/experienced keys getting 'stuck' when shift is held? For me the Input System specifically no longer registers any keyboard input changes when the shift key is held.

I'm on Linux and submitted a bug report about 13 days ago but haven't heard anything

#

Fair few threads on google about it, none with either a solution or a dev response

pine lake
#

or am i doing it completely wrong and should be using unity events?

austere grotto
#

you dragged the wrong thing into the slot

#

you dragged the script in

#

you need to drag in a GameObject that has the script attached to it.

#

really

unreal crane
unreal crane
#

new

austere grotto
#

deadzone can be configured on the action itself or the binding with a press interaction.

#

as for reading it like a button, just make it Action Type: Button

unreal crane
#

I guess I can still manually put the path in there but is that gonna work?

austere grotto
unreal crane
#

How do I define the press behaviour?

#

Oh nvm I think i can find it in the docs

#

Thanks

austere grotto
#

press only is fine

#

and the press point is your deadzone

unreal crane
#

Thanks. Exactly what I wanted

lunar root
#

Nvm, found out via the tooltip that's it the min time the button is to be held.

lunar root
#

Anyone know why I cannot put a Hold interaction on a WASD/move Vector 2 action? The only little info I've been able to find is that Hold is invalid on Vector 2 types

#

This my workaround, not pretty but I can get what I need from it:

#

Eh actually since it's a WASD/directional binding that won't work if I have other keys held down. I might resort to doing it manually

lunar root
#

For now I'm going with not using a composite binding and creating actions for each of the 4 keys. I get way more flexibility here and the keys are more independent. For UI I have a separate action map that uses the usual composite/vector2 binding instead

potent ledge
#

Hey I'm trying to get UI support working for a VR mod. I made a custom BaseInputModule and it's pretty much working for canvas stuff, but I'm having trouble with colliders in the scene that are listening to OnMouseEnter etc. The game uses a separate camera to render the UI which isn't necessarily in the same place as the game camera. But I'm wondering if OnMouseEnter etc aren't even triggered by the EventSystem - are they completely separate?

I'm starting down the path of just calling OnMouseXXX directly based on raycast results from the VR laser pointer, but if those things are supposed to work from the EventSystem then I'd probably rather use that.

tame oracle
#

Hey! I am working on a local multiplayer game and I got everything working BUT one thing. In a specific section of the UI, I want to disable the functioning of the second gamepad, however, I can't seem to find anything which can help me with that.

The old Input System had the option to to set the Joy Num. Any help = ❤️. Stuck on this for a while

austere grotto
tame oracle
austere grotto
tame oracle
solar kite
#

Using InputAction.CallbackContext is it possible to get the processors applied to input? I want to check to see if my mouseDelta is being scaled down.

olive mortar
#

How do i grab the second action in this in code?

#

and can i add / remove pre-processors on it at whim

sullen lintel
#

huh dont they both use Aim

olive mortar
#

yes, but i need to do something with the controller assignment

#
    private bool toggleADS = false;
    public bool ToggleADS
    {
        get => toggleADS;
        set
        {
            toggleADS = value;
            int isOn = value ? 1 : 0;
            aimAction.controller.Processor = value ? press : null;
            PlayerPrefs.SetInt(PREFS_TOGGLE_ADS, isOn);
        }
    }``` as an example, second to last line is entire psuedo code
sullen lintel
olive mortar
#

yea, i just want to add and set Press if value, else remove it

sullen lintel
#

is it not InputBinding?

olive mortar
#

I dont know, thats why im asking

sullen lintel
#

some good info in there might help. This new system hella confusing

olive mortar
#

on the processor doc, doesnt look like i can add and remove them

#

oh, i should be looking at interaction docs

clear flicker
#

can someone help me?

austere grotto
olive mortar
#

Yea, I ended up making two actions and disabling /enabling the appropiate one

wintry hawk
#

Does anyone know how to setup keybinds to a float? So for example when W is pressed I want the float to be 1, when S is pressed I want the float to be -1, and untouched is 0.

late inlet
austere grotto
#

In fact that axis is built in by default

lament roost
#

How can I do something like this? I want it to debug "Q", because that's what DropPickUpLeft is binded to.

lament roost
#

Nvm, this did it: ```cs
Debug.Log(rebind.Player.DropPickUpLeft.GetBindingDisplayString(InputBinding.MaskByGroup("Keyboard, mouse & gamepad")));

long belfry
#

why the inputs of the new input system are delayed and sometimes they don't work?

sullen lintel
long belfry
sullen lintel
long belfry
#

i followed a tutorial...

sullen lintel
#

and? most tutorials are shite

long belfry
#

the one from Dapper Dino

sullen lintel
pliant copper
#

Hey, is there any way for me to get the controls object to respect the current control scheme on the player input object? I need to check input every frame, so using the events on the player input object won't work for me, but when I just read from the controls object, it doesn't disable input from inactive control schemes. By the way, "controls" is the name of my input actions.

desert mauve
#

How do i add looking with a Console Controller

sullen lintel
desert mauve
#

I added it, but now my movement is working

#

it was working before i added looking

desert mauve
sullen lintel
desert mauve
#

yes

sullen lintel
#

just add the gamepad joysticks as input

desert mauve
#

ye i did

#

The looking isnt the problem

#

for some reason now i cant move

sullen lintel
#

well you said How do i add looking with a Console Controller

sullen lintel
desert mauve
#

ye i dont know, but i'll figure it out

soft gulch
#

Hi there, I need some help on the new input system 🤔
I've got a simple button action for Sprint. While the sprint button is down the player sprints, and when the sprint button is released the player stop sprinting.
Things work well, I can use WasReleasedThisFrame or canceled to detect when the sprint action is canceled = when the sprint button is released.

BUT, when the sprint button is down, if I move the mouse the sprint action is automatically canceled (even is the sprint button is still down).

Does someone know if it is normal than mouse movement auto-cancel button actions?
Thanks !

rustic sentinel
#

Whenever i try to bind any gamepad key to the Movement action, it's always the right thumbstick who calls the Movement action even if i dont have the right thumbstick binded to anything. Anyone had a similar issue like this? I dont have any idea if this is just a bug or i messed up with something. And every other gamepad button just does not respond, it's always the right thumbstick. Using PS4 Controller connected via bluetooth

lyric mountain
rustic sentinel
austere grotto
#

Also why would it work for keyboard at all?

#

You don't have keyboard bindings there. I think you've confused yourself with multiple input action assets or something

rustic sentinel
#

I added keyboard bindings for testing and it works fine there. But when i use the gamepad the right thumbstick always calls every action

austere grotto
#

Again show how you set it up

marsh sage
#

Hey, I just enabled automatic navigation for my UI. It's 4 buttons aligned vertically. It works so far, if I press the arrow down key, it goes down, if I press the arrow up key, it goes up, and when I press return, it "activates" whatever the button does. But I need it so it goes down on the right arrow key, and up on the left arrow key. How can I change this?

austere grotto
#

An/or by using manual navigation

marsh sage
dire quartz
#

I get this error when trying to access the PlayerInputActionControls from another script

austere grotto
dire quartz
hallow edge
#

Hello, I was wondering if anyone knew how you are able to reference specific gamepads as a variable so it is tagged and able to be used in a turn based game? I am trying to make a 4 player input system for a lobby where each gamepad is able to ready up a slot and need to figure out how to detect when a controller has already been pressed down thank you!

austere grotto
pulsar mist
#

If a PS4 controller is connected to my pc unity doesn't receive inputs from my keyboard and mouse anymore. Auto-switching is toggled on on all my Player Input components. Is there a general fix for this? The only way I can get my kb/mouse working again is to unplug the device or to remove if from the device list manually when using wireless

austere grotto
pulsar mist
#

I left the default schemes and just added a bunch of new controls to the keyboard scheme while leaving the controller one as default

#

Supported devices is set to gamepad, keyboard, mouse

austere grotto
#

Yeah sounds like you don't want separate schemes

pulsar mist
#

Why not? What’s the difference?

#

Do i have to view each scheme as it being a separate player?

austere grotto
#

Not separate player, no

#

Just independent sets of devices that won't be used together

pulsar mist
#

so if one is used the other simply cannot be used?

#

then what's the point of auto-switching control schemes?

hallow edge
austere grotto
#

yep that's what PlayerInputManager is for

hallow edge
#

alright thank you

pulsar mist
rustic sentinel
dark root
#

Hi all, I'm trying to implement multiple input devices support.
I have 1 InputActionAsset in which I defined 1 custom ActionMap for my player actions, and 1 Action map for the UI (copied over from the package asset).
The issue I'm facing right now is that whenever I press a movement action on my keyboard, it performs a navigate action instead (from the UI map).
The current action map is set to my custom action map and never changes at runtime. Anyone know why this is happening? Using PlayerInput component with UnityEvents.

dark root
#

solved the issue above but now the mouse can't interact with ui buttons

austere grotto
dark root
#

i do, yes

#

actually...

#

damn. I had a child canvas without a raycaster

#

thanks @austere grotto

delicate pollen
#

Hi there. Currently attempting to use the PlayerInput component set to SendMessages instead of getting a reference to C# script. In testing, I'm attempting to have a character run a 'block' animation when a button is pressed, and stop running the 'block' animation when the button is not pressed. Unfortunately, the only message that's being sent is OnBlock, so my 'Block' bool remains set to 'true'. Is there a standardised method for creating an 'on released' event?

austere grotto
#

if you use UnityEvents mode, you can get a callback context which will let you check whether the context is performed, started, or canceled

delicate pollen
#

This is what I get for using the Unity Third Person Animation template as a testing ground. =D I'll switch it over... or try, anyhow.

delicate pollen
#

@austere grotto Thank you, that worked perfectly.

pallid niche
#

Hello. Can anyone have a guess as to why my menu isn't navigable via mouse / keyboard, but it works fine with my two controllers? I have a keyboard set up in the input system.

austere grotto
#

input module is what links the input system and the UI/Event System

pallid niche
austere grotto
#

You input module. It's a component that is most likely on the EventSystem object

pallid niche
#

Oh yeah thats on the first screenshot

#

I haven't added any custom scripts to it

#

Is this what you mean

austere grotto
#

you'd have to look at all those actions you have set there

#

and see what bindings you have for them

pallid niche
bronze ridge
#

not sure where to ask this but

#

i got a script where holding down alt + WASD changes walking speed

#

but i cant actually see if it works

#

since alt + wasd or other keys opens up random stuff in unity

#

how to disable unity hotkeys in play mode?

#

nvm figured osmething out

dire quartz
#

player character movementpressed variable doesn't get activated unless i press vertical and horizontal input together

#
        _playerActionControls.Player.Move.performed += ctx => _movementPressed = _movementInput.x != 0 || _movementInput.y != 0;
dire quartz
#

the code clearly says that if one of them isn't = 0 then movement pressed should be on

#

but its not working as intended

#

both of them need to be pressed for it to activate

austere grotto
#

seems like that's coming from some separate code

dire quartz
#
        _movementInput = _playerActionControls.Player.Move.ReadValue<Vector2>();
austere grotto
#

why is it not just:

_playerActionControls.Player.Move.performed += ctx => _movementPressed = ctx.ReadValue<Vector2>().magnitude > 0;```
#

why rely on some other code and reading the same input action data nonetheless 🤔

dire quartz
#

interesting that's a better way to do it i guess

#

i'll try it

dire quartz
#

🙏

remote leaf
#

Hello World

#

I am just using the new unity input, and I made a player which moves when clicked (w or d key) or (left or right arrow), there is this behavior
-1 while left key pressed
+1 while right key pressed
0 while none is pressed

#

the only issue I am facing is, if i press the left key and then release it my player continues to move in left direction it does not stop

#
    private float _movementX;
    private void Awake()
    {
        _myBody = GetComponent<Rigidbody2D>();
        _playerControls = new PlayerControls();
        _playerControls.Enable();
        _playerControls.PlayerControl.Move.performed += context => { _movementX = context.ReadValue<float>(); };
    }

    private void Update()
    {
        MovePlayer(_movementX);
    }
#

any help is appreciated

austere grotto
#

to fix this with events you'll need to also subscribe to the canceled event

#

e.g. cs _playerControls.PlayerControl.Move.canceled += context => { _movementX = context.ReadValue<float>(); };

#

To do it with polling you can remove all the event subscription stuff and just do this:

void Update() {
  _movementX = _playerControls.PlayerControl.Move.ReadValue<Vector2>();
}```
remote leaf
#

while trying this, first error was cant use vector on float, so I fixed it by ReadValue<Vector2>().x but now I am getting some weird error

#
InvalidOperationException: Cannot read value of type 'Vector2' from composite 'UnityEngine.InputSystem.Composites.AxisComposite' bound to action 'PlayerControl/Move[/Keyboard/leftArrow,/Keyboard/rightArrow,/Keyboard/a,/Keyboard/d]' (composite is a 'Int32' with value type 'float')
austere grotto
#

I got confused because usually people use Vector2 for a Move action

#

(you should consider doing that if you have separate x and y variables...)

remote leaf
#

worked how I wanted it to, thanks a ton

remote leaf
remote leaf
austere grotto
remote leaf
#

What do you mean by polling

austere grotto
#

polling means "checking periodically"

#

in this case, checking the input value every frame

remote leaf
#

alright, thanks a ton for helping me out

faint oak
#

how would I pull a certain binding from an action? I have a dash function that isn't based on a vector2 value and i want it to dash in all 4 directions and have each direction being a double tap, and those directions are all under a dash action

lament roost
#

How can I shorten this? ```cs
playerControls.Player.Jump.started += ctx => Jump(ctx);
playerControls.Player.Jump.performed += ctx => Jump(ctx);
playerControls.Player.Jump.canceled += ctx => Jump(ctx);

#

Also, what's the equivalent of GetKey in context.{...}?

austere grotto
lament roost
#

exactly

austere grotto
lament roost
#

that's why I'm wondering if I can shorten it.

austere grotto
#

Why would you need all three for an action like jumping

#

also you can just do playerControls.Player.Jump.performed += Jump;

#

you don't need the lambda

lament roost
#

oh

#

ok

#

although then I can't use the parameter.

austere grotto
#

yes you can

#

try it

#

write it exactly how I wrote it

#

it will work

lament roost
#

although I want the parameter.

#

lol

austere grotto
#

you can use the parameter

#

please read

lament roost
lament roost
austere grotto
#

So?

lament roost
#

what should I put there?

austere grotto
#

listen to me Elliot

#

you don't know what you're talking about

#

I do

lament roost
#

ok

austere grotto
#

Write this:
playerControls.Player.Jump.performed += Jump;

#

that's all

#

don't change Jump

#

keep the parameter in the function

#

it will work

lament roost
#

how in the world is it supposed to know what the context is then?

austere grotto
#

the event passes it to the function when it is invoked

lament roost
#

invoked?

austere grotto
#

yes events are invoked

#

it's an event

#

this is you subscribing to an event

lament roost
#

what does invoke mean?

#

for events.

austere grotto
#

to invoke

#

trigger

#

fire

#

cause to happen

lament roost
#

bruh that's toxic.

#

the reaction.

austere grotto
#

I don't understand what you are asking

#

with your ?

#

so I put my own ?

lament roost
#

Common sense imo.

austere grotto
#

I don't understand what that inquiry means at this point of the conversation

#

we're well past that

lament roost
#

what

austere grotto
#

If you have a question just ask it

lament roost
#

What's the equivalent of GetKey in the new input system?

#

I literally did.

austere grotto
#

There isn't a direct equivalent

#

what we're doing with these events etc is the equivalent

lament roost
#

huh

#

What does context.performed do?

austere grotto
#

it returns a bool telling you if the action is currently in the performed phase

lament roost
#

bruh

lament roost
#

literally not what I meant.

austere grotto
#

I don't know what you meant I guess. I answered the question you asked though

lament roost
#

What does the performed input state do in the new input system that was released about 4 years ago in Unity?

austere grotto
#

performed in relation to an input action is an event that gets fired when the action "happens"

lament roost
#

after started?

austere grotto
#

performed in relation to a Callback Context e.g. ctx (which you asked about the first time) is a bool property saying "is performed happening right now?"

austere grotto
#

depends on the interaction set for the action

#

the system is somewhat complicated

lament roost
#

so what exactly should I use for GetKey?

austere grotto
#

what do you mean by that exactly

#

what are you trying to achieve

lament roost
#

what should I use instead of getkey?

austere grotto
#

gameplay wise

lament roost
#

I'm trying to detect if a specific key is currently being pressed.

austere grotto
#
void Update() {
  bool isCurrentlyPressed = myInputAction.IsPressed();
}```
lament roost
#

yeah I know about that.

austere grotto
#

that's more or less the GetKey equivalent

lament roost
#

Although I'm asking about the InputActionAsset equivalent.

austere grotto
#

the point of using the events etc is to not check in Update

austere grotto
#

with which you would do as I showed above

lament roost
#

I mean this.

austere grotto
#

that's the input action asset inspector, yes

#

what about it?

#
public InputActionAsset myInputActionAsset;

void Update() {
  InputAction myInputAction = myInputActionAsset["SomeActionMap/SomeAction"];
  bool isCurrentlyPressed = myInputAction.IsPressed();
}```
lament roost
#

InputActionAssets do not contain a definition for IsPressed().

austere grotto
#

is that what you want?

austere grotto
lament roost
#

already checked it out.

sullen lintel
lament roost
#

already checked it out.

#

that's not for an inputactionasset.

austere grotto
#

so what are you asking that hasn't been answered at this point

lament roost
#

what the equivalent of getkey is for inputactionassets.

lament roost
#

isn't that for one of those?

austere grotto
#

no?

#

That's a PlayerInput

#

which we haven't discussed at all

lament roost
#

playerinput isn't an actual name.

austere grotto
#

yes it is

lament roost
#

it's a name I set.

#

right?

austere grotto
lament roost
#

yes

austere grotto
#

that's the name of the component

lament roost
#

that I set.

austere grotto
#

just like a Rigidbody is called a Rigidbody

lament roost
#

oh

austere grotto
#

you did not set PlayerInput

lament roost
#

I thought I named it.

austere grotto
#

You set "PlayerControls"

lament roost
#

yeah

#

that too

austere grotto
#

that's a different thing. That's the Input Action Asset

#

which we discussed already

lament roost
#

yeah

lament roost
austere grotto
lament roost
#

not really

#

but I've seen IsPressed() in PlayerInput.

austere grotto
#

so are we just doing free word association?

#

PlayerInput makes me think of joysticks which reminds me of arcade games like Street Fighter

lament roost
#

since when was playerControls an array?

austere grotto
#

it's not an array

#

It's an InputActionsAsset

lament roost
austere grotto
faint oak
#

lol

austere grotto
#

you can give indexers to types

#

See look InputActionsAsset has an indexer that takes an action name

faint oak
#

brackets dont always mean arrays

austere grotto
#

to find an InputAction

lament roost
#

CS0021: Cannot apply indexing with [] to an expression of type 'PlayerControls'

austere grotto
lament roost
#

what should I do it with?

austere grotto
#

my example uses InputActionsAsset

lament roost
#

isn't that what it is?

austere grotto
#

No

lament roost
#

okay I wanna use playerControls for it.

austere grotto
#

PlayerControls is the generated C# class you created FROM your InputActionsAsset

#

if you want to use PlayerControls you'd do something like:

PlayerControls myPlayerControls = new PlayerControls();

void Start() {
  myPlayerControls.Enable();
}

void Update() {
  InputAction jumpAction = myPlayerControls.Player.Jump;
  bool isPressed = jumpAction.IsPressed();
}```
lament roost
#

oh ok

#

thanks

austere grotto
#

😵‍💫

lament roost
#

I agree

lament roost
austere grotto
#

yes

#

I separated it it to highlight the fact that playerControls.Player.Jump is just an InputAction

austere grotto
lament roost
#

ok

lament roost
#

the player doesn't jump.

austere grotto
lament roost
#

although it does jump, but it doesn't crouch.

austere grotto
#

So it does jump...

lament roost
#

playerControls.Player.Crouch.performed += Crouching;

#

yes my bad

austere grotto
#

So shouldn't you be asking about Crouching?

lament roost
#

yes

#
    public void Crouching(InputAction.CallbackContext context)
    {
        // Start crouching
        if (context.started)
        {
            crouching = true;
            transform.localScale = crouchScale;
            transform.position = new Vector3(transform.position.x, transform.position.y - 0.5f, transform.position.z);
            if (rb.velocity.magnitude > 0.5f)
            {
                if (grounded)
                {
                    rb.AddForce(orientation.transform.forward * slideForce);
                }
            }
        }

        // Stop crouching
        if (context.canceled || (crouching && !playerControls.Player.Crouch.IsPressed()))
        {
            crouching = false;
            transform.localScale = playerScale;
            transform.position = new Vector3(transform.position.x, transform.position.y + 0.5f, transform.position.z);
        }
    }