#🖱️┃input-system

1 messages · Page 50 of 1

neat marten
#

It always worked with new Input System?

crisp raven
#

Yes. I'm just feeding the input to the rest of the ECS world

crisp raven
#

same code works in MonoBehavior

#

I assume that has something to do with subscenes. I havent used it in subscenes before

unique basin
#

Hello Community, so i make the UI button in unity so i use script like this to prevent the input mouse pass trough UI button,It's work in Editor but not after i build it in Android device, i am using Unity 2019.4

unique basin
#

how to make it work same as after build especially on mobile

austere grotto
#

the event system will call it for you

#

and if you use the event system properly there's no need for code like this

unique basin
#

its for calculating distance bettwen drag start and drag end sir

#

ok i'll try it

lyric steeple
#

I have been trying to use the interfaces generated but isn't there a solution where you implement only what you want ? i could just use SendMessage() but its slow

frigid ridge
#

UnityEvents are the easiest way to get the most out of the input system

lyric steeple
fresh mortar
#

alrighty.. so... is there a singular Input statement that handles both get key up and key down? I'm trying to make it so an object's scale is transformed ONLY when the button is pressed... do i need to have two statements for that? I hope there's a way to only transform it when there's the button being pressed ;-; right now, I've got

      if (Input.GetKeyDown(KeyCode.LeftShift))
      {
        transform.localScale = new Vector3(1, .5f, 1);
      }

But i want it to return to the normal size when it's done being pressed...

#

(for a crouch feature obviously)

dapper narwhal
twilit drift
#

I just started using unity and whenever I type input into my code It doesn't highlight it for give me options

dapper narwhal
#

programming languages care about whether something is uppercase or lowercase

twilit drift
#

Still not giving me options

dapper narwhal
#

you sure?

twilit drift
#

mhm

dapper narwhal
#

then your IDE is not properly set up

dapper narwhal
#

then you want Input.GetKey

fresh mortar
#

I tried that but it's not resetting the scale :,>

dapper narwhal
#

well is there any other place where you're setting the scale than that if statement

twilit drift
fresh mortar
#

no place where I'm resetting it 😦 I'm just pretty sure in pygame (python's 2d module) i didn't have to reset it, it only transformed when i pushed the button, and no other reset was necessary. I was just wondering if there's a way to do it like more efficiently 😦

dapper narwhal
#

well this ain't pygame

#

you can do something like ```cs
if (Input.GetKeyDown(KeyCode.LeftShift)) {
transform.localScale = new Vector3(1f, 0.5f, 1f);
}
if (Input.GetKeyUp(KeyCode.LeftShift)) {
transform.localScale = new Vector3(1f, 1f /* or whatever it normally is*/, 1f);
}

fresh mortar
#

Yeah lol ugh that's annoying, that's what i figured i had to do but it just seems inefficient is all, thanks. 😛

dapper narwhal
#

np there's nothing inefficient about it

#

it's just two if statements

#

can't get much more efficient

fresh mortar
#

yeah but it would just constantly be checking for a keyup too even if there's no keydown being pressed

dapper narwhal
#

well yeah

#

it's negligible though

#

like as negligible as can be

fresh mortar
#

I sure hope so lol

sweet niche
#

I am having some weird issues. Can I have multiple of player input on certain part of UI screen? E.g. a Main Menu has it's own Player Input, but when you join the "Campaign" menu UI (Just main menu game object active is false and the Campaign gameobject active to true)

prime vigil
#

any ideas why my button will click the first time, but not the second if i dont move my mouse? im ussing the new system and simalting touchsreen

teal ravine
#

I'm a newbie to input system, followed about 6 tutorials, and found my console is spammed with :

InvalidOperationException: Cannot read value of type 'Vector2' from control '/DualShock4GamepadHID/leftStick/left' bound to action 'Gameplay/SteerL[/DualShock4GamepadHID/leftStick/left,/XInputControllerWindows/leftStick/left]' (control is a 'ButtonControl' with value type 'float')

I have no real idea what it's trying to tell me, my setup looks like this:

neat marten
#

Maybe you're reading your action incorrectly? I guess you're reading it through ReadValue<Vector2>(), but it looks like a button

teal ravine
#

its a value vector2 yeah

#

I don't get why it would think it's a button, its the leftstick input

neat marten
#

It says leftStick/left, not just leftStick

teal ravine
#

hmm, i figured leftstick/left meant pushing the left stick.. left lol

neat marten
#

I think you might have added an action which by default is of Button type, then added binding leftStick/left and then changed the action type to be Value of Vector2

#

Be careful there 😉

teal ravine
#

yes I think you're right, when i added it again it changed the type looks correct now

#

but I had to delete/re-add, not just change it

#

I think I can just change it to "steer" and extract the left/right vector from that now, thanks, rubber duck

#

Can you confirm what "Control Type" i need to be using for an analog trigger, for throttle? trying Analog

neat marten
#

Yeah I guess, haven't used it yet though

teal ravine
#

hmm right trigger brings this up (dunno what it is). I'll go do some investigating 😄

twilit drift
#

I have it set to get a message in console when I start the game and press space but I get nothing at all

neat marten
#

If you add some Debug.Log outside of if, do you see it printed?

twilit drift
#

Like that?

neat marten
#
Debug.Log("Some message");
if ...
twilit drift
#

I did this and it gave me nothing

neat marten
#

Then make sure your script is attached to some GameObject in the scene

twilit drift
#

I fucking forgot to attach the code 🤦‍♂️

#

It works thx

thorny plover
#

the docs say MonoBehaviour.OnMouseDown() works on a Collider or GUIElement... but then says GUIElement is obsolete and removed confuseddogwithquestionmarks
how do you get a mouse click on non-colliders then..?

austere grotto
#

you should be using the IPointerDownHandler interface from Unity's event system

little geode
#

I just had a friend install my mobile game on their Samsung S21 standard model, and none of the UI button click events are working at all. I've tried multiple apks to troubleshoot, but not getting anywhere at all. The buttons are showing perfectly scaled, but the click is just not triggering for him on the S21. I've had over 100 downloads and no one has complained about any other model too, and this also works great on the phones I've personally tested. My app is built in Unity Version 2019.2.18f1 (prior to LWRP) and I've been using the new input system for over a year now (which I've been using version 1.0.0 but today I tried updating to 1.0.3 to see if that would help on the S21 but it's still having issues). I'm really stumped on what could be the issue here, and was wondering if anyone has faced a similar issue at all, or has any thoughts on what I could try to do to fix this? I was thinking it was a scaling issue perhaps, but it doesn't seem like this is the case as everything looks aligned correctly on the menu. If it helps too, I'm just using the straight up OnClick() events and my event system seems set up right as it works fine for other Android devices.

austere grotto
little geode
thorny plover
#

I have the exact same code as the example with my own class name, the Start method is definitely called, but the OnPointerUp and OnPointerDown don't get called

#

I tried with a collider and without, but nothing works

#

what did I forget to use?

#

ah, I think it requires to be used on a UI object... no idea how to do that yet

sharp geode
vernal epoch
#

ProGrid cant be installed in package manager, but i need it to help snap things onto spaces like here

#

can someone help? I would like to be exakt on the lines

teal ravine
#

I'm trying to bind the right analog trigger for throttle in my game, but It brings up this HDRPGraph, with no apparent way to disable it?

This is with a PS5 controller, Any solutions?

languid scroll
#

if you cant see it you have to enable preview packages in the Project settings

sick cradle
#

@teal ravine there isnt a toggle for that in hdrp asset etc? Also do you get that in release build? I think it should only exist in dev builds (unless you use some older version)

misty locust
vernal epoch
deft berry
#

Edit > Project Settings > Package Manager > Enable Pre-release Packages

vernal epoch
#

Ye i found it. Tx

agile fog
#

So when I start the game from the menu screen scene I get a problem with the mouse where it goes outside of the gamescreen and keeps rotating - which makes it very hard to move. If I start it in the gamescene i click onto the game and the mouse keeps inside the game window.

#

The dialogue system I added doesnt work either and I have a feeling its because of the mouse input problems

fickle agate
#

@timber robin hey, i dont know if you remember, but i asked here before if someone knew how to detect if a controller/gamepad had been switched on or plugged in, and you replied with an answer.

timber robin
#

Sorry, I interact with a lot of people, so I don't. But if you say it's so, then it's so. 😆

fickle agate
#

it is, and i greatly appreciate your help. i was just wondering if you have any further knowledge or experience rigging that function up with code? 🙂

timber robin
#

I've actually never used it. It was just something I remembered reading.

#

And I can't try it right now, I'm currently in the middle of a game jam. Lol.

fickle agate
timber robin
#

The new input system is a bit vague in that regard, yeah. Plus multiple implementations as well.

fickle agate
teal ravine
misty locust
remote fog
austere grotto
remote fog
#

ohh tnx

deft berry
remote fog
deft berry
#

clearly not since it's not configured

bronze kestrel
#

I have a 2D-Vector, and it's not resetting to 0.0,0.0 when not pressed

#

Which is strange because I have an identical one that works that way

austere grotto
bronze kestrel
austere grotto
# bronze kestrel

I'm not 100% sure but I think that style only gets the performed callbacks

#

which don't include the reset to 0

#

just one of many reasons PlayerInput sucks

bronze kestrel
#

but OnMove is never stuck at 1,0

#

it always returns to 0,0

austere grotto
#

hmm

bronze kestrel
#

Ah I forgot to change the action to Value-Axis

#

it was at button

austere grotto
#

oops

remote fog
deft berry
#

did you restart VS since doing it? monobehaviour will be green and it will say Assembly-CSharp where it currently says Miscellaneous Files

deft berry
#

yeah that's how we can tell it isn't currently configured

remote fog
#

so its fine now 👍

deft berry
#

not if it still looks like the screenshot you just showed

remote fog
deft berry
#

still not configured

remote fog
#

@deft berry

#

what

#

bruh i give up

deft berry
#

notice how it still says "Miscellaneous Files" and how MonoBehaviour isn't green? those are both indicators that it is not configured

#

if you have gone through the steps to configure it, then fully close visual studio and open it by double clicking a script within the unity editor

remote fog
#

ok

#

still no green

deft berry
#

then go to #854851968446365696 and find the IDE Configuration section, click on the relevant link and follow all of the instructions in that link

remote fog
deft berry
#

great! completely restart visual studio

remote fog
#

appreciate your time and effort finally

pliant helm
#

Hey, i need to get the last pressed key, because pressing A then B (or A and B but A first) should produce an action. I cannot really store the last key pressed because i use events. Is there another way ?

austere grotto
pliant helm
#

because it looks like this

#

and i dont want to go to each functon i call to chage a global variable somewhere

austere grotto
#

you can do whatever you want in them

pliant helm
#

i can write
controls.TopDownControls.Move.performed += _ => cam_controller.move = _.ReadValue<Vector2>() || lastPressed = 'up';
you mean ?

austere grotto
#

not really, that code makes no sense

#

you can write multiline lambdas though

#

or just use a real method

pliant helm
#

ah i see

#

but i'll have to write this for every key witch seem pretty painfull

austere grotto
#
controls.TopDownControls.Move.performed += WhenMoveHappens;

void WhenMoveHappens(InputAction.CallbackContext c) {
  cam_controller.move = _.ReadValue<Vector2>();
  lastPressed = "up";
}```
#

though that code doesn't make a ton of sense either tbh

#

are you trying to do like a mortal kombat style "move" system

pliant helm
#

i guess i'll just do something like :

controls.TopDownControls.Move.performed += _ => cam_controller.move = _.ReadValue<Vector2>();

controls.TopDownControls.Move.performed += _ => lastPressed = "up"
#

it's a RTS system like starcraft, where you can select a unit and do A then click to attack, or R then click to patrol etc...

#

now that i think about it i only have to keep the info for the chosen keys, and for any other key pressed set it to null or something using input.anykey or it's equivalent in the new system

austere grotto
#

I would think that pressing A for example just puts you into a different mode

#

where you can then just choose where to attack

#

what you need is a simple state machine more or less where you have modes like:
Idle
Attack Placement
Patrol Placement
etc.

pliant helm
#

because if you have a unit selected && you press A && you left click, it attacks, but
if you have a unit selected && press P && left click, it does nothing

austere grotto
#

right - state machine

#

which i guess you're kinda doing a light version of with your "lastPressed"

#

but I'd formalize it a bit more and make it not directly related to the input so much

pliant helm
#

yeah maybe

#

thanks

frigid ridge
#

Looks like you are trying to read a float while the input is setup to be Vector2

#

Yea seems fine. The code part is what is most likely wrong

#

Visual Scripting, not really.

crisp smelt
#

Any way to reach the team working on Input System?

chrome walrus
#

Your best bet is here I guess or through a bug report

crisp smelt
chrome walrus
#

Did you try to manually check against with their phase status, are they keep being stationary? @crisp smelt

crisp smelt
#

Yes, they are all stuck on being stationary

chrome walrus
#

you could just try to manually set them at the end of the script to cancelled and see what happens in the next frame, it should only update the once that are still active

crisp smelt
#

How would I do that?

#

For some context I did not file the issue, but I can see it happening by just showing InputSystem.EnhancedTouch.Touch.activeTouches, and that's a read only array.

chrome walrus
#

Oh you cant set touches manually, dang. Hm, let me think

#

Some threads say its a phone thing, not a unity issue. hm

crisp smelt
#

Well, it certainly doesn't happen with Input Manager

#

If the touches are misreported by the hardware then it would happen to both.

chrome walrus
#

If it was that easy 😉 So the legacy input manager is working, yes?

crisp smelt
#

Yes.

#

It's as simple as printing out InputSystem.EnhancedTouch.Touch.activeTouches vs Input.touches

#

You can see ghost touches getting stuck with Input System which doesn't happen with old Input Manager, on the same device.

#

Not even specific to just my device, many people tested and confirmed it.

chrome walrus
#

I totally believe you there, was just quoting the threads as a second thought. Well not sure if there is a way to manually force the inputsystem to update.

#

Do you need the stationary phase for your app right now? If not, I would hack myself around it until its fixed or someone else fixes it.

crisp smelt
#

I do yeah, rhythm games do need to detect touches that are held down (but not necessarily moving)

#

If it's just for detecting taps/releases then that would be completely fine.

chrome walrus
#

Okay, thats an issue. hm

#

I mean you rbug report side says "Fix In Review", so maybe

crisp smelt
#

Maybe 🤞

#

It's unfortunate because for rhythm games, it's critical to get the precise timing of player input so you can judge them fairly (hardcore rhythm game players can 100% tell) which Input Manager doesn't do

chrome walrus
#

🤞 for you, it will get fixed soon. I voted for it at least, as this is some serious thing not just in games but multitouch screens for exhibitions and stuff.

#

Just wondering, could you just use began and cancelled to check instead of stationary?

crisp smelt
#

I actually don't know for those ghost touches that get stuck on stationary, if a cancel event was ever fired.

#

I suppose if it does get fired, I could manage my own list of touches with that.

chrome walrus
#

Hard to suggest anything without knowing your game, but you could try to bypass stationary and just use began and cancelled (which might not get fired on the ghost touches) to see, if the player started and ended at the right time instead of check holding with stationary.

crisp smelt
#

Actually now that I can recall, cancel definitely isn't fired.

#

An action player is required to complete is to tap, follow, release in one continuous motion

#

People have reported that the release isn't being recognized which is what led me to finding this bug.

#

So from all the game can tell by querying active touches, player just holds the touch there permanently.

chrome walrus
#

So cancelled is fired only on the "real" touches, so you coul duse them?

crisp smelt
#

But you can't tell

#

If a touch has started, then stay stationary for rest of the game, you can't tell if the player is actually doing exactly that, or it's a bugged touch that isn't being cleared.

chrome walrus
#

So its there forever?

crisp smelt
#

Yep.

#

This is a photo someone sent me earlier

#

It's reporting 10 active stationary touches, and well, you certainly can't see 10 fingers.

chrome walrus
#

Yeah thats weird. We will have to wait for the fix I guess

crisp smelt
#

Yep, the bug is with InputSystem.EnhancedTouch.Touch.activeTouches.

chrome walrus
#

ohh, woops, missed that

crisp smelt
#

I think the higher level APIs (directly sending events in response to inputs etc) are fine with Input System

#

Or at least I haven't heard people screaming about it.

ruby hedge
#

How do I switch the enabled action map when a button is pressed.
I have a menu that you hold the input to keep open. So I want to switch from my "Gameplay" action map to my "UI" map when the button is performed, and then back when it is canceled.
This is a simple example I made of it. This freezes Unity though.

 private GameInput input;
    
void Start()
{
  input = new GameInput();
  input.Gameplay.Enable();
  input.Gameplay.Inventory.performed += OpenInventory;
  input.UI.Inventory.canceled += CloseInventory;
}

public void OpenInventory(InputAction.CallbackContext ctx)
{
  input.Gameplay.Disable();
  input.UI.Enable();
}

public void CloseInventory(InputAction.CallbackContext ctx)
{
  input.Gameplay.Enable();
  input.UI.Disable();
}
austere grotto
#

so it's inifitely swapping back and forth

#

I'd probably put this action (toggling the UI) into a third action map that is always enabled

ruby hedge
ruby hedge
# austere grotto oh hmmm 🤔

I put Debug.Log in both and added an auto return at the top after it had been called x number of times. Only the cancel event for the UI map was called, the performed for the Gameplay map was only called once at the start...

#

I just made a new map "GameplayAndUI" for it. Feels a bit ugly, but it works really well so... ehh.

teal ravine
#

is there a way to continuously poll the analog sticks, such that it always has the latest value? currently with the new input system, if i move the stick fast it only reads a few values and doesn't capture the last position of the stick (completely left)

ruby hedge
whole forge
#

Hello. I'm having trouble with the input system package. I have everything hooked up the way I need it, and everything in my script is correct. I've set up an interact key and I'm able to interact with my 3D environment with it. However, somehow the key is getting pressed three times when I only press it once. I know this because the console within the editor is outputting three different messages. Does anyone know the fix to this? (Haven't found a resource online that helps). Here's my Interact method just in case. I've also included my input actions map.

public void Interact(InputAction.CallbackContext input)
    {
        cameraPos = Camera.main.transform.position;
        rayDirection = Camera.main.transform.forward;

        if (Physics.Raycast(cameraPos, rayDirection, out vision, rayLength))
        {
            if (vision.collider.CompareTag("Tree"))
            {
                vision.collider.gameObject.SetActive(false);
                Debug.Log("You chopped a tree!");
            }
        }
        else { Debug.Log("You can't interact with anything here."); }
    }
ruby hedge
whole forge
#

No, I've only added it once.

whole forge
teal ravine
ruby hedge
teal ravine
#

i spent an hour moving all my input code from the update method into event driven like that, now I have to move it all back 😄
oh wait, it needs to use event driven for regular buttons

ruby hedge
ruby hedge
teal ravine
sharp geode
sharp geode
#

use an inputactionreference to get something in the inspector you can use to specify what you need

#

for example, a vector2 or whatever

#
public class MyBehavior : MonoBehaviour
{
    // This can be edited in the inspector to either reference an existing
    // action or to define an action directly on the component.
    public InputActionProperty myAction;
}
teal ravine
#

Got it now, thank you

cursive spear
#

Hi, does anyone know why when saving any script with the Input System in the project, it completely errors out the input system and makes it unusable untill i replay the scene?

deft berry
#

Gotta provide more info than that, mate. Maybe share the movement and input code.

cursive spear
#

other than that the new input system is awesome

deft berry
#

#854851968446365696 will tell you how. It also tells you what kind of info to include in questions, as well as some other useful stuff

cursive spear
#

its when I recompile any script

#

unless saving recompiles every script

deft berry
#

It will

teal ravine
high crystal
#

I'm using default events, does the EventSystem component even do anything then? I wanted to switch to IPointerClickHandler as MouseDown reacts even if it's below the Canvas UI. Do I have to switch the Input System?

austere grotto
#

not sure what you mean by "default events"

high crystal
#

there is an input system that you do not need to install via package manager and one you need to install. I was wondering if IPointerClickHandler only works with one of them

#

my input worked with MouseDown on Monobehaviour, but it was getting events through the Canvas. I read that IPointerClickHandler solves this, but now I don't get any events at all.

austere grotto
#

OnMouseDown only works with the old one as far as I know

high crystal
#

ok... hm I've switched to the new input system. but I guess I am missing something else for this to work

austere grotto
#

If you're trying to use IPointerClickHandler on a 3D/2D game world object you will need a few things to make it work

high crystal
#

as it was supposed to work in both

austere grotto
#
  • Event System in the scene, also with an Input Module component on it (the correct one for your input system)
  • PhysicsRaycaster on your camera
  • Collider on the object
  • Script with IPointerClickHandler interface on the object
high crystal
austere grotto
#

that's a collider

#

what about the other 3 things

high crystal
#

oh, I think it might be physics raycaster. I dont have it on all cameras

#

yes that was it. damn

#

thank you

#

I guess you need it on the camera that renders what you want to click

#

I only had one on the UI not on the game visuals

warm flume
#

First time using any type of input system. How would I call these input buttons? The second image shows the code I have but it says Keyboard does not contain a definition for 'Move'.

#

I have changed my code to this and it works, however it just detects the key specified and not the key from the input system I set up.

neat marten
#

Have you visited docs? 🙂
Yes, currently you don't use actions you've set up, but the actual keys

warm flume
#

I tried looking at docs but from what I could find everything refers to using this way of getting input which I find somewhat confusing.

I liked being able to say if (Input.GetKey(KeyCode.W)); But I can't do that with the input system. A video showed the method I did before and I want to do something like that/like the Input.GetKey but instead of KeyCode.W or wKey I want to refer to the specific bind I made.

#

Is there a way to do that other than the image I just posted?

deft berry
neat marten
#

There are also Samples

ashen pendant
#

the old non-event based input system was convenient for getting up and going quickly. However, an event driven system has a number of benefits and the setup isn't bad once you are familiar with it.

west oracle
heady lagoon
#

anyone ever use a gamecube to usb adapter with unity? cant seem to get the Y axis for the c-stick or dpad

solar kite
#

Can the new input action support multiplayer in PUN 2 or Fusion?

warm flume
# west oracle You can too still do this. ```Keyboard.current[Key.A].wasPressedThisFrame```

Yeah but that still means I am looking for the key A. I want to call the input keybind I made because I want to allow players to change keybinds.

Personally I feel like the input system is too complex for just calling the keybinds. This is 100% my opinion but for now I think I am just going to make my own input system script with variables for example string moveForward = "w" and then just use Input.GetKey(moveForward).
That feels so much simpler than what the input system makes me do. Unless there is a way for something like that but I missed it but it seems to me like there isn't.

west oracle
#

You can

#

1.1prev has proper extensions for it, but you can watch.... Lemme get link

#

Hope some of those help :)

warm flume
#

Ok, will have a look. Thanks for the link.

west oracle
#

There's a bunch of reasons to migrate upward, but it's a bit of a learning curve

#

I made those tutorials after struggling thru migrating, so they're all in that context.

warm flume
#

Ok

haughty thorn
#

I'm using the new input system and I would like to disable the "onMove()" callback based on a condition

#

I know I can prob do something like this:

#
moveAction.performed -= OnMove;
#

But how do I get access to the moveAction?

haughty thorn
#

found it 😄

austere grotto
rich stream
#

Can we please get support for Unity remote 5 🙏

remote fog
#

Help

dapper narwhal
# remote fog

what do you expect cs Destroy(obj, 0, 5f); to do? what is the 0 meant to do?

#

also why is this in input system

#

you're not even using anything related to input 🤔

dapper narwhal
remote fog
#

Yes

dapper narwhal
#

and it works i assume

remote fog
#

No

dapper narwhal
#

in what way does it not

remote fog
#

Ahh I just noticed I had x2 Zeros

#

Appreciate the help

dapper narwhal
#

np ig

hallow flicker
#

I have a listener here that's waiting for a .performed

    {
        playerControls.Movement.Moveandlook.performed += move;
    }```

Is there any callback that's continuous? This is to move a player, so currently every when you hold W it moves slightly and stops. I'm trying to avoid populating Update
austere grotto
#

performed will get called every time the actuation of the control changes though (and remains nonzero)

hallow flicker
#

yeah I just stuck it all in update in the end

heady lagoon
#

How can I get smooth movement from an analog stick?

#

its either 0 or 1

austere grotto
#

under normal circumstances it will give you a value between 0 and 1

heady lagoon
#

not sure what you mean

austere grotto
#

How are you getting the value

#

your 0 or 1 value

heady lagoon
#

with my eyes lol

austere grotto
#

where is it coming from

#

in code

#

in your input setup

#

give some context

heady lagoon
#

input system i assume

austere grotto
#

more context

#

show your input action and how you're getting data from it

heady lagoon
#

im setting up a gamecube controller in unity

austere grotto
#

I'm not a mind reader

heady lagoon
#

chill dawg im going

#

unity has to rebuild

austere grotto
#

I'm not sure the GameCube controller is really going to be fully supported by Unity (or anything except a nintendo console), so let's start off with - you might not be able to get this working without some custom hardware

heady lagoon
#

im not sure why it would not work

austere grotto
#

and you're reading it how?

heady lagoon
#

its through zadig

austere grotto
#

WIth Input.GetAxis?

heady lagoon
#

yes

austere grotto
#

what is zadig?

heady lagoon
#

a driver that converts the gamecube to usb to a typical windows controller

#

at least i believe thats what it does

#

could be wrong

#

but either way, the controller can operate just fine with analog input in dolphin for example

austere grotto
#

not really sure - at this point you're dealing with a bunch of unsupported software and hardware 🤔

heady lagoon
#

yeah lmao

#

im suprised i got this far

austere grotto
#

Is this a project just for yourself?

heady lagoon
#

sorta yeah

#

just wanted to see if i could get it in the game im making

#

i guess ill see if i can find a way to get it through code

austere grotto
#

you might need some kinda native windows plugin to get this working

hallow flicker
#

is there a way of setting up the circled input as digital while keeping the others as analogue?

pliant helm
#

can anyone tell me how i can get the mouse screen position using the new input system ? Mouse.current.position returns a Vector2Control instead of a Vector2, and i have no idea how to extract coordinates out of this

pliant helm
#

ok i got it it's Mouse.current.position.ReadValue();

austere grotto
hallow flicker
#

I tried that but unfortunately it can't call both inputs simultaneously. In this case (tank controls), you'd have to stop walking forwards to turn, as 'stick left' and 'stick right' are in the other input. So when you hold the diagonal, whichever input triggers first is the only input until you reset the stick to 0,0

austere grotto
hallow flicker
# austere grotto why can't it use both input simultaneously? Sounds like a limitation of your cod...

I'm not sure. It could because it's not liking 2 simultaneous inputs for a Vector2?

The full process is I read the vector2 from 'moveandlook' in the input system, then SmoothDamp it, and extract .y and .x for forwards/back and look left, look right.

        // Get movement inputs, smooth input, reset previous movement
        movementInput = playerControls.Movement.Moveandlook.ReadValue<Vector2>(); 
        currentInputVector = Vector2.SmoothDamp(currentInputVector, movementInput, ref smoothInputVelocity, 0.2f);
        if(movementInput.y == 0)
        {
            currentInputVector = new Vector2(0,0);
        }
        runningInput = playerControls.Movement.Running.ReadValue<float>();

        
        // Convert V2 input into floats
        verticalInput = currentInputVector.y;
        horizontalInput = movementInput.x;
        
        // Set speed and direction
        curSpeed = moveSpeed * verticalInput;
        Vector3 z = transform.TransformDirection(Vector3.forward); 
brazen crater
#

Anyone know how to replace Input.GetMouseButtonDown/GetMouseButton with the new input system?

austere grotto
brazen crater
austere grotto
#

if you don't have it then you can use

action.phase == InputActionPhase.Started``` and ```cs
action.ReadValue<float>() != 0``` instead
brazen crater
#

im on 2021.1.21

austere grotto
#

then it should be available in the package manager afaik

brazen crater
#

I just uninstalled 1.0.2, maybe it will come up now

austere grotto
#

or maybe it's only for 2021.2+ idk exactly

#

either way you can use those alternatives

brazen crater
#

alright thank you

brazen crater
#

thanks

sinful turtle
#
        var mouseX = Pointer.current.position.x.ReadValue();
        var mouseY = Pointer.current.position.y.ReadValue();
        // Mathf.Clamp(-mouseY, -lookXLimit, lookXLimit)
        _cam.transform.localEulerAngles = new Vector3(-mouseY, 0, 0);
        transform.rotation = Quaternion.Euler(0, mouseX * lookSpeed, 0);```
 should i change this to use the actions stuff
#

im having an issue where if i lock the cursor and set it to hidden then im not able to move the mouse

#

but if i dont lock it moving the mouse causes it to go offscreen

mortal ridge
sinful turtle
#

what should i use

austere grotto
#

and read the value of that each frame

mortal ridge
#

yes. but you have to increment a seperate variable if you want to use it with Quaternion.Euler()

austere grotto
#

yes - i'm suggesting a 1:1 replacement for the current thing he's doing with Pointer.current.position.ReadValue()

sinful turtle
#

im used to the old input system so this is new to me

mortal ridge
#

the new one is definitely so much better 👍 you'll get used to it quick

sinful turtle
#

so i add the Player Input component to my player prefab?

mortal ridge
#

i would suggest using the InputActionAsset itself rather than the playerinput component

#

@sinful turtle

mortal ridge
#

have you created any input action asset?

sinful turtle
#

yes

mortal ridge
#

ok, go to it, and in the inspector click 'generate c# script'

sinful turtle
#

ok

mortal ridge
#

when you have, in the script you have, add a private <<GeneratedScriptClass>> _controls;

sinful turtle
#

done

mortal ridge
#

in OnEnable() put _conrols = new <<GeneratedScriptClass>>() and then _controls.Enable(); and in OnDisable() put _controls.Disable();

#

actually put _controls = new <<GeneratedScriptClass>>() in Awake()

sinful turtle
#

wait

#

im using mirror for networking

#

i think it would be better to go in OnStartLocalPlayer

mortal ridge
#

probably. although i have no experience with mirror. but put it somewhere where it get's called when the script is being 'Activated' and 'Deactivated'

sinful turtle
#

alright

#

now what

mortal ridge
#

ok, so have you created an actionmap in the asset itself and added some controls?

sinful turtle
#

ye

mortal ridge
#

ok, then in your code you can write: _controls.<<ActionMap>>.<<InputBinding>>.ReadValue()

sinful turtle
#

ok so i think i got it all working

mortal ridge
#

yeah?

sinful turtle
#

one thing

#
var mouseDelta = Pointer.current.delta.ReadValue() * (Time.deltaTime * mouseSensitivity);
_mouseX += mouseDelta.x;
_cam.transform.localEulerAngles += new Vector3(Mathf.Clamp(-mouseDelta.y, -lookXLimit, lookXLimit), 0, 0);
transform.rotation = Quaternion.Euler(0, _mouseX, 0);```
 i have this, which kinda works but sometimes the camera can rotate past the max or min
mortal ridge
#

ok, why are you using the Pointer class now? XD

sinful turtle
#

o

#

i forgot to change that

#

var mouseDelta = _controls.Player.Look.ReadValue<Vector2>() * (Time.deltaTime * mouseSensitivity);

sinful turtle
mortal ridge
#

it's probably because you are adding to localEulerAngles

mortal ridge
sinful turtle
#

oh

mortal ridge
#

90% sure that's what's wrong

tame oracle
#

guys,why are the axis a float?

dapper narwhal
#

it gets an axis from the input manager

#

and the axis is between -1 and 1

#

although an exception is the mouse

tame oracle
dapper narwhal
#

it's value will be the mouse delta multiplied by the axis's sensitivity

tame oracle
dapper narwhal
#

ye

#

for example that Horizontal axis

#

it will be 1 if you press D and -1 if you press A

#

and 0 if you're pressing neither or both

tame oracle
#

i heard there is a newer input system?
idk if that's true or something

dapper narwhal
#

there is indeed

#

but it is more complicated than the old one

tame oracle
#

what is it?

dapper narwhal
#

you can install it through the package manager, it's called "Input System" but i'd recommend you to use the old one

#

the benefit of using the new input system is that it is much more customizable

tame oracle
dapper narwhal
#

that's the old input system

#

in the new input system you'd have some input map and then you'd do for example ```cs
controls = new Controls();
controls.Enable();

controls.Main.Jump.performed += _ => {
//something happens
};

#

although there are many other ways in the new input system

remote fog
#

I broke somwthing

little geode
#

I'm migrating my mobile UI touch controls to start using the new input system. The way I have my non-mobile controls set up is with the new input system, and instead of using the generated code, it's using the Player Input script to send Unity events to my custom playermovement script. An example of my 1d axis horizontal movement binding script:

public void OnHorizontal(InputAction.CallbackContext context) { horizontalMove = context.ReadValue<float>(); }

The On-Screen Button scripts seem to work perfectly for most of my mobile buttons, but I'm using the On-Screen Stick script for my joystick and it is not allowing me to move it around unless I uncheck the Auto-Switch boolean option in the Player Input script before runtime. I have to have this checked for my non-mobile release though in the case the player is switching from a keyboard to a gamepad controller at runtime. And also setting playerInput.neverAutoSwitchControlSchemes = true; at awake if it's mobile is not allowing me to move the joystick either. It has to be unchecked before runtime. Was wondering if someone can help me out with getting this joystick to work with autoswitch still enabled on my PlayerInput script.

Unity version is 2020.3.18f1
New Input System is 1.1.1

#

And this is what my Player Input script looks like with the event call and Auto-Switch on.

little geode
#

Update: just generating the scripts from my input action and using a new instance of that in my script seems to have fixed it. I guess I won't question the other approach I was doing before.

brave barn
#

I'm using the new unity input system and I cannot pass the input system generated C# class as a reference to another script through the inspector. For some reason, the public field "controls" is not visible. I tried forcing a serialization, but it did not solve the issue.

public class Player : MonoBehaviour
{
    public InputMaster controls;

    private void Awake()
    {
        controls.Player.Shoot.performed += context  => Shoot();
    }

    private void Shoot()
    {
        Debug.Log("Test");
    }

    private void OnEnable() { controls.Enable(); }
    private void OnDisable() { controls.Disable(); }
}
trim hollow
#

And InputMaster is your generated c# class name right ? @brave barn

austere grotto
#

It is not serializable and will not show up in the inspector

#

That's not how the generated class works

#

You create one with new InputMaster()

brave barn
brave barn
#

Alright, I got it to work by instantiating it in the awake.

last warren
#

Hi everyone.

#

Been trying (real hard) to get a mouse press (button down) fire an event. For some reason the callback gets fired both on mouse press and release. What is the correct setup for this? I couldn't find a specific example nor could I get it to work by trial and error. Thanks!

#

New input system BTW, if that was not clear

celest orchid
#

I cannot get rid of 'The type or namespace name 'InputSystem' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?) [Assembly-CSharp]' I have rebuilt proj files (after deleting them) making sure it is set to VS code, the system is set up to the new system

ember sundial
#

Hi i need help with input system .the perform happens only once
is there a solution to make it happen like all the time?

austere grotto
austere grotto
austere grotto
haughty thorn
#

How do I unregister an action?

#
PlayerInput playerInput = GetComponent<PlayerInput>();
InputAction moveAction = playerInput.actions["Move"];
moveAction.performed -= Onmove;
#

this doesnt seem to work?

hot socket
#

Does anyone know why this action input button for VR Bluetooth controller is not working but the Action Input for the Key (E) is working?

trim hollow
#

And take the time to read all this page it’s worth it 🙂

little geode
#

Is anyone facing random issues in the newest version of the new input system 1.1.1 where the On-Screen Stick will, at a random time, just start following any touch you make on the screen, even if it's outside of the image you had the script on? I saw this post recently on an older version of the system, but I'm facing it with the newest.: https://forum.unity.com/threads/how-to-prevent-touchscreen-controls-getting-stuck-using-the-input-system-samples-example.965738/

And also, this never happens in the editor (I'm using 2020.3.18f1). Only when I build it and run it on my Android device.

turbid crane
#

Hey, I am using the new Input system, how do I stop the movement after I release the WASD keys?

#

Also, when I change direction to the opposite with multiple buttons pressed it doesn't work

nimble mulch
#

Hello everyone! I've been having some issues setting up the Input System for my new project. I've done it before, but this time around it's telling me that the namespace "InputSystem" doesn't exist. I've tried unisntalling and reinstalling the package, updating my .NET SDK, so I'm not sure what other options are left here

glass yacht
#

InputSystem isn't the namespace

#

are you using UnityEngine.InputSystem;?

nimble mulch
#

Yes

glass yacht
#

Are you getting the issue in Unity

#

or just VS

nimble mulch
#

Just VS

glass yacht
#

well, I presume it should not say Unloaded here

#

so I'd look into whatever causes that

#

Can you right click on it and reload it?

nimble mulch
#

Yea, it asked if I wanted to install missing features so I'm doing that first

#

Alright, I installed the missing features and it no longer says unloaded but i still get these errors

#

@glass yacht

glass yacht
#

It looks better at least, did you restart, I'd probably try that next

nimble mulch
#

I did but let me try one more time

nimble mulch
glass yacht
nimble mulch
#

I few updates in there, I'll download those and restart

#

Thank you!

nimble mulch
#

It worked btw so thank you more!

dapper ermine
deft berry
#

you have enabled the Input System and set your project to use that but are attempting to use the input class for input. Either switch to using the Input System for input or change your project settings
the setting is in Project Settings > Player > Active Input Handling

dapper ermine
#

its not there

deft berry
#

what isn't where?

dapper ermine
#

Active Input Handling

deft berry
#

yes it is, you just aren't looking hard enough.

dapper ermine
#

ok i found it thank you

copper aurora
#

Hey, how do i check if a button is not pressed with the new input system? I need a specifc action to occur depending on whether Shift is pressed or not (so Shift + button = something and only button = something else)

acoustic bough
copper aurora
#

So i'd need a new action mapped like "Shift" and basing on whether shift is held or not, modify the bool, right?

acoustic bough
#

That's what I would do, yeah

tribal fractal
#

how come nothing is showing up in my properties tab? I want to add a path to my <No Binding>

acoustic bough
#

How can I move a player left and right with the same CallbackContext? Since there's only one called "Move" with Unity Events

crimson crater
#

how can add support for 4 different types of devices and each not trigger each other actions? i'm using the generated c# class and i classify myself as a newbie with the new input system

turbid crane
#

Hey, why my buttons can't outweight other buttons, example going from right to up

#

This was never an issue with GetHorizontal/Vertical old input system

teal ravine
#

anyone know why the input system does not work with controller at all in a build of my game? - works perfect in the editor

turbid crane
#

Hey I am using a new Input System and for some reason if I am going right or left I can't overweight the right and left with up or down buttons, could anyone guess what am I doing wrong?

#

I solved my issue....

#

I didn't press Save Asset button while I was making changes to the input system, so all the time I thought I was doing something wrong.

tribal fractal
#

Would anyone know the fix to my question above? It's kinda urgent

zenith stone
#

anyone able to send a link to a good tutorial on input and multiplayer input?

fickle torrent
#

when playing Minecraft the mouse pointer isnt visible and the playerCharacter rotates its body as we move the mouse

how do i implement that in a fps game i am making?

#

please ping me when anyone responds

fickle torrent
#

thanks

fluid hedge
#

What's the replacement for Input.GetAxis("Mouse X") in the new input system?

#

Rather, is there a way to get the mouse input without using CallbackContext

misty locust
turbid crane
#

the new input system is a hell to work with state machines....

tame oracle
turbid crane
#

Unity literally slows down if I use single input action multiple times, wtf

lilac granite
#

using the minis midi input with the input system i have a scene that, when loaded on it's own, works perfectly (4 separate midi input channels doing what they need to do). when the scene is loaded as part of the build after a different scene, midi channel 1 also triggers the midi channel 2 action. i've tried loads of different workarounds (even inserting extra scene to "reset" the input system) but this continues to happen, any ideas here?

crimson crater
#

how can i get input from one specific controller?

crimson crater
# tame oracle Wdym

If i have multiple controllers, assign one to a specific GameObject so that it is controller by this specific controller. I researched a bit and the only thing i get is that i need multiple control schemes and an Input Action component on the objects

tame oracle
#

And then I bet you can do it

crimson crater
#

Kay thanks

green island
#

I'm having a bit trouble with the input system in the WebGL version of my project. I am using the old unity input system and the unity UI and when I click a button, it keeps on getting pressed repeatedly until I click somewhere else. How can I fix this? 🤔

#

I should add that it works great in the desktop release and the editors play mode

sweet niche
#

Question, I'm working on a multiplayer set of code. What I've done was instantiate a NetworkController for the player to join and play in the game, but then it doesn't have a actor or pawn to spawn in the world. I can instantiate a player game object, but how do I assign the current player's controller to that game object?

#

It's not like I could do something as

playerGameObject.GetComponent<PlayerInput>().Assign( this.playerInput );
```?
crystal rock
#

Hey Friends! Would anyone be so kind to link me to a solid guide to help me create a 3D Isometric Character Controller? I unfortunately cannot seem to find an up to date one. Thank you so much!

quasi wren
#

I literally cannot set an input, when I type "LeftControl" to Positive Button it gets deleted

#

what the fk

#

that's it

#

I'm fucking done with this glitchy mess

#

can't focus on what I'm gonna create cuz of these constant glitches

quasi wren
#

really? a space fixes that?

#

when the keycode doesnt have a space

glass yacht
#

It's not a keycode, it's also not just a space

little geode
#

Has anyone had any PS4 controller issues with the new input system UI mappings with their Windows build? The controller works great in the editor, but when I build out my application with Windows x86_64, it's very janky. The joystick works fine as do the cardinal buttons, but the d pad gets screwy. Windows controller and keyboard work fine, although keyboard does not work when the PS4 controller is plugged in when running my Windows application. I'm on Unity 2020.3.19f1 with the new input system version 1.1.1.

sweet niche
little geode
sweet niche
#

Nope. Not even the xbox 360 controllers nor the xbox one either!

#

It used to work before, but something happened and now they just stop working.

little geode
#

Using 1.1.1 of the new input system?

sweet niche
#

Let me check...

#

What did ya know?

#

Also, for the sake of it, this is what my input schemes look like.

#

See if downgrading the version fixes the issue you're experiencing? I might do this later after work.

sharp geode
#

you might want to try to go back to 1.1.0-preview.2 which in my opinion is the most reliable version

little geode
#

Thanks, @sharp geode ! Has that worked with a PS4 controller on a windows build for you?

#

@sweet niche looks fine to me. I recently had a funky issue with my UI mapping where I had to copy the UI action map from the input system package's default input action and that stopped an issue I was having with my joystick sticking when tapping a button with the On-Screen Button script attached to it.

#

Wonder if this is happening for you now

little geode
#

Yes @sharp geode. 1.1.0-preview.2 fixes my issue. I don't know if this will mess up the touch buttons on my mobile yet, but I think for now, I'll just create my PC build with 1.1.0-preview.2 and hopefully by the time I push a new version up to Steam again, they'll have this fixed.

#

Thanks a lot

little geode
#

Update on 1.1.0-preview.2 though, it doesn't seem to read some of my keyboard buttons. I think there is something going on with the default input action maps that they keep changing in each of these versions. In the 1.1.1 version, my UI buttons work good, but navigation on the PS4 controller doesn't. In the 1.1.0-preview.2 version, the UI buttons all seem to work out great, but the player controls on the keyboard for me are messed up.

little geode
#

Yep, doing that as we speak

little geode
#

So, it looks like if I have a controller plugged in, the keyboard input will allow all my input mappings except my 1D axis bindings that I have in my horizontal movement. But once I unplug the controller, the scheme switches fine and works on the keyboard. I guess I'll have to create a Vector2 binding for my entire movement if I want to make this work, although I'm not sure if a Vector2 movement will work based on what I'm seeing with the 1D axis stuff.

little geode
#

Well, dumb me. If you're using 1.1.1, just add the D pad stuff in the navigate section of the UI of the DefaultInputActions Action Map

heavy cipher
#

i feel like this has been asked before but

how do i ReadValue<>() a bool from a keyboard space action?

#

what control type do i use

#

oh should i use ReadValue<float>() != 0?

green island
#

Reposting this in hopes somebody can help me with this issue:
I'm having a bit trouble with the input system in the WebGL version of my project. I am using the old unity input system and the unity UI and when I click a button, it keeps on getting pressed repeatedly until I click somewhere else. How can I fix this? 🤔
I should add that it works great in the desktop release and the editors play mode, I have also seen the button working flawlessly on other peoples browsers

floral otter
#

I'm trying to use the "Virtual Mouse" device for the gamepad with the PlayerInput component. It works when there are no control schemes in the inputactionasset. However once you add a control scheme the Virtual Mouse isn't detected for a User.

How can I link the Virtual Mouse to a User with the PlayerInput component?

#

here doesn't appear in the "Paired Devices" section

EDIT:
FIXED: For those wondering of the solution: InputUser.PerformPairingWithDevice(virtualMouse, playerInput.user);

crimson crater
#

My ui is not working with the new input system

#

nvm

#

found a fix

turbid crane
#

I am using the new input system in a combination with FiniteStateMachine and for some reason, when running input on start and on exit It runs N times and slows down the game

#

has anyone had similiar issues?

tame crane
#

i added starter assets in my project

#

then i deleted it cause of this error

#

what do i do now?

tame crane
#

Thanks to my self that i made a backup of my own project

heavy aurora
#

(Regarding the new input system) Is it possible to get on code an input button to show as a string on UI? For example, if the currently active input for jumping is the "D" key I can grab it on code and use it as a string?

frigid ridge
bronze bison
#

hi all , anyone know how to get values from the keyboard with the new input system that are floats ?
like 0.5 0.4 -0.3 and so on ?
i am only getting 1 0 -1
From the gamepad i am getting the values
both vector2 are analog

fluid ermine
#

hey guys do you know why this is happening , i'm trying to set the position of the player when he join but it goes where the Input System spawned the player before i implemented this

frigid ridge
#

If you are looking to smooth the input, you can use Vector2.MoveTowards or some other smoothing method in the script.

sweet niche
#

Can someone help me understand how PlayerInput.Instantiate() works? Does that means that player 1 would "attach" to the newly created gameobject instead of creating player 2?

austere grotto
#

never tried it myself though

frigid ridge
#

Yea it seems to be an Instantiate wrapper with some values that will be set on the PlayerInput component on that prefab

sweet niche
#

Ok so how do I go about spawning a player "actor", but the player input are driving from a "NetworkController", namely a spectator game object not attached to a player "actor" yet.

#

I have the Player Input on the "spectator" camera, but when I spawn the Player that "hooks" into, I have to feed the input to the player somehow?

frigid ridge
#

I tend to just go for a separate Player gameobject that primarily hosts PlayerInput and some component to manage and send input to controlled gameobjects.

#

Then you can just unhook the spectator camera and hook in the controlled entity

sweet niche
#

That's the thing how do I do that? The "Spectator" is just a camera gameobject, that have Player Input, NetworkObject, and Player Handler (Just basically spectator behaviour)

#

I can parent this "Spectator" to a newly gameobject, but then how do I go about Attaching handlers to that?

#

Funny I'd say "possessed" a player

sweet niche
#

Ok so in this case here I have to use Player Input for controlling "Player". How do I give User 1 to control Player 1 character?

fluid ermine
#

wait ,is there a way to change player spawn position because i tried scripting it but it seems like it's setting another position after i set it?

#

like when i use Join When Action is Pressed

chrome walrus
fluid ermine
#

does local multiplayer is networking?

chrome walrus
fluid ermine
#

nah i'm using custom join method

#

but it seems like when i set the position , the input system set another one for me

chrome walrus
#

And it is set in your onjoined where you set playerInput position?

fluid ermine
#

or it just doesn't change the position for some reason even tho it should

#

well i'm doing playerInput.gameObject.position

#

it should work right?

chrome walrus
#

Should be transform.position

fluid ermine
#

oh wait i know.

#

thanks !!

#

also , how can i make the connected players join without pressing a button?

#

sorry btw for crossposting

chrome walrus
#

This is such a general question. You have to explain your setup, so we know what you mean? Generally answered, if they connect, put the function you use on button right inside your connected function

fluid ermine
#

well , when you connect your controller or your keyboard for exemple , i want my game to automatically add a new player without them pressing a button or adding a prefab of the connected player when i'm changing the scene instead of having them always press a button to join

#

i know i can do that with join manually but how can i get all the connected controllers?*

chrome walrus
#

well then listen for the connected function and use that to handle the join then

fluid ermine
#

yeah but is the connected function only on the playerInput?

#

like OnPlayerJoined is only executed when a player press a button or something like that , but it's not executed when a device is connected right?

chrome walrus
fluid ermine
#

ok ima check

chrome walrus
#

devices should give you the current once, maybe you gotta filter for gamepads or what not, but API should get you started there

fluid ermine
#

ok thanks

chrome walrus
fluid ermine
#

yup!

tame crane
#

is the new input sustem more versatile than the old one?

#

system*

fluid ermine
#

in my opinion yes it is

austere grotto
#

Much more versatile yes

tame crane
timber robin
#

Unity has a lengthy one on their YouTube channel.

tame crane
#

alright

#

as they are very well explained

fluid ermine
#

do you know why for some reason it doesn't get called?

haughty thorn
#

How do I add a sprint action? I'm confused on what the correct way to do this

#
    public void OnSprint(InputAction.CallbackContext context)
    {
        isSprintHeld = context.ReadValue<bool>();
    }
#

I have this code? basically I just want to know if the button is down, yes or no

#

So my action type is a Value

#

but what's my control type?

#

there's no 'bool' option :/

deft berry
#

so then if the value is not zero that means it is being held, right? so just use that

haughty thorn
#

I get the idea yes

#

but I don't know how to do that in code :/

deft berry
#

isSprintHeld = context.ReadValue<float>() != 0
this would make isSprintHeld true if it isn't 0 and false if it is

haughty thorn
#

🤔 okay, that worked thanks

#

mmh, still weird that there's no better way

deft berry
#

i mean there's many ways to do what you are trying. but this does exactly what you wanted to do in pretty much the same way you wanted to do it

haughty thorn
#

is this the optimal way?

austere grotto
#

it does the exact same thing though

haughty thorn
#

ic, thanks 😄

tame oracle
#

How do I get input from the player to the ui in the new input system... I found in the upgraded event system a navigation event toggle.. How do I use it.. I looked for help from unity support.. I can't find something to help me
I want to use it to detect if the player moves up and down in a drop down

ebon escarp
#

Hey guys, so im getting this error the whole time even tho im clearly not using the old input system anymore... anyone had the same issue/can help?

calm tapir
ebon escarp
#

is There anything that has to do with mouseinput that im not aware of?

calm tapir
#

if you're sure you're not calling it then try saving all your scripts or restarting unity

calm tapir
#

not sure how to help here sorry

ebon escarp
#

np thanks anyway

#

Ohh I got it... I added a ui canvas, and I needed to update the Eventsystem to the new input system

dapper ermine
#

is there a way to add a controller bind with get key down?

frigid ridge
#

With the old input system? I don't think you can at runtime. IIRC you can modify the file manually through code and relaunch the game.

round coral
#

Hey, everyone! I have a question to those of you who have shipped Unity games to consoles before: Did you use the Unity Input System or some third-party plugin like Rewired? I'm being told that the new input system doesn't work well with consoles yet.

spiral galleon
round coral
spiral galleon
# round coral Thank you, that's good to hear, I was kind of hoping for that. We're working wit...

Maybe someone had a bad time with it in the past or maybe there's just stubborn programmers at the studio 😛
I know of one studio that had issues with Rewired but that specifically for Stadia, but I also heard a lot of people really like rewired. I guess it boils down to if you want to trust a 3rd party to fix any issues related to input. Input System is open to modification after all so in theory you could implement any fixes yourself.

round coral
#

Having made the switch recently, I can say that so far we're having a bunch of trouble with input and movement that may or may not be Rewired's fault. 😅 Also, from what I've seen so far, Rewired's UI is not the best...

frigid ridge
#

Decent chance that there have been input system kinks on consoles in the past 6 months as the input system is getting mature. Rewired has been there for a while, so I can see it being a safe fallback for a lot of studios.

round coral
#

I see. In that case, I'll just hope that this will be ironed out by the time our next release draws close so we don't have to deal with another plugin.

gritty scaffold
#

Hello, I am new to Unity have a problem about taking input. I am having "InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings." error while using UnityEngine.Input.GetKeyDown (System.String name) function. I have tried this in two projects (also not being able to get InputValue), but could not find a workaround. As far as I understand, Unity can get input (I checked using one of Unity's features but forgot where I found it) from keyboard, but for some reason, I cannot get keyboard strokes trigger something in code (the game is unresponsive when I press something). I have also checked online but could not find a decent solution to solve this issue. Has anyone solved this issue?

calm tapir
gritty scaffold
# calm tapir you'll want to switch back to the old input system which you're trying to use Ed...

I removed the legacy input code (Input.GetKeydown) and removed the error. However, I was getting input from InputValue in OnMove() method. I was fallowing the Roll-a-Ball project from Unity tutorials, where until I integrated the UI, controls were working just fine. After implementing UI, the keyboard input stopped working, I probably got the error as I was trying to read input from keyboard to test it out. Now it keyboard input does not work without any errors...

calm tapir
dawn river
#

Do i need to declare a main controller with the new input system? as multiple devices plugged in causes unexpected issues.

west oracle
ocean patrol
#

Not 100% if this is the channel for this, but I have a terraria-like game with destroyable blocks. When a block is hovered, it lights up by enabling emission on the mesh. On the player gameobject, I have a click action script that reacts different ways to different things being clicked. It doesthis by casting a ray, returning the label, then working with that information. This system works great, but I cannot click through colliders, so if I place a sphere collider on my player (for interaction radius) there is no way to detect if the mouse is in the radius and clicking something clickable. It only returns information on the sphere collider, not anything behind/inside it. Is there a better way to restrict range on objects that can be clicked from the player's location?

austere grotto
#

or if not, you can just use a LayerMask on your raycast to exclude the player's sphere collider

ocean patrol
#

I could do the mask, but I need to know if the mouse is within that radius

#

Vector3 distance might be the move

lilac hazel
#

hi all how can I go about getting the value from this thrust value please, the examples dont seem to mention much

#

You have the OnWhatever etc etc, so in this case its saying OnMovement but I have no idea how to get the data inside

trim hollow
#

@lilac hazel which data you are looking for exactly ?

#

The input values?

#

You can do Mouvement.ReadValue<Vector2>()

austere grotto
tame summit
#

I have an inventory button, the function simply sets the window to display if it isn't active, or deactivate if it is active. Even with the On Button Released option in the actions settings this causes an infinite toggle between states and so the window never leaves. How do I detect if a key is pressed in code?

austere grotto
#

You should generally just be listening for the performed state/event of the button and it will just happen once when you press it.

tame summit
#
        {
            if (_input.inventory)
            {
                if(InventoryObj.activeSelf == true) { InventoryObj.SetActive(false); }
                if (InventoryObj.activeSelf == false) { InventoryObj.SetActive(true); }

            }
            
        }```
#

when I hit I, the inventory appears and disappears

#

So, I am not sure how to listen for when it is performed

austere grotto
#
                if(InventoryObj.activeSelf) { InventoryObj.SetActive(false); }
                else { InventoryObj.SetActive(true); }```
Or even better:
```cs
InventoryObj.SetActive(!InventoryObj.activeSelf);```
tame summit
#

InventoryObj.SetActive(!InventoryObj.activeSelf); this causes the menu to toggle infinitely off and on

austere grotto
#

the way you have it right now, if it's currently active, it will be deactivated by your first if statement, and then the second if statement will also run

austere grotto
tame summit
#

infinitely

austere grotto
#

you aren't showing enough here

tame summit
#

my inventory is being called in the update code

austere grotto
#

How are you handling the input

#

I don't see any input handling code here at all

austere grotto
#

unless you have some code that is checking for some input

tame summit
#

Well, the action mapping is set to only toggle the action as a button press

austere grotto
tame summit
#

It uses the input system and action maps

austere grotto
#

You just showed some code and said it's running in Update()

austere grotto
#

How are you listening for the button presses

#

there are many ways to do it

#

show more of your code

tame summit
#

its just the starter asset third person controller from the asset store

austere grotto
#

that starter asset doesn't have an inventory screen as far as I'm aware

tame summit
#

im just trying to toggle the inventory by listening for the key. _input.inventory listens for the key but doesnt respect the fact that the action is mapped to a button press

austere grotto
tame summit
#

private StarterAssetsInputs _input;

#

just uses the starterassetsinputs

austere grotto
#

what is StarterAssetsInputs? Is that the generated C# class file from the InputActionsAsset?

tame summit
#

yes

#

jump

#

run

#

ect

austere grotto
#

That's not a correct way to listen for input

#

If anything that's just checking if it's null

#

which it won't be

#

You probably need something like:

_input.inventory.phase == InputActionPhase.performed```
tame summit
#

phase does not exist

austere grotto
#

What is the type of _input.inventory?

#

mouse over it, your IDE should tell you its type

tame summit
#

input action asset?

#

its the thing with all the keymappings for the input system

austere grotto
#

doesn't sound right

#

_input might be InputActionsAsset

#

but _input.inventory should be ActionMap or InputAction or something

tame summit
#

private InputAction InventoryAction;

austere grotto
#

if it's an InputAction then it will have a phase property

tame summit
#
            InventoryAction = PI.actions["Inventory"];```
austere grotto
#

Then InventoryAction.phase should be a thing

#

Also if you're using Input System version 1.1+ you should also be able to use InventoryAction.WasPerformedThisFrame()

tame summit
#
            {



            }```
#

performed is underlined

austere grotto
#

Yeah because it's InputActionPhase.Performed

#

sorry capital P too

tame summit
#

ohh

#
private void MyInventory()
        {
            if (InventoryAction.phase == InputActionPhase.Performed)
            {

                InventoryObj.SetActive(!InventoryObj.activeSelf);

            }


        }
#

this causes it to disappear after toggling multple times

austere grotto
#

"disappear"?

tame summit
#

I can bring it back the same with while it toggles multple times

austere grotto
#

wdym by disappear

tame summit
#

yeah open and close inventory

#

its working wonkily now

austere grotto
tame summit
#

I hate this new input system. This was so easy to do with the old one. Just get key down, no big deal

austere grotto
#

At this point it's not the input system causing you issues

tame summit
#

its called in update

austere grotto
#

Also can you show how you set up the Inventory action in your Input actions asset?

#

You should just have it set up as a basic button with no interactions or anything

tame summit
#

no because discord is crap and cant handle a gif image

#

its set up as

austere grotto
#

It should just be Action Type: Button

#

no interactions

tame summit
#

Action Maps: Player Under player there's inventory, and in inventory there's the path with is the I key and its set to Press and Release

austere grotto
#

like this

#

and get rid of the Press and Release interaction

#

it's causing issues for you

#

You want a basic button with no interactions

tame summit
#

now it ceases to do anything

#

I was looking at this

#

no idea how this works

austere grotto
#

yes you can go event based but that will probably end up confusing you even more

tame summit
#

probably

#

I'll probably just have to write a coroutine to stop it activiating so fast, which I didnt want to do

austere grotto
#

you really don't have to

#

the setup we have discussed will work

#

you have something out of place somewhere

#

You can also try InventoryAction.phase == InputActionPhase.Started

tame summit
#

That causes it to work, but wonkily, toggling multiple times unless I super fast tap the key

#

even then it still will likely toggle multiple times

austere grotto
#

Something isn't right - can you share the current state of your code and screenshots of how you configured the input action, including all the bindings?

tame summit
#

Thanks so much !

thorny thistle
#

Hi so I seem to be running into a problem when it comes to setting up a button as a mobile jump button I can get it to work fine but I made it so that if the player dies they respawn and so since the player object gets destroyed and a new one spawns from the prefab the jump button loses the jump function since its assigned from the original player object. I've tried to assign the jump function from the prefab but when I try that the jump function doesn't work at all. Any help or maybe a different way of doing it will be appreciated.

chrome walrus
thorny thistle
#

Thanks that helped a lot!

sweet niche
#

What's the difference between CallbackContext and InputValue?

sullen plover
#

Hi,
I'm a beginner so please bare with me.
I am making a FPS controller with the new unity input system.
My input works absolutely fine when using mouse and keyboard.
Yet when I add bindings for a generic gamepad I get stutter issues when using the WASD - movement keys.
My gamepad look axis (right stick) is also slower in turn speed than my mouse.

The stutter with the WASD feels like the input is pressed but then abruptly stops whilst sometimes, I can press the WASD and have nothing happen at all - while the gamepad left stick moves the player just fine.

I have deleted previous the Gamepad bindings and this fixed the problem but obviously I want to use Gamepad as well.

I will provide details / pictures of how I have set up my Input System:

I have the 'Movement' action properties set to:
Action Type = Pass Through
Control Type = Vector 2

then separate control scheme profiles - one for keyboard, one for gamepad.

For the WASD I have a 2d Vector Composite Type and the Mode is set to digital normalized.

For the gamepad I have a binding with a stick deadzone processor.

#

For the 'View' Action I have Action Type = Pass Through and Control Type = Vector 2

I have delta [Mouse] for the binding with the control scheme set up on the Mouse profile - previously had this in keyboard profile but switching either made no differences in regards to the issue.

For the gamepad set up I have the binding on the Right Stick gamepad, Processors are using stick deadzone.

#

with the dead zone options for either profiles on / off I still run into the two problems I have stated:

  1. WASD stutters or does not work, randomly

  2. Right gamepad stick turns extremely slow, while mouse turn speed is perfectly accurate

#

Please if anyone can help i'd be so appreciative

sullen plover
#

@chrome walrus is this for the second issue?

#

do I use another processor and times the amount?

chrome walrus
#

Oh dang, I kind of jumped through your message, sorry 😄 yeah for the mouse gamepad difference 😉

#

just scale the gamepad input if you want it to be faster

sullen plover
#

how do I get it to match the mouse speed?

chrome walrus
#

Trial and error

sullen plover
#

got it

chrome walrus
#

there is no math for mouse to gamepad 🙂 as all can be different somehow.

sullen plover
#

I suppose you don't know why my WASD is stuttering?

chrome walrus
#

so you might want to add a setting later for sensitivity

#

Okay, wasd is stuttering? hm, let me see. did you send your code too

sullen plover
#

I am following a tutorial but it works fine until I plug my gamepad in

#

then the gamepad kinda becomes reliable with movement

chrome walrus
#

Oh, so you get input form gamepad and wasd at the same time

sullen plover
#

yeah I want the player to be able to use either whenever they want

#

but the gamepad kinda interrupts the WASD

#

I thought it might be something to do with the deadzones?

#

sorry im very new to all this

chrome walrus
#

Well, it sounds like your gamepad is sending input while in 0 position, so this is some drift issue with your gamepad. did you try another? Did you try to higher the deadzone to the max to just "kill" gamepad input?

#

Just make like 0.4 and 0.6 or something, but not sure if this actually interrupts the input or just kills the vector2 output. But Id say, its your gamepad sending dead values

sullen plover
#

okay thanks Twentacle

#

I'll investigate

chrome walrus
#

Happy to hear back what has been the issue, you are veyr welcome 🙂

sullen plover
#

ah just tested it

#

no matter where I change the deadzones it still has the same issue

chrome walrus
#

try another gamepad to be sure its not something else.

sullen plover
#

okay i'll have to find one

chrome walrus
#

You could just bind mouse 1 and 2 to the action of w and s for example just to test out if you can walk with either or at the same time

sullen plover
#

I just tried another gamepad same issue

#

okay i'll try that

chrome walrus
#

Did you remove the deadzone just to test that out too?

sullen plover
#

oh the joypad

#

no i'll do that now

#

and yeah it works fine with the mouse bound to 1 and 2

chrome walrus
#

So, back to gamepad, deadzone removed, still that issue?

sullen plover
#

yeah

#

still stuttering

chrome walrus
#

is wasd bound to keyboard too?

sullen plover
#

yeah

chrome walrus
#

Can you show your setting for WASD?

sullen plover
chrome walrus
#

Oh wait what. what did you do with the joystick?

#

why separate all directions? Just do this:

sullen plover
#

I changed it to a 2D vector just to see if it would make a difference

#

yeah

chrome walrus
#

Oh sorry, my bad then

sullen plover
#

I've tried both ways

#

no worries

chrome walrus
#

Did you just debug log your input you get? Just to see if there is dead input somewhere

#

so tap wasd, then use joystick, then let go everything an dsee what comes in as vector2

sullen plover
#

okay I will try to figure out how to do that

chrome walrus
#

you are using the vector somewhere, dont you

#

ReadValue(Vector2) or so somewhere

sullen plover
#

let me show you what I have

#

so on the awake

#

setting up the inputs right

#

um how do I send code

chrome walrus
#

So just debug.log input_movement

sullen plover
#

sorry for being such a newbie

chrome walrus
#

All good, you can send code with three times ` or just use hastebin

sullen plover
#
    {

        if(input_Movement.y <= 0.2f)
        {
            isSprinting = false; 
        }


        var verticalSpeed = playerSettings.WalkingForwardSpeed;
        var horizontalSpeed = playerSettings.WalkingStrafeSpeed;

        if(isSprinting)
        {
            verticalSpeed = playerSettings.RunningForwardSpeed;
            horizontalSpeed = playerSettings.RunningStrafeSpeed;
        }


        //Effectors

        if (playerStance == PlayerStance.Crouch)
        {
            playerSettings.SpeedEffector = playerSettings.CrouchSpeedEffector;
        }
        else if (playerStance == PlayerStance.Prone)
        {
            playerSettings.SpeedEffector = playerSettings.ProneSpeedEffector;
        }
        else 
        {

            playerSettings.SpeedEffector = 1;

        }

        verticalSpeed *= playerSettings.SpeedEffector;
        horizontalSpeed *= playerSettings.SpeedEffector;


        newMovementSpeed = Vector3.SmoothDamp(newMovementSpeed, new Vector3(horizontalSpeed * input_Movement.x * Time.deltaTime, 0, verticalSpeed * input_Movement.y * Time.deltaTime), ref newMovementSpeedVelocity, playerSettings.MovementSmoothing);

        var movementSpeed = transform.TransformDirection(newMovementSpeed);

        if (playerGravity > gravityMin)
        {

            playerGravity -= gravityAmount * Time.deltaTime;

        }

        if (playerGravity < -0.1f && characterController.isGrounded)
        {
            playerGravity = -0.1f;
        }

        movementSpeed.y += playerGravity;

        characterController.Move(movementSpeed);

    }```
#

so I'm presuming the newMovementSpeed might be the issue?

#

I'll put a debug log in the the update event to test while you read this

chrome walrus
#

first just debuglog the input_movement, is it 0,0 if you touch nothing after you controled with wasd and joystick first

sullen plover
#

okay so it freezes on (0,0,0.0) say if I switch from the left stick to wasd

#

if I don't touch the left stick - wasd seem to work fine

#

and the left stick is fine with moving - lots of numbers for both

#

but it is as soon as I have used the left stick and switch

chrome walrus
#

So if you use the left stick and then let go and use wasd, it starts spazzing out but input is still 0 if you let go wasd again?

sullen plover
#

no sorry

#

basically it works

#

only when I release the left stick and either press the wasd

#

or have the wasd already held down

#

it goes to all the zeros

#

I can move again fine if I just use the left stick again

chrome walrus
#

so when is it spazzing out? 😄

sullen plover
#

it isn't sorry I just meant the numbers move

#

there is another issue

#

sometimes even when I press WASD and haven't hit the stick

#

it will move fine

#

then stop and get stuck at 0

#

this was the stuttering effect

#

(im sorry if i'm not being very clear)

chrome walrus
#

Oh well, then you might just have to go from ground up, check whats your movement is doing. Remove all interpolation and just use raw and then add stuff one by one.

sullen plover
#

I suppose I'll just use the old input system

#

and get rewired or something when I have money

#

what a bummer

#

Thanks for helping me twentacle, I appreciate you taking the time out of your day

chrome walrus
#

sorry we could not get rid of your problem. Still I do not htink its the input system itself. But maybe its a bug. Best of luck figuring your way out 🙂

sullen plover
#

Thanks

dark copper
#

Making my own pairing system for the input system since I'm not a fan of the PlayerInputManager

#

How do I associate InputActions with a device? I've now got pairing implemented, and now I want the players to receive the correct input.

Each player has a reference to the device ID it's paired to. How can I reference InputActions that use WASD and gamepad analog stick from just the device ID?

If I just do this:

movement=controls.PlayerActions.Movement.ReadValue<Vector2>();

where controls is a new instance of the auto-generated C# class from the input actions asset.

It doesn't stop the keyboard from controlling players paired with a controller and vice versa

#

I've tried looking through PlayerInput.cs and PlayerInputManager.cs for answers, but I can't really find anything.

dark copper
#

Anyone know how this is achieved with the PlayerInputManager?

dark copper
#

seems to explain what I need

amber finch
#

controls.PlayerActions.Movement += ctx => movement = ctx.ReadValue<Vector2>();

#

that's how I do it and how it always works for me

#

I'm not sure if you're looking for this since I just saw your discussion

sick light
#

Can someone help me with the ui how do i make it so the input affects a parameter of a object

dense sluice
#

there is anyway i can trigger a press button event without using Update and FixedUpdate?

austere grotto
dense sluice
austere grotto
civic glen
#

Hey, so im trying to do something when i press grip on my vr controller. (if (grip pressed & is touching wall) --> start climbing)

How can i do this?

low cedar
#

Does Xbox one compiled games use the Cursor (lock states) by chance? I use the cursor to judge to see if my script needs to reassign a button to selected game object for controllers but idk if it would work in concept due to xbox not being a desktop with normal keyboard/mouse

spiral galleon
crisp gyro
#

I'm new to the NIS, I've forgotten how to add subscribers to an event

#
    void Jump()
    {

    }
#

do I need to add a parameter to my method or something?

#

oh

#

(InputAction.CallbackContext context)

dreamy zealot
#

Sometimes buttons get "stuck down" int he new input system

#

Like i'll be holding right and then let go of it and it keeps holding until I tap right again

#

as if that somehow "resets" it

#

the code is all adapted from old input system where it worked perfectl

#

for instance this used to be * input.getAxis

#

this has happened on previous unity new input systemp rojects

#

that Ialso adapted from old input system

#

and also had the exact same problem

#

which is why I abandoned them

austere grotto
# dreamy zealot for instance this used to be * input.getAxis

Looks like you're adding your input to your turnMovement variable instead of setting it. Unless you have some other code that zeroes it out, adding zero won't change it.
Overall it's hard to say what the problem is without:

  • seeing more of the context of the code
  • seeing how you've configured your input actions and bindings
dreamy zealot
#

yeah, it gets zeroed out every frame

#

it was addition in the version beforehand as well

#

it only gets "stuck" if I hold down a movement button, then hold down another button, and let go of it

#

it seems more like a glitch than some sort of systemic problem

austere grotto
dreamy zealot
#

thign is it only triggers if another binding(IE, for the boost/nitro) is held

dreamy zealot
austere grotto
#

leave the other actions alone

#

You have 4 separate bindings for Move, I've seen issues with that, especially if any of those devices are currently plugged in.

dreamy zealot
#

Here's a video showing the problem

#

with a keyboard overlay from OBS

#

notice how even after I let go of d the thing still moves right or a for left

#

and that only when I tap them again does it stop drifitng like that

austere grotto
dreamy zealot
#

I have no code that modifies your movement depending on your boost

#

Also @austere grotto Printing input values every frame confirms the problem

#

even when I let go of A or D the input still prints

#

as if I was

austere grotto
#

are you just reading the value in Update?

#

Or using events?

dreamy zealot
dreamy zealot
austere grotto
#

That's not wrapped in any if statements or anything?

dreamy zealot
#

I read that doing that is the drop-in replacement for getaxis

#

Nope

austere grotto
#

yeah it should be 🤔

#

that's quite strange

dreamy zealot
austere grotto
#

You don't have any interactions or processors on the input action or the bindings do you?

dreamy zealot
#

The only processor I have is deadzone, and if I remove it the results are the same

#

for boost I have it set to action type value again and no interactions or processors

austere grotto
#

I've never seen this before 🤔

#

actually calling ReadValue in Update, should have no issues