#🖱️┃input-system

1 messages · Page 38 of 1

static walrus
#

in NIS?

full forge
#

in the new input system

#

both project use it

#

same setup and i even copy pasted the c# which works at edit time

full forge
#

problem solved: it was missing a special package from the Switch team

#

bit of a black box, they need runtime debugging

fleet lichen
#

Hello, I am a bit new to the input system and am having trouble.
Is is possible to disable 1 action from the action map?
I tried .disable() but it stayed on.

static walrus
#

@fleet lichen i actually wonder about that too, it was supposed to be possible to unsubscribe but it didn't work for me so i just worked around it by making a delegate and setting whatever action i need to it, and call the delegate with input. and now i'm wondering if it's possible to just change the method it calls, without the delegate

chrome cypress
#

When I don't wiggle my right stick, the new Input System stops registering inputs from it. The built-in Input System doesn't have this problem. The Left Stick doesn't have this problem either.

low raft
#

I'm currently working on my own custom input manager and I followed this tutorial: https://www.studica.com/blog/custom-input-manager-unity-tutorial
which is great and all however he's using

jump = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("jumpKey", "Space"));

for assigning a default value to the key. Is there like a default name for those key names? or can I just use my own?
for example, he uses the string "jumpKey", but could I also rename it to "spaceKey" or whatever?

static walrus
#

@low raft you sure that way is better/easier than just using new input system?

low raft
#

@static walrus I'll take a look at it asap. Didn't catch up bout rhat yet

fleet lichen
#

@static walrus Thank you for the info but I am a little confused on making a delegate.
Are you talking about the InputDeviceCommand stuff in Unity.
Sorry still getting used to all the features in Unity 🙂

static walrus
#

@fleet lichen System.Action whathappensonbuttonpress = delegate { print("this is before it's assigned"); } MethodThatYouWantToExecute(){} AnyOtherMethodThatAssignsWhatHappens() {whathappensonbuttonpress = MethodThatYouWantToExecute();}
something like this

#

and then input ctx => whathappensonbuttonpress();

#

it allows switching what you actually want to do, and i have no clue if i actually did it right, but it works :0

fleet lichen
#

Ahhh ok.
I used something like this for when the button is held down or not.
Would this still hold true when the input I want to stop is the delta of the mouse?

static walrus
#

ehh, for delta you'd probably handle it elsewhere, checking if value is lower than you want

fleet lichen
#

Hmmm, I'll have to read up on it more.
The end goal is to stop the mouse from moving the camera if a button is pushed.

static walrus
#

@fleet lichen what's causing the camera to move?

fleet lichen
#

@static walrus I have a look action in the input system that gets the mouse delta.
Then I call the delta by returning the Vector2 and finally using that info in the postpiplinestagecallback override for cinemachine.
This gets my virtual camera to follow the mouse.

#

Maybe it's not the best way to do this but I wanted to use cinemachine.

static walrus
#

so you just make it so that if bool is true, input = get mouse delta, if false, do what you want to stop camera

#

@fleet lichen

fleet lichen
#

That.... makes a lot of sense

#

LOL thank you I will have to give that a try when I get home.

low raft
#

@static walrus so... what's the equivalent of the new input system regarding

if (forward has been pressed)
{
  // do stuff
}
static walrus
#

you assume it always is, you just make a bool to prevent it from doing anything

#

if i should be able to move, i move. if i shouldn't, i don't. do you have a case where you need to know specifically if it's being pressed?

low raft
#

Yeah so first off I want to have a custom UI for my input system
so let's say pressing jump is binded to the "space" key as default
but if i wanna bind jump to lets say, "return", it'd be bad to say

if (space has been pressed)
{
   // do stuff
}

also i need bools that indicate w/e that action is being pressed or not
regardless of the key that it has been binded to if you get what I'm saying

#
            if (inputManager.isInput[0]) { // do stuff }
            if (inputManager.isInput[1]) { // do stuff }
            if (inputManager.isInput[2]) { // do stuff }
            if (inputManager.isInput[3]) { // do stuff }

            dir = Vector2.ClampMagnitude(dir, 1);
            didDirectionChange = !dir.Equals(direction);

            direction = dir;

            actionPressed = inputManager.isInputDown[4];
            cancelPressed = inputManager.isInputDown[5];
#

this is my current input system, and it takes the the action regardless of the key that has been specified to it

#

above are the general actions, and below that are the keys that are binded to that action

#

i could change the default input keys to
forwardArrow
backwardArrow
leftArrow
rightArrow
etc
and it wouldnt change the way the system works

static walrus
#

@low raft hold on i'm not completely getting you, you're worried about rebinding? NIS handles it perfectly

#

you abstract it by default so you just press jump, and then define jump in settings that can be rebound or multiple different methods of controlling

fleet lichen
#

@low raft This might help
Public bool Inputyouarelookingfor()
{
return controls.action.triggered;
}

The .triggered returns a true if the assigned button is pressed. so no matter what button is assigned the function works the same.

low raft
#

Yes I see that I can bind it to any key I want
In the tutorials I watched so far it's specified to they key , not the action itself however

static walrus
#

@fleet lichen do you know if it's possible to cancel manually?

low raft
#

hmmm

#

Alright

static walrus
#

@low raft that's the replacement to old

fleet lichen
#

the function will return false once the button is not being pressed

static walrus
#

it's not how you're supposed to use it

fleet lichen
#

So in my case I have a IsJumping function

If(IsJumping())
{
//Do stuff
}

#

And if the isJumping returns false nothing happens

static walrus
#

yeah, you can either skip that step entirely or make same bool with NIS

#

if all you're doing is calling a method there then you skip the step. if you have extra complexity then bool

low raft
#

Well I should ask a simple question before:
Can those keys be manually binded with a UI?

static walrus
#

yes

low raft
#

alright so do i have to make a individual binding for each key then to specifiy what direction has been pressed exactly?

#

because right now if would check if this binding has been pressed, it could be like any direction

static walrus
#

it could be vector2d, or you can access the 2D Vector.x and y

#

so if you need to detect camera looking up/down you just grab .y and see what it does

low raft
#

ohhh yeah i totally forgot about those, however that isn't enough since I need to know exactly which direction has been pressed

static walrus
#

there's probably a way but i never needed that so idk

low raft
#

and x could be left or right, and y could be down or up

#

hmmm ill have to look that up

static walrus
#

i mean

#

imagine using controller

#

you'll use dpad for that? then sure

#

if it's a stick then knowing what's being pressed is impossible like that anyway, you'd need to check it after grabbing input

tame oracle
#

How do you rotate on the Z axis for joysticks effectively? Here I am using CS xRot = Input.GetAxis("JoystickX") * joySensitivity * Time.deltaTime; zRot = Input.GetAxis("JoystickZ") * joySensitivity * Time.deltaTime; transform.Rotate(new Vector3(xRot, 0, zRot));
but does this (I am pulling back on the joystick, but it sways side to side)

static walrus
#

@tame oracle 6DoF tutorials for starters

tame oracle
#

Okay

static walrus
#

there's also that kinematic demo by unity which has a working flying ship

tame oracle
#

Do you have a link by chance? Can't find that demo

static walrus
tame oracle
#

Thanks

tame oracle
#

Yeah I realized that there was no issue and that I should probably get some sleep so that I don't waste that much time trying to fix something that was working as intended lol

full forge
#

how do you attach a gamepad button to a UI button?

tame oracle
formal mesa
#

Hey guys,

I got a question.
I created a game mostly using JoyPad-Input. And so i created Inputs like this:

#

Is it possible to map "Attack" to an UI-Button?

#

right now I'm doing a workaround like this:

        uiAttackButton.GetComponent<Button>().onClick.AddListener(MeleeAttack);
        uiSpellButton.GetComponent<Button>().onClick.AddListener(SpellAttack);
#

which isn't that cool...

#

What i want is to actually do this with an UI-Button:


        if (Input.GetButtonDown("Attack") && currentState != State.attack && notStaggeredOrLifting && inventory.currentWeapon != null && meeleCooldown == false)
        {
            StartCoroutine(AttackCo());
        }
#

Does this make sense?

static walrus
#

@formal mesa on button click call method/event?

formal mesa
#

the best case would be... to trigger Input.GetButtonDown on UI.Button.Click

static walrus
#

ui buttons have on button click

formal mesa
#

yes but I would need to reference the input.GetButtonDown("Attack") to that click

#

i want my ui botton to do the same as my controller

static walrus
#

you're just thinking about it a bit wrong

formal mesa
#

that might be true

static walrus
#

if (Input.GetButtonDown("Attack") || onbuttonclick)
{ if (the rest of your conditions)}

#

not sure the correct way to do it though

#

but either way the rest of your conditions are in a method, while the button tap or click call it

#

also switch to new input system to save headache with different controllers later

#

it can wait if you're not doing too much stuff though

formal mesa
#
if ((Input.GetButtonDown("Attack") || uiAttackButton.GetComponent<Button>().onClick)
#

this says it cant be bool

#

that was my first idea 🙂

#

maybe i still got you wrong

static walrus
#

why are you getting component

formal mesa
#

good question...

#

not needed

#

still same error

static walrus
#

no i mean, you're just poking blindly

#

idk about old system, in new one you could just assign both the buttondown and onclick as events

#

yeah there are so many ways to go about it and i don't know a single one, don't want to poke into old system either

formal mesa
#

i got that

#

hmmm

static walrus
#

i switched to NIS expecting that kind of bullshit

formal mesa
#

im still suprised i just cant check for true/false for the onClick event

static walrus
#

old input's great when prototyping but falls apart as you make game more complex

formal mesa
#

actually this should be basic.

static walrus
#

that's because onclick event is an event

formal mesa
#

yeah thats actually just what i want

static walrus
#

although no, i'm probably wrong about it

#

iirc events are delegates

formal mesa
#

i want to press the ui button and make an attack

#

nothing more

#

with those listeners its working fine

#

but thats some nasty extrasteps

static walrus
#

hmm

#

want me to try doing that in new input system? i'd need a menu eventually anyway

formal mesa
#

i dont have anything to offer 😉

#

in form of menu

static walrus
#

it implies that if i find a solution then you switch to NIS though

formal mesa
#

ive not read about the NIS

#

but all ive heard from it was good

#

so

#

no problem?

static walrus
#

it's hard to wrap your head around but it does the job so far

shut berry
#

having a problem adding players when I add with a custom layout

#

the thing will not add when I allow players to spawn

shut berry
#

never mind I found out I cannot use both keyboard and gamepad combined

shut berry
#

but anyway to figure out player Index when you load a player

#

?

#

never mind I found it it

tame oracle
#

I was trying to see if it would work but could anyone tell me whats wrong ps im beginnerish

#

like why is it saying i dont have a constructor with 2 inputs

glass yacht
#

That is not how you construct an array

#

your constructor also isn't public

tame oracle
#

oh, lemmi look it up

#

@glass yacht how do I

tame oracle
#

ooooh that would explain why ive never got them to work lol. Thankyou @glass yacht

pale shard
#

How to check if the player is not moving using character controller ?

final ledge
#

Why textmesh pro has only latin letters?

zinc stump
final ledge
zinc stump
final ledge
zinc stump
#

I think if you are adding already made font supporting the language it would be automatic.

final ledge
#

Im adding fallback fonts to existing stilized fonts i already have

trim hollow
#

Hi guys, I’m using a inputactionmap.AddAction() in my code but I can’t find anything to remove that action using script ...

#

I only find RemoveAllbinding

#

Any idea what’s the method to remove an action from the actionmap?

trim hollow
#

nvm found it Action.Remove exist just not in doc or i didint find it 🙂

tardy adder
#

guys is use somebody a new input system for production on mobile devices ? It's ok, if touch input taked 2ms by self ?

heavy cairn
#

Anyone know how to make
if (Input.GetKeyDown(KeyCode.JoystickButton7)){} a long press button before it it used?

An example: the KeyCode.JoystickButton7 is the Start button on the Xbox gamepad, i want to hold the button for 0.4 seconds before it can execute a command so the single click does something else

tardy adder
#

@heavy cairn use GetKey() and increase your timer along is true, or use Invoke(methodname, 0.4f); and call CancelInvoke(methodname); if KeyUp

heavy cairn
#

Can you write an example with getkey()?

I haven’t programmed in over 20 years and looking to try something with gamepad but don’t know how to implement what you’ve told me on that previous code

#

Trying to learn by example

tardy adder
#

@heavy cairn

if (Input.GetKey(KeyCode.JoystickButton7))
        {
            timer += Time.deltaTime;
            if(timer>0.4f)
            {
                //here need reset timer or set it to 
                timer=0;
                ExecuteMethod();
            }
        }else if(Input.GetKeyUp(KeyCode.JoystickButton7))
        {
            timer = 0;
        }
tame oracle
#

Hi there. Basic question, but I can't seem to find this on Google... How do I get Unity to recognize input from both copies of the Horizontal and Vertical axis? I set up my secondary set to use the D-pad on my controller (6th and 7th axis) but then for some reason the thumbstick stops registering input (x axis/y axis in the default). How do I make both work? Thanks.

#

Nvm, figured it out. Copied the secondary hor/ver axis one more time and set up separately stick and d-pad and it worked. Thx and gl all.

strong cairn
#

Sorry in advance for the stupid question. I'm attempting to make use of the new input system. Earlier I started a new project and imported a few basic assets as well as the input system package. I was able to create an input action asset and add the player input script to an object. When I attempted to add a custom event, referencing the quick-start guide (https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/QuickStartGuide.html, example at the bottom), I run into an issue where the script fails to compile:
The type or namespace name 'InputAction' could not be found (are you missing a using directive or an assembly reference?)

Is there something else that needs to be done to get InputAction working? I've been reading through setup documentation, and I can't figure out what I missed, if anything.

I did try finding a solution online, but I didn't have any luck, and I'm just about out of ideas aside from scrapping the project, creating a new one, and trying again.

jagged wyvern
#

don't use the new input system unless you need to

strong cairn
#

I was looking to use it to simplify keyboard/controller support, and there were some things that could be done with it that I couldn't figure out how to do with the legacy input system. Optimally, I'd like to get the new input system working, at least to test it out and compare it to what I had on the legacy system

#

Ended up creating a new project and imported the input system immediately, without importing anything else... but it's still throwing that error. Has anyone else hit that before?

#

...nevermind, new project fixed it

zinc stump
#

On the Package manager page you can import examples which showcase how to work with it 3 different ways at least.

strong cairn
#

For some reason, the imports didn't automatically detect in the old project. New one had the "UnityEngine.InputSystem" piece that the other one didn't seem to recognize

south pilot
#

Hello I have this error with the new Input Sytem

Here is how I set the callbacks

        Controls.Player.Tile.performed += ctx => SetMousePos(ctx.ReadValue<Vector2>());
        Controls.Player.Right.performed += _ => RightClick();
        Controls.Player.Left.performed += _ => LeftClick();

What is it about ?

NullReferenceException while executing 'performed' callbacks of 'Player/Right[/Mouse/rightButton]'
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)
lone tide
#

I have a really annoying issue that I've beent rying to solve for days now; essentially buttons dont work at all in a build or when I choose "build and run" on neither mouse nor controller, but they work just fine in editor. Any ideas why this may be?

I even set up a test scene with just a single button - it gets highlighted in build but wont react to being pressed.

I'm using the new inputsystem, I tried all update modes in input system package settings within project settings, and also tried all pointer behaviour on the InputSystemUIInputModule too. Version 2019.4.f1

Has anyone encountered this? Any ideas what I could try?

lone tide
#

Managed to fix it, I dont understand why this is the case but after changing the submit action to be interaction: press only, it now all works ¯_(ツ)_/¯

austere meadow
#

Whenever I use Cursor.lockState = CursorLockMode.Locked; the entire input for the mouse is constantly 0

#

I guess it's because it's using the mouse delta and the actual cursor doesn't move and has a foxed position, but that's just a stupid thing to have to work around

#

actually it's so stupid it almost makes the new input system unusable

#

what game has a visible cursor when in first person view???

obtuse rover
#

Ones that use the mouse for UI interaction without having to explicitly enter a menu

static walrus
#

@south pilot how did you manage to confuse tilemap collision nullref with input system

south pilot
severe sorrel
#

is there a way to flip my Input axis based on character direction?

#

I have a motion input system where the "Horizontal" input returns "Left" or "Right" so the player can do directional inputs. currently its based on character direction
so basically if im facing north and press Left on the stick it returns left, If i press the stick right it returns "Right". if the character turns around then this should flip, so that it matches the controller and the character doesnt jump the oppposite direction

#

because if the character turns around then Left on the stick is Right for the character so i dont want him dodging to the left

#

this is probably an awful way to explain it but if anyones got any ideas i can show the code and a video of whats going wrong

swift heath
#

@severe sorrel Well ,you have to "flip" it by yourself, not in the input setting. Check for the character direction and flip it

#

but is hard to imagine what you have over there, can be anything with that explanation

dark thicket
#

Hi, I am pretty new to game development and have been trying to learn the new input system for VR development. Right now I am just trying to console log a trigger value from my Rift S controller. I have my XR Rig set up with the default input actions and I am able to log out the trigger value but it only logs 0 and 1 values not the float value. The attached image is of the PlayerControls script that is logging the value. Any idea why this isn't logging the in-between floats?

fringe swan
#

Hello, not sure if answered already, but whenever i try to cancel a rebind in the new input system, it actually rebinds to "anyKey"

#

My rebind operation is set up with ".WithControlsExcluding("<Keyboard>/escape")" and also ".WithCancelingThrough("<Keyboard>/escape");"

#

Also, for some reason, rebinding to the arrows when the num lock is pressed rebind to "print screen"

fringe swan
severe sorrel
#

Is it possible to simulate the AI having its own controller? I have a movelist with follow ups and id like the AI to be able to for example Spam the attack button and go through the combo without recoding it all

#

for example instead of starting a new state i could treat it like he was holding a controller

#

and take taht input

#

so when i want him to attack i could do "Press Square on this controller"

fringe swan
#

You should abstract that, create a class "brain" that controls your character and has implementations that take a controller input to say what actions to take and implementations that take an AI to say what actions to take

soft steeple
#

so when you mess up writing that script, then you can say, "oh no, my brain is broken!" or, "my brain has bugs!"

novel hedge
red isle
#

Hullo! Could anyone tell me how to go through inputaction assets programmatically? If possible at all?

glacial thicket
#

is there any way to poll actions instead of receiving them as events?

#

nvm found how to do it I think

red isle
glacial thicket
#

wait I can't use the actions I've already set up in the inputactions thing
smh

#

if anybody knows how to get the inputactions from the inputactions asset / generated class I'd like that

#

nvm, found out how, have to create a new instance of my generated class and get the actions from that

weary holly
#

👋

#

im using the new system and broadcast messages, the event do not get triggered tho. i created the system added the player input and hooked the system into it. is there a magic step to get it working or am i just retarded?

weary holly
#

this is driving me nuts

glacial thicket
#

I love that the doc talks about these functions but they straight up don't exist in the package

#

at least for me

weary holly
#

i made it the "old fashion" way by exporting the script and binding the actions

#

useless code but whatever

glacial thicket
#

nvm it's only in the preview version, which the doc defaults to despite it not being available in the package manager

static walrus
#

@glacial thicket did you copypaste it as is or inputaction.state.button.ispressed?

icy ferry
#

Hey does anyone know how to fix this issue? I can’t get the input system working at all, the properties panel and input debug window are completely blank.

#

I tried with different versions of unity and the input system and no luck.

bitter ice
#

This is probably a really basic question, but I want to add behavior to an object where clicking on selects it, and then pressing numbers causes it to show whatever the last number pressed was (for tiles in a number puzzle). Would you recommend I use a text input box or should I custom script it using a text box and a button? Any good tutorials related to this topic?

fallen kraken
#

What's the reason for using the input system?

icy ferry
#

to use controllers

fallen kraken
#

Thanks @icy ferry

meager flare
#

Hey I have this move thingy with a vector2, I use it to well move the character with a simple rb.velocity = context.ReadValue<Vector2>();
But I have a problem, when I pressed right key and after the left key (and so getting both of those key pressed) the vector 2 x is equal to 0 instead of 1 ( like it would with the Input.GetAxis). So how could I fix that ? It make the character stop and it's really annoying :/. I thought about detecting which binding is pressed but I also don't know how to do that x)

ember dagger
#

I need help 😦

#

Why when in IPAD and in Editor it doesn't result the same output ?

 bool HitTestUVPosition(ref Vector3 uvWorldPosition)
        {
            RaycastHit hit;

            Vector3 cursorPos = new Vector3(Inputs.Position.Position.ReadValue<Vector2>().x, Inputs.Position.Position.ReadValue<Vector2>().y, 0.0f);
            Debug.Log("Cursor Pos " + new Vector2(Inputs.Position.Position.ReadValue<Vector2>().x, Inputs.Position.Position.ReadValue<Vector2>().y));
            Ray cursorRay = ViewCamera.ScreenPointToRay(cursorPos);
            if (Physics.Raycast(cursorRay, out hit, 200))
            {
                MeshCollider meshCollider = hit.collider as MeshCollider;
                if (meshCollider == null || meshCollider.sharedMesh == null)
                    return false;
                Vector2 pixelUV = new Vector2(hit.textureCoord.x, hit.textureCoord.y);
                uvWorldPosition.x = pixelUV.x;//To center the UV on X
                uvWorldPosition.y = pixelUV.y;//To center the UV on Y
                uvWorldPosition.z = 0.0f;
                return true;
            }
            else
            {
                return false;
            }

        }
#

It was working fine couple of days ago, I'm not sur of what I changed or something, and I was about to release my app

meager flare
#

and does someone know how to use multi tap interaction ? It doesn't change anything for me :/

meager flare
#

nvm I fixed it myself

dark thicket
#

I am wondering if there is a reason that the trigger values I am able to log out of my Oculus Touch controllers read from the low end of 1.43533 E-14 to 0.9999999 and not 0 to 1. Anyone else have this issue and have a way to resolve it?

main echo
#

so im trying to make a third person shooter game where the look angle is controlled with the mouse (like most FPS/TPS games). my script is working well, however when the mouse cursor hits the edge of the screen, i can't rotate my view any further in that direction. is there a way to snap the cursor back to the center of the screen at the end of each frame after i've done all my calculations using the cursor's position?

glass yacht
main echo
#

am i supposed to use this in conjunction with Cursor.visible? because that's what i tried and it doesn't allow any mouse movement at all

glass yacht
#

You can. It wouldn't allow for mouse movement but it should still accept delta input

main echo
#

where am i getting the delta from? is there a mouse delta variable in the Input class?

#

currently i'm doing:

Vector2 oldMousePos;

Update()
{
  Vector2 mouseDelta = Input.mousePostion - oldMousePos;
  // do stuff
  oldMousePos = Input.mousePosition;
}
glass yacht
main echo
#

ah, thanks

tropic oxide
#

Hey :) I need to get key input while the "game" isnt in focus. I try to make a tool that is basically a chuncked walkthrough of PoE for the second screen and want to switch hints back and forth with 2 hotkeys

chrome walrus
#

@tropic oxide That might be called keylogging and is not allowed I think.

#

Or you have another application that listens for those hotkeys, if you mean that

tropic oxide
#

How do other apps like LiveSplit, OBS, Teamspeak handle this issue (using hotkeys while not being in focus)?

west tulip
#

I am currently trying out the new input system but whenever a button is pressed the event is called thrice

#

anyone know how to fix this

tropic oxide
#

bool keyA_pressed = false;

if (pc.General.keyA.ReadValue<float>() > 0f && !keyA_pressed)
{
//do stuff
keyA_pressed = true;
}
else if(pc.General.keyA.ReadValue<float>() <= 0f && keyA_pressed) {
keyA_pressed = false;
}

chrome walrus
tropic oxide
#

how do I use code tags 👀

chrome walrus
#

three times ` before and after your code

tropic oxide
#

if (pc.General.keyA.ReadValue<float>() > 0f && !keyA_pressed)
{
        //do stuff
    keyA_pressed = true;
}
else if(pc.General.keyA.ReadValue<float>() <= 0f && keyA_pressed) {
keyA_pressed = false;
}```

@west tulip Not sure if its state of the art, when I used the system several months ago it had no OnPress or OnRelease functions.
chrome walrus
#

@tropic oxide What hotkeys are you actually talking about? Like with a StreamDeck and so on?

tropic oxide
#

No, the basic keyboard hotkeys. You can start recording ingame, mute yourself in teamspeak or make a timestamp without those apps being in focus.

chrome walrus
#

Hm, good question. Just wondering how those hotkeys are overriding for example an ingame hotkey.

novel hedge
magic aspen
#

Hey anyone here have experience with setting up controller inputs with the new system?

#

Will pay for some help lol

magic aspen
#

Anyone ? I'll pay.

zinc stump
magic aspen
#

Is there a place to hire someone for help then lol. i have it installed im having troubled with variables

zinc stump
#

There are game dev communities with job boards, not here.

chrome walrus
magic aspen
#

@chrome walrus yeah fair enough ahah

novel compass
#

Hello!

#

Does anyone know if the New Input System is compatible with Unity Remote 5? I can’t seem to get it to detect touches

#

I’m fairly sure I have everything set up correctly because I’m able to get a mouse click to work with the same code I want to use the touch with

vernal seal
#

short answer: it isn't compatible 😛

cedar vortex
#

Hello everybody! I'm new here.

#

I'm very interested in the new input system, but I don't know where to start and where to find tutorials

#

Could someone help me?

tame oracle
#

@cedar vortex look at demo projects

#

in package manager

cedar vortex
#

Do the demos come together when installing the package?

west tulip
#

how do i get the mouse input with a 2d vector composite

#

pls help

bronze parrot
#

In the Unity Docs it says

control schemes impose a set of devices requirements that must be met in order for a specific set of bindings to be usable

about control schemes. So, how can I know which control scheme is being used in my project and is there some sort of event fired when the control scheme is changed?

crimson scroll
#

how on earth do i convert TextMesh Pro UI - Text input to an integer?

Debug.Log("Playing custom game:" + CustomGameTextInput.text);

it prints the correct output, e.g.:
Playing custom game:1234​

I can show the text in a Debug.Log and it looks right, but then when i do:

int result = int.Parse(CustomGameTextInput.text);

I get:

Format Exception: System.FormatException: Input string was not in a correct format.

can anyone point me in the right direction here? i've tried googling to no avail.

glass yacht
#

This isn't really an #🖱️┃input-system question, but you just need to trim the end off of the input string.
.Trim() gets most of them, but I've seen it require a .Trim('\u200b') in the past

crimson scroll
crimson scroll
glass yacht
#

The question's really just about string parsing

tight furnace
#

Hey guys, a bit new here...

#

I'm learning animation transitions, I need a way to transition states by 1 condition or another.

#

but NOT both are required to be true, just 1 or the other.

#

also im curious about what the difference of these transitions are

#

ah ok, found it out, I needed 2 transitions (the triple arrow). I had to set the first condition on one of them, and the 2nd condition on the other.

terse basin
#
hey anyOne know a simple input system for example when u drag up ur finger in the screen the person jump or if drag left or right the person go left and right
i need only the input system
if(input....)
????????????
glass yacht
hearty latch
#

Hey guys. new today to the InputSystem. Got it going code seems fine. But i have inverted controls! So W = going left S = Right A = up. Not sure what i may have done wrong. Any help would be great

ancient gazelle
#

What would be the correct way to get a mouse input the way you could with "Mouse X" in Input. I've tried delta but it didn't work correctly

heady silo
#

Hey i need some help !

#

Is there a way to make controls for mobile with the input system?

#

If yes how

#

@ me if anyone figures it out

rustic pawn
#

sprite + button + your event(move) @heady silo

heady silo
#

Ty!

mild rose
#

I wanna add joy stick and jumping button and crouching and aiming area who knows how to help me pls ping

#

And it would be better if its on another script not the same as the fps script cause fps script is big and I dont wanna mess it

mild rose
#

So basiclly I need code that can work with key board and mouse when plugged and for touch joy stick jump and crouch or just tell me how to make i will make it cause I cant think of a way

#

Pls.

frigid ridge
#

There probably are events in the new input system for when new device is detected

mild rose
#

thanks m8

safe drum
#

Guys, I'm using the unity new input system and I'm having issues when trying to drag objects with the mouse cursor.

safe drum
#

this is what my code looks like:
public void DragMe()
{
Vector2 movePos = new Vector3(Mouse.current.position.ReadValue().x,
Mouse.current.position.ReadValue().y, gameObject.transform.position.z);

    gameObject.transform.position = Camera.main.ScreenToWorldPoint(movePos);

}
safe forge
#

is there any advantage to using

{
//things
}
   if (Input.GetKeyUp("W")) 
{
//opposite things
}

to detect inputs instead of just

{
//things
} else 
{
//opposite things
}```

?
#

besides a possible one frame delay i just dont see it.

glass yacht
#

They are fundamentally different

#

one does something only if down or up (single frames)

#

the other does something always (either held or otherwise)

safe forge
#

So the only thing is an extra process running always. okay.

azure atlas
#

Hi there! I'm currently making a click-to-move mechanic using the New Input System. I'm trying to avoid hard-coding the controls.

Is it possible to get the Vector2 mouse pointer position only when I click the left mouse button without having to call Mouse.current.position in my code? The ButtonControl returns a float. How do I make it return the Vector2 mouse position instead?

I created this thread in the Unity Forum. https://forum.unity.com/threads/mouse-click-to-move-using-the-new-input-system.1041241
I hope someone answers.

slate jetty
#

Hey is there any way to simulate more than 1-finger-touch with the Simulated Touchscreen on the new input system ?

red isle
#

How one does access the input actions asset programmatically, I'd like to make a tool that "magically" create a rebind screen and this is the first step. Can we start from the Input asset directly or do we have to use the generated class? For the rebinds, we use the class too though? Any way to generalize this for a tool?

tidal sedge
mild rose
#

Nope not new input system didnt work with my fps script

tame oracle
#

can i make unity control my computer? like if i hit a certain wall in the game it will input W on my keyboard, is that possible?

tame oracle
#

you can use an external library

copper night
#

Guys, is the Input system compatible with the new UI? And if so, any pointers on how to make it work?

frigid ridge
#

@copper night Need to change some stuff on the EventSystem on your UIs

#

I believe it's one click to convert

humble lichen
#

can sombody help me?

#

like when you put your name it says your name back in a different scene?

chrome walrus
#

You want to store the name? I would start with player prefs @humble lichen google will give you resluts about them

severe bay
#

Hey, is it possible to use the Input System with the Steam Controller in the editor? Unfortunately a steam controller is the only controller I've got at the moment.

chrome walrus
#

Hm you should have buttons like D-Pad without being specific to Xbox or ps4 or whatever, just try it out.

severe bay
#

Having messed with it a little, it seems that the steam controller is listed under unsupported devices in the editor, and it can be used pretty well with the editor, but it is actually just sending keyboard and mouse inputs, rather than any Xinput button presses or anything like that. I've read online that you can add the editor to steam in order to get the steam controller to work properly, so I might try that next. Really, I think this is more a Valve problem than a Unity problem.

#

It's a little unfortunate because it seems like if I want to have a game work with the steam controller without requiring it to be launched via steam, I have to bind a bunch of keyboard buttons to actions in the game, which might conflict with the normal keyboard controls.

severe bay
#

I finally got this to work by adding the version of the unity editor I am using to steam and adding the command line argument -projectPath "E:\Unity Projects\YourProjectHere" to the "game" properties in steam. This results in the device being recognized by unity as an Xbox controller. Whatever controller configuration you set the the unity "game" in steam will determine what button presses are sent to unity when configuring the controls. I don't think this method allows you to access any of the raw input from the touchpads, as the input is converted into joystick input by steam.

humble lichen
#

@chrome walrus hm? google doesnt help what should i put in google?

chrome walrus
humble lichen
#

?

chrome walrus
# humble lichen

I am not the guy that helps at every little step... put some effort in it

calm rampart
#

Hello

#

I installed the new input system and now UI and eventssytems are gone how can i refrence a text object. Text dosent work anymore

#

and TextElement dosent do anytthing either

heavy dome
#

if(Keyboard.current.wKey.isPressed) { movement.z += 1; }
This line of code makes VS underline Keyboard even though I have the new input system installed, because, it doesn't exist in the current context.

#

What's wrong with my script exactly?

frigid ridge
#

@heavy dome Likely missing an using statement. Right click -> Quick suggestions on the line and it will probably show you the right one

chrome walrus
gilded dirge
#

How can i get input from mouse?

chrome walrus
#

Old or new input system?

gilded dirge
#

New

chrome walrus
#

Mouse.current

heavy dome
#
InputManager.Controls.Player.Move.canceled += ctx => ResetMovement();```
InputManager being highlighted red because it is inaccessible due to protection level. What am I doing wrong?
frigid ridge
agile terrace
bold mauve
#

@heavy dome you dont reference InputManager directly if I remember well, it's internal

#

you should get a refrence of your InputAction something like that

#

and .Enable() it

#

or you Unity can code-gen a controls class for you based on what you set on the editor

#

errr... double-check the manual, it will be easier ^-^"

#

What the hell am I writing ? xD InputManager is a your Singleton to handle input probably ....

bleak ermine
#

What does input system mean

#

What kind of help does it provide

safe forge
#

you would want to create an input system for more precise customization and easier access to what inputs you want to do what in a game @bleak ermine, so a potential player can make jump whaever he wants and we dont have to type in input.getkeydown(Keycode.W) whenever we want our character to move forward.

safe forge
#

Actually i think this is applicable here. if what I am doing is considered crossposting please let me know, even though i am deleting my previous message.

#

So this is an issue i have been having all freaking day and im honestly incredibly done.This might be a wall of text.
The Situation: Currently, I have a working Main menu using buttons, EventSystem, and Event triggers. I navigate using A and D or Left and Right according to the default InputManager. The input module for EventSystem is the StandaloneInputModule. All inputs work, I can press submit, it works.

The Issue: Whenever I click on anything with Mouse button 1, It unselects everything and it is not able to reselect anything, even with a click. My current band-aide one the issue is that whenever the EventSystem property currentSelectedGameObject == null, I set the selected module to a random button. I do not want this to be my fix.

I do know it is specifically when i click on the screen anywhere.

What i have tried: I have tried Making a copy of StandaloneInputModule and trying to edit the script to rid myself of any mouse inputs, but it doesnt seem to like that, no matter what area I comment out. I am unfamiliar with inputmodules so it has been a really hard issue for me to fix.

Is there any way i could just rid mouse inputs from my input module in this scene? is there a method that i cant seem to find on the unity UI Scripting API? Is my idea of Making a new inputmodule that doesnt respond to mouse inputs the correct way to go about this?

pseudo raft
#

Hi everyone,
I'm trying to create a simple local multiplayer lobby :
Press a button to enter -> select character -> confirm

#

any idea of a good way to do that with PlayerInputManager ?

pseudo raft
#

Ok i fixed the issue by scripting my own lobby with its own input to join / choose a character / save the device used to join

#

I then set the "PlayerPrefab" variable from the PIM for the chosen character and use the JoinPlayer method to instantiate it + define the input device

stable plinth
#

I'm trying to make my player move every time I click the mouse so one click equals for example 1M anyone help little confused

tame oracle
#

can someone help me

#

i added sprinting into my "game"

#

but i wanna disable it when im moving backwards

#

here's my code

#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{

    public CharacterController controller;

    public float speed = 12f;
    public float gravity = -9.81f;
    public float jumpHeight = 3f;

    public Transform groundCheck;
    public float groundDistance = 0.4f;
    public LayerMask groundMask;

    Vector3 velocity;
    bool isGrounded;
    private object playerCol;

    // Update is called once per frame
    void Update()
    {
        isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);

        if (isGrounded && velocity.y < 0)
        {
            velocity.y = -2f;
        }

        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Vertical");

        Vector3 move = transform.right * x + transform.forward * z;

        controller.Move(move * speed * Time.deltaTime);

        if (Input.GetButtonDown("Jump") && isGrounded)
        {
            velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            controller.height = 3f;
        }

        if (Input.GetKeyUp(KeyCode.C))
        {
            controller.height = 3.8f;
        }

        if (Input.GetKeyDown(KeyCode.LeftShift))
        {
            speed = 20f;
        }

        if (Input.GetKeyUp(KeyCode.LeftShift))
        {
            speed = 12f;
        }

        velocity.y += gravity * Time.deltaTime;

        controller.Move(velocity * Time.deltaTime);
    }
}
#
if (Input.GetKeyDown(KeyCode.LeftShift))
        {
            speed = 20f;
        }

        if (Input.GetKeyUp(KeyCode.LeftShift))
        {
            speed = 12f;
        }
#

and here is where i put the sprinting

#

ik its bad im bad

#

how do i do it so it dosent sprint backwards

bold mauve
#

You can use the dot product to check if 2 vectors are in the same direction

#
if (Input.GetKeyDown(KeyCode.LeftShift) && Vector3.Dot(move, transform.forward) >= 0)
        {
            speed = 20f;
        }

Maybe start with something like this (not tested)

#

@tame oracle

tame oracle
#

?

#

k

#

thanks

bold mauve
#

the dot product equals 1 if vectors are in the same direction, 0 if perpendicular, -1 if opposite direction

#

should probably normalize the move vector, as you multiplied it with user input

#

Vector3.Dot(move.normalized, transform.forward)

lime temple
#

can someone help me this? I'm trying to make a 3rd person game where WASD/arrow keys moves the player relative to the camera

#

and it worked great until I added the ability for the camera to rotate around the player

#

I know I need to replace player_capsule.transform.forward with something to make the new motion relative to the camera and not the way the player is facing

#

but I'm not sure what it needs to be

jagged wyvern
#

camera.forward?

west oracle
#

Just wrote this example for @tame oracle 🙂

valid basin
#

my mouse isn't being detected by the input system. How do I fix?

#

this is my setup for the mouse

#

Look Action is a Action Type Value with COntrol Type Vector2

glacial thicket
#

are inputs for nintendo switch pro controller on pc broken in unity 2019.4.11f1? it's doing really weird inputs

glacial thicket
#

yeah they're completely wrong, despite my controller working fine on other games

west oracle
#

@glacial thicket oof.... i'll check this when i get home w/ my switch. was gonna have to deal with this sooner or later. were you Wired or Bluetooth?

glacial thicket
#

wired

winged orbit
#

I'm having an issue with DS4 controllers. I use Gamepad.current.startButton.wasPressedThisFrame to pause/unpause the game. That's the Options button on the DS4 controller. In the editor it works perfectly, but when I build it, it only works sporadically.

#

anyone else encounter this?

west oracle
#

@winged orbit are you sure you're checking in the right update loop?

winged orbit
#

It's in Update() . I check for escape key there too and that works fine.

west oracle
#

make sure InputSystem is set to Update

#

(it would be by default if you didnt change it)

winged orbit
#

I didn't change it.

west oracle
#

do you have more than one gamepad plugged in?

winged orbit
#

Yes

#

Is that an issue?

#

It's a local multiplayer game, so I want any of the players to be able to pause.

lime temple
#

so you can see right now that as the camera spins and I hold down W, the player runs forward constantly

#

but I want the player's "forward" to change when the camera angle changes

#

same with backwards, left, right, etc

#

so I guess what I need is still this line: player_capsule.transform.rotation = Quaternion.Euler(0f, angle, 0f);

#

but I need some way to add the camera's change in rotation to the calculation of my angle variable

west oracle
#

@lime temple did you look at my example?

lime temple
#

yeah I looked at it but it didn't look like there was any camera rotation in the example scene

west oracle
#

rotate it manually 😛

lime temple
#

and the script said camera.transform.forward

#

but if I do that, it'll always move towards camera forward

#

even if I'm pressing backwards

west oracle
#
        //get the forward facing direction of the camera
        Vector3 cameraForward = Camera.main.transform.forward;
        //zero out the Y axis   (this is the lazy way, not 100% accurate and wont work for extreme angles)
        cameraForward.y = 0;
        //generate a rotation to rotate your inputs around
        Quaternion cameraFlatRotation = Quaternion.LookRotation(cameraForward);

        //rotate yout input vector based on the camera's "Heading"
        input = cameraFlatRotation * input;```
#

code is nice n' commented

#

you are rotating your input by the camera's rotation

#

this gives you a world space vector to move a character in (ie: pressing "Up" on a joystick or W/Up key will always move the object away from the camera)

#

if your character isn't incorporating the input vector, then it wont do that

winged orbit
west oracle
#

@winged orbit yea, that was my next suggestion. TL;DR polling is a bad idea with the new InputSystem for arious reasons

#

diferent controllers function differently (some stream constant rate, others like XInput are event based)

#

if you use Actions instead of directly querying a controller, you'll have better results 😦

#

i submitted some significant design paradigms to Rene-Damm that they're slowly starting to look more like 😛

#

should make a lot of that more sane

lime temple
#

hey so i've got this camera rotation code

#

and the first five lines work great to rotate the camera round the player but keep it always looking at him cause it's a 3rd person game

#

the bottom three lines work great to allow mouse movement up and down to change the camera angle

#

but the two code blocks don't play nice at all. the bottom three lines are overriding the x-rotation somehow

#

I don't understand how this line is wrong:
transform.rotation = Quaternion.Euler(currentRotation.y, transform.rotation.x, 0);

#

but instead it does this

lime temple
#

@west oracle hey are you still around? I could really use help with this

west oracle
#

Dinner, I'll be on in a bit

lime temple
#

ty bb

west oracle
#

@lime temple here

#

transform.rotation.x this is a quaternion. you probably want eulerAngles

lime temple
#

i switched it to eulerAngles.x and now it's rotating around the player, but not looking at him anymore

west oracle
#

so whats ur goal?

#

you want a kinda Free Look camera for 3rd person?

lime temple
#

mouse moving up and down will angle the camera up and down

#

mouse moving left and right will rotate the camera around the player

#

but when I try to implement them together it messes it up

west oracle
#

so....to be honest, Cinemachine has pretty much got this down to an absolute science

#

so fi you really wanna re-invent it just to do it, thats cool, but Cinemachine really does a great job

lime temple
#

my experience with cinemachine is that if something breaks, I don't know how to fix it because I don't know how it works

west oracle
#

lol fair 🙂

#

lemme put together a simple gimbal thing for ya as an example...

lime temple
#

plus there's a lot of overhead that I really don't need, and I can't figure out which features I want and which ones I don't want

west oracle
#

lol yea i've been there.

#

you exclusively want to use InputSystem yea?

lime temple
#

as opposed to?

west oracle
#

Input.GetAxis("Horizontal") or InputSystem ?

#

(old versus new)

lime temple
#

oh i've been using getAxis

west oracle
#

oh ok

lime temple
#

but tbh I don't know the difference

west oracle
#

uh... a lot lol. if you hate cinemachine because you can't fix it, you'll hate InputSystem more 😛

lime temple
#

lol

west oracle
lime temple
#

let me try and integrate it with my other code

lime temple
west oracle
#

theres a Distance To Target variable

#

although Zoom = Field of View, not Position 😛

lime temple
#

yeah i tried changing that in the editor but it didn't seem to change anything

#

probably cause it gets set in start

west oracle
#

change it at runtime

#

or dont set it at start

#

up to you

keen phoenix
#

is it possible for anyone to lend me a tilt controlled arcade style car controller?

tame oracle
distant salmon
#

@tame oracle Did you get the reference to the player's body?

#

meaning, did you drag the body into the empty square in the inspector?

topaz moon
#

VS code doesn't have any errors with the code, the jump input doesn't work.

#

This is driving me nuts lol.

tame oracle
iron wing
#

Hello everybody.
I have a very basic code running in my Update function that sets the vector2 movementInput to the raw input of the right/left and up/down arrow keys.
The getting horizontal input works fine. But there is about a 1 second delay when setting the input to the vertical axis. Why is the vertical axis delaying?

austere grotto
#

you're using raw for the x

#

and not raw for the y

#

GetAxis applies some smoothing to the value

iron wing
#

@austere grotto Oops! Thanks for pointing that out!

#

It works now

heavy dome
#

Currently getting an error on the InputManager variable on lines 16 and 17 saying that it's inaccessible due to its protection level. (This is a repost from a few days ago, except now I am including my code)

Code: https://hatebin.com/ridzbqgsgb

uncut crater
#

Hey, can I somehow disable mouse in new input system? I want to use Keyboard and/or Gamepad but when I click with my mouse the PlayerInputManager (which is set to automaticaly spawn) spawns another player for that mouse

west oracle
#

the spawn behaviour for PlayerInputManager has a "Join Behaviour"

#

use the action or manual method to override the default behaiour

sly sigil
#

is it still important to multiply certain things by Time.deltaTime, or are the brackeys tutorials a bit outdated now?

austere grotto
#

and it's still "certain things" not all things

sly sigil
#

awesome - I was just curious

#

thanks for the quick answer 😀

stark sinew
#

is there a way to disable player input on the new input system

#

have smth like this right now:

    void PauseGame ()
    {
        //Time.timeScale = 0;
        controls.Disable();
    }```
ocean jacinth
#

time.timeScale = 0f; should be ok

stark sinew
#

that works but is there a way to just disable playerinput

#

doing controls.InputName.Disable() works for me
InputName is the name you gave to the ActionMap

valid basin
#

okay so now I now have another problem lol

uncut crater
#

hey, i want to create something like choosing character by moving focus to the Choose Character (input/button/focusable) and by pressing left or right my script will change characters (characters wont be focusable, focus will be on the Choose Character field). Is there a input like that or I have to write it on my own? I don't have a problem with it and I know how I would do that but I wouldn't like to create something on my own if there is a built in feature 😄

pine meadow
#

@uncut crater so you want to choose a character based of looking at them?

uncut crater
#

Nah, let me show you how I would create it in code and maybe you will tell me if there already is something like that.
Let's say I have a button called "< Choose Character >".
WASD/Arrow navigation.
Player moves focus to the button. My code recognizes player is focusing this button. Player performs left/right input. Script receives it and changes character accordingly.

pine meadow
#

So like you want to move based off of wasd or am I not reading it right

uncut crater
#

you change focus by up/down, and change value by left/right

pine meadow
#

Oh so ui? Ok I'm pretty sure by default you can make either yourself or in code that when you make ui next to each other unity links then and you can use arrow keys

west oracle
#

you want IMoveHandler most likely

uncut crater
#

oh, that's what I was probably looking for

#

sorry for describing it so poorly

west oracle
#

your description was good 🙂 i was just busy eating crackers 😛

pine meadow
#

@uncut crater blackthornprod has a series on it

slate jetty
#

Hello I'm trying to implement a touchMove detection event with the new unity input system. I made event for start touch and end touch but I can't figure out how to implement the move touch. If someone can help would be appreciated 🙂

Here's my code

using UnityEngine;
using UnityEngine.InputSystem;

[DefaultExecutionOrder(-1)]
public class InputManager : Singleton<InputManager>
{
    private TouchControls touchControls;

    private void Awake()
    {
        touchControls = new TouchControls();
    }

    private void OnEnable()
    {
        touchControls.Enable();
    }

    private void OnDisable()
    {
        touchControls.Disable();
    }

    private void Start()
    {
        touchControls.Touch.TouchPress.started += ctx => StartTouch(ctx);
        touchControls.Touch.TouchPress.canceled += ctx => EndTouch(ctx);
        // touchControls.Touch.TouchPosition += ctx => MoveTouch(ctx);
    }

    private void StartTouch(InputAction.CallbackContext context)
    {
        Debug.Log("Touch started " + touchControls.Touch.TouchPosition.ReadValue<Vector2>());
    }

    private void EndTouch(InputAction.CallbackContext context)
    {
        Debug.Log("Touch ended");
    }

    // Here I need help
    private void MoveTouch(InputAction.CallbackContext context)
    {
        Debug.Log("Touch moved");
    }

}

and a screenshot of my action map

chrome walrus
#

inputSystem.Interaction.Position.performed += ctx => touchPosition = ctx.ReadValue<Vector2>();

#

Just alter it to your input names, but this is what I am using

slate jetty
slate jetty
chrome walrus
slate jetty
#

Lock input to game view isn't working or I don't understand what it means then

chrome walrus
#

Maybe its locking the cursor to it, I dont know. But to be honest, I had issues with those settings. The simulate touch just made my events fireup twice because I was using touch as input but still got the mouse as another touch triggered too, weird bugs there 😄

civic anchor
#

is there an easy way to convert keycodes to strings? like the actual key, not the name?
(e.g. 0 instead of Alpha_0)?

chrome walrus
#

Where is the keycode coming from? Input.Key?

civic anchor
#

i have a bunch of keycodes and a ui where i want to show the key for each slot

#

so i store KeyCode[] for the slot keycodes

#

and want to show those keys in the ui

chrome walrus
#

so keyCode.ToString() is not working?

civic anchor
#

it is, but i don't want to show the player Alpha0, i want them to see 0. i just will write a little converter. if (keyCode == KeyCode.Alpha0) text = "0" and so on

chrome walrus
civic anchor
#

nah that would be too much overhead, some simple if functions are more effective, also there are other cases with Escape and such

chrome walrus
civic anchor
#

this will get probably even more complicated with keys of other languages

#

i'm comparing keycodes, not strings

chrome walrus
#

well yeah, you do you

slate jetty
#

How can I get the touchId using TouchControls actions ?

void relic
#

Hello! I have a specific problem that I was hoping to get some ideas on how to solve. I teach game development and my “Hello World” is an FPS using the FPS AIO Plugin. One of my students this spring is quadriplegic, and requires the virtual keyboard to type. However, when you hit play in Unity, the mouse focus goes straight to the game. In order to bring up the virtual keyboard, my student has to defocus their mouse, making the virtual keyboard useless in editor. My student has the use of three mouse buttons and they can move the mouse around the screen using their wheelchair joystick. Any ideas how I can get my student engaged in the course material and with Unity? I’m at a state school and accessibility is crucially important to my curriculum, so if I can’t get this solved through technology, I’ll have to do some very quick and deep thinking on how to alter my assignments to meet my students’ needs or write some sort of plugin. I also don’t really think it’s necessarily fair to limit them to curriculum based on a technology issue since this really just has to do with virtual keyboard interfacing with unity.

void relic
#

someone messaged me an answer to this question, I thought I'd leave an answer. Cursor.Lockstate was taking over the virtual keyboard. Remove or comment it out, and the V-keyboard will work.

small sequoia
#

Hi does anyone know how to make a melee and jump buttons with the new input system?

west oracle
#

@void relic you can use Win32 API's to refocus the mouse.

#

^ also Cursor.lockstate too 🙂 if you need more than that feel free and DM me too! Accessibility and teaching are both near and dear to my heart.

void relic
#

Thanks! I also like to design for accessibility, it just hadn't occurred to me what could effect the windows keyboard, so we're trouble shooting. The keys are worknig, but we're trying to get it in a good position so that the Mouse Look doesnt leave them staring at the ceiling or floor by the time their mouse reaches their V-Keyboard 🙂

west oracle
#

for sure 🙂 Also definitely take a look at the Tobii Eye Tracker for input stuff

forest minnow
#

How do i trigger an input while the right trigger on my controller is held down? (old input system)

west oracle
#
if(Input.GetAxis("WhateverYourRightTriggerAxisIs") > 0){
    if(Input.GetButtonDown("WhateverYourButtonIs")){
      //Do the thing
    }
}
forest minnow
#

thanks

stark orchid
#

Hi. Can someone help me with a problem that I'm having with the Player Input?

#

For some weird reason, the player input don't call my OnControlsChanged event :/

#

And my code (I've also tried putting the playerInput variable as a parameter and it has the same problem)

#

It only calls when I recompile the code and enter PlayMode, but anytime after that that I try to change controls, it doesn't

radiant temple
#

@stark orchid When do you want this function to fire?

stark orchid
#

Basically I want to make my character aim at my mouse/direction I'm pointing with the right stick on the gamepad. The simplest way I find to do this is to have different inputs for the mouse and the gamepad and switch the current one when I change the input device being used on

#

That's why I need to use OnControlsChanged (which is a default function callback from PlayerInput) to work, because since the default inputMode is InputMode.Mouse, the right stick don't work when this bug happens

#

I've tried putting both input devices on the same action, but it didn't work to me

radiant temple
#

Oh okay. So you would need to call this function after, for example, a mouse wiggle. I've not done that before, But I imagine it would look something like this:

#

You'd want to change from "SendMessages" to Invoke Unity Events.

#

And then you'd want to fire that function when that action happens.

stark orchid
radiant temple
#

ahuh. That looks alright.

#

You should be able to also do it with SendMessages, but, I don't know how.

stark orchid
radiant temple
#

Yeah, You should be able to do it that way. SendMessages, as I'm sure you've heard, is slower and sometimes don't fire correctly, but they are easier to use. imo.

slate jetty
#

Hello I'm having an issue using the touchId, when I first touch my screen touchId starts at 0 and then goes to 1 even before I release my mouse (Touch 0 start > Touch 0 move > Touch 1 move > Touch 1 end)
Other touches after the first touch work correctly (Touch x start > Touch x move > Touch x end)
Any idea why this is happening ? Is it because of touchScreen simulation ?

umbral sluice
umbral sluice
austere grotto
#

Are you using assembly definitions @umbral sluice ?

austere grotto
#

Ok so probably not then

#

unless you did it by accident

#

Do you have that error in Unity, or just in your IDE?

umbral sluice
#

unity

#

also one time that i was installing and re-installing the package

#

it appeared an error

umbral sluice
#

@austere grotto

#

actually

#

only in the ide||the ide is the script editor, right???||

umbral sluice
#

how do i get the axisraw with the new input system?

umbral sluice
west oracle
#

@umbral sluice input is generally Raw until you add a Processor to it w/ the new system.

#

there are some default deadzones applied in InputSystem preferences (edit -> project settings, etc)

#

you can setup Actions, or you can access devices directly ie:

Gamepad.current.LeftStick

#

etc

umbral sluice
#

@west oracle i didnt understand

west oracle
heavy dome
#

I'm making jumping in my 3D game with the new input system, and I'm wondering what binding or whatever it's called I need to add. Do I add a binding, a 1d axis composite, or a 2d vector composite?

umbral sluice
#

@west oracle in your videos, you explain how to make a character controller, not how to get the rawaxis

west oracle
#

its already "raw" unless you add a Processor

#

if you want the bytes coming back from the controller you can get that too

umbral sluice
#

i think u didnt understand

#

i already have a controller

#

but it uses the Input.GetAxisRaw function

#

and i need to use the new input system for some more advanced stuff

austere grotto
#

In the new input system you use InputActions and listen for their started/performed/cancelled events

#

or poll them with myInputAction.ReadValue<sometype>()

umbral sluice
#

like readvalue<horizontal/vertical>?

austere grotto
#

sometype would usually be float if it's a simple axis

#

no like ReadValue<float>()

umbral sluice
austere grotto
#

It's specified by which InputAction

#

you are calling ReadValue on

umbral sluice
#

wait

#

i think i have a simpler solution

austere grotto
#

or oftentimes you put both horizontal/vertical on the same InputAction

#

and do ReadValue<Vector2>()

umbral sluice
#

ill make 2 floats and if i press w/s the 1st float will be 1/-1 and a/d the 2nd one will be 1/-1

heavy dome
#

I'm making jumping in my 3D game with the new input system, and I'm wondering what binding or whatever it's called I need to add. Do I add a binding, a 1d axis composite, or a 2d vector composite?

austere grotto
#

For just a button?

#

Just use Action Type: Button on the Jump action

heavy dome
#

@austere grotto Thanks for the response, but what type of composite binding would that be? Binding, 1D axis, 2D vector, Button with one modifier, or Button with two modifiers? Sorry if this is a dumb question, but I'm new to the input system.

austere grotto
#

Just a regular binding @heavy dome

west tulip
#

how do i get the current input scheme through the generated c # class

west oracle
#

^ very good question. this is one of the reasons i've completely abandoned Generated C# Class checkbox.

#

along with not supportign PlayerInput component AT ALL

tall crag
#

Why my game pressing d while iam not pressing d?????

hollow flame
#

is this where i ask about UI ?

sly sigil
naive vector
#

is there a way to access the users clip board on webgl, ive seen some solutions that use an input field, but i would rather it just be able to be bound to a key
eg you press "c" and it copies the arbitrary string "hi" to your keyboard, or you can press "v" and it saves the users clipboard to a variable

after messing around i found i could use GUIUtility.systemCopyBuffer, which while it can save to a clipboard, this clipboard is only accessable from the game itself, and cant access the clipboard of the user

naive vector
#

i found some code on the internets that seemingly does what i need!

severe pasture
#

how do i set up an input button

rough wing
#

for some reason my jump input isnt working

#

here is my main movement and jump script here

austere grotto
#

GetKeyDown only returns true for the exact frame during which the button is pressed

#

FixedUpdate does not run every frame

#

It only runs according to the physics update timestep.

#

The normal way to deal with this is to capture the input in Update(), store it in a variable, and consume it in FixedUpdate

rough wing
#

ah I see

#

@austere grotto mind if I show you my current script?

austere grotto
#

isn't that what I just looked at?

#

well part of it anyway

rough wing
#

oh yeah

austere grotto
#

yep, that's a script

rough wing
#

so from what I have gathered getkeydown should be under standard void update

austere grotto
#

yes, it should be in the Update method

#

you should create another bool variable to record when the player presses the button

#

and in FixedUpdate, check that variable. If it's true, do the jump and set the variable to false

rough wing
#

public bool onKeyPress for example?

austere grotto
#

doesn't need to be public but sure

rough wing
#

can probably be private

austere grotto
#

probably - you would't want any other scripts messing around with it.

rough wing
#

I believe I should set it to false initially then register it as true on press

austere grotto
#

yeah that makes sesne

#

just make sure you set it false again when you do the jump in FixedUpdate, or you will keep jumping each frame.

#

You may also want to only set it to true if playerOnTheGround is also true at the time the player presses the button - basically the same condition you have now on line 37 in the hatebin

rough wing
#

player on ground is true at start

#

onkeypress is false on start because thats assuming you dont press anything right away

austere grotto
#

mhmm

austere grotto
#

That could be useful in case you have a level where the player starts in the air for example

#

¯_(ツ)_/¯

rough wing
#

so perhaps in private bool I could do onKeyPress= false if playerOnGround is true

rough wing
austere grotto
#

bug on line 44

#

Should be == instead of =

#

also you don't need line 46 (it doesn't do anything)

#

And you should move line 32 to inside the if statement on line 44

rough wing
#

okay I am gonna test now

#

jump still doesnt work

austere grotto
#

Do you mean for your jump vector to be on the Z axis instead of the Y axis?

#

jump = new Vector3(0.0f, 0.0f, 2.0f);

#

Usually "y" is up, but I don't want to assume anything about your game

#

Bigger problem: you're not setting onKeyPress to true inside the Update input check

rough wing
#

in this case z is up due to the orientation of the model

#

well it definitely works now but now I end up flying off into space

austere grotto
#

You're probably not setting onKeyPress back to false when you do the jump in FixedUpdate

#

something like that - something not being reset properly

rough wing
#

probably have to make an if onkeypress is false line or something

uncut crater
#

hey, do new input system (and to make it more precise - Multiplayer event system) have a problem with selecting buttons?
my button is selected by default (and all move events work perfectly) but it has a "Normal Color" instead of "Selected Color"
If I navigate down and back to it it is correctly selected (with proper color)

leaden summit
#

well it gets stuck there

#

Oh. My vpn was causing the problem....... HOW

uncut crater
#

Another thing, my controller has an access to corresponding player's PlayerInput. What's the easiest/clean way to register listener to this PlayerInput map events? playerInput.onActionTriggered listens to all events so I have to do ugly filtering. Can I somehow get my PlayerControls (InputAction) from it and register listeners with strong typed references?

chilly hazel
#

hi, how do i make one thing happen when a button is pressed, and make ANOTHER thing happen when it's released?

fading bane
#

Hey, you should use IPointerDownHandler and IPointerUpHandler

using UnityEngine.EventSystems;

public class Test : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
    public void OnPointerDown(PointerEventData eventData)
    {
        //Button is pressed...
    }

    public void OnPointerUp(PointerEventData eventData)
    {
        //Button is released...
    }
}
chilly hazel
#

thank you! how do i set these up in the input actions?

fading bane
#

You can use UnityEvent for when you press and release
https://docs.unity3d.com/ScriptReference/Events.UnityEvent.html

using UnityEngine.EventSystems;

public class Test : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
    [serializedField] UnityEvent onPointerDown;
    [serializedField] UnityEvent onPointerUp;

    public void OnPointerDown(PointerEventData eventData)
    {
        onPointerDown?.Invoke();
    }

    public void OnPointerUp(PointerEventData eventData)
    {
        onPointerUp?.Invoke();
    }
}

You can even override and only accept functions that has certain argument(s)
https://docs.unity3d.com/ScriptReference/Events.UnityEvent_1.html

#

I haven't really used Input Actions, so I can't really help you there unfortunately, but if you attach the above script to a UI element that should do the trick

chilly hazel
#

thank you

#

oh sorry, i didnt mean gui stuff... i meant a button on a gamepad

soft basin
#

I prefer to react to the started event

#

MyInput.Player.MainAction.started += event => Shoot()

#

And then the .cancelled for release

chilly hazel
#

thank you

#

where do i add this

#

also what does this mean

#

are they all called when i do OnA()?

soft basin
#

I don't know

#

But how do you use input system?

chilly hazel
#

i dont know. i dont really get unity all too much, im very new to it

full forge
#

in the new input system a press on the keyboard spawns 2 events, how do you filter so that only buttonDown is triggering an event?

#

like this, which doesn't work

austere grotto
#

Started, performed, abd cancelled

#

You just need to pick one to listen to and ignore the others

#

No need to add any interactions

#

Ig you want only buttonDown the equivalent in Input System is to just listen for the started event.

cold sail
#

how would i make a UI button do horizontal and vertical input like with the WASD and arrow keys?

full forge
#

so what combination of interactions do I add to get Down?

#

might need a custom interaction

#

god damn! this documentation is full of typos, nothing's working

robust harbor
#

Hi. Is it possible to handle phone vibration with Input System? Or still need a custom implementation?

uncut crater
#

I'm creating a local multiplayer. I have InputActionAsset called PlayerControls. My player object has PlayerInput component with my PlayerControls referenced. My other UI controller has reference to exact player's PlayerInput. Can I somehow extract PlayerControls from PlayerInput and add strongly typed listener to exact events? atm I can do playerInput.onActionTriggered += myListener; and then filter out context but it feels really bad

slate jetty
#

Is there any way to simulate more than 1 touch with the Simulated TouchScreen option ?

austere grotto
austere grotto
#

You can also try like what I just suggested to elenfantopia

#

Input System gives you a lot of options

uncut crater
#

@austere grotto solution with currentActionMap worked playerInput.currentActionMap[PlayerControls.Player.Cancel.name].performed += OnCancel; but it still forces me to create a new instance of PlayerControls to have an access to the Player (and Cancel and its name) field 😦

uncut crater
#

This seems to be an overkill 😅

        playerInput.currentActionMap[PlayerControls.Player.Cancel.name].performed += OnCancel;
        PlayerControls.Dispose();
violet briar
#

Can someone help me understand the new Input System? Using 2020.2.0f1 version and got basic movement with translate down on player game object in a new unity scene with rigidbodies, but I can't figure out how to setup basic camera controls with the new input system.

#

I'm using the default action map created from the player input component asset.

austere grotto
#

Create a Pan Action in your input asset

#

create binding(s) for it

#

then in your code listen to the Pan action - and pan your camera

#

likewise for roll and zoom

violet briar
#

I just want he basic move camera with right stick functionality.

austere grotto
#

Ok so you just need to hook up your code to listen to events on the Look action

#

how did you do it for the movement?

#

Just do something similar but with Look instead of move

violet briar
#

Is it put in code that is connected to the player or camera?

austere grotto
#

Up to you - I would most likely attach it to the camera since that's what the code is controlling

violet briar
#

Can't seem to invoke the OnLook event.

#

Sorry also got an object with onmove connected to it, trying to make own third person system using the new input system. Got the camera and player objects separate.

#

So I think i'm interpreting the new input system wrong as I have almost no experience with it.

#

I got the player input component on the player and a script to move that object on it, but on camera its just the script, would I need multiple player input components to get this work?

#

new inpout system on two onbjects ubity

violet briar
#

I was trying to avoid using cinemachine to not bloat load learn my brain the various new thing I never touched before. Cause I want to learn more about the component's functions.

austere grotto
#

Just make a public field and drag it in

full forge
#

has anyone succesfully made a custom interaction? mine keeps erroring that it's deregistered, each time i launch unity

sly sigil
#

hello, friends
are these all the appropriate inputs for a ship that can move, roll, etc?
are there any particular settings/options I should consider checking or configuring?

violet briar
#

For now I've given up and am using combo of the new input system and the Cinemachine camera system to make a basic third person camera+control system.

ocean wasp
steady sentinel
#

Hey all, question on the new input system. I have a card game asset I’m going to sell on the Unity Asset Store and need to have both mouse and touch input. Can’t use 3rd party input since I’m selling it, so I’m trying to figure out how to make this work. I could use the new Input System but wouldn’t that force the people that buy my asset to use the Input System whether they want to or not?

So I’m deciding between:

  1. Use the UI system which has built-in touch controls (but the UI system has a LOT of limitations and you couldn’t make a game like Hearthstone with it)
  2. Use the new Input System (but would possibly force whoever buys my asset to use the new Input System whether they want to or not)
  3. Is there an “old” version of combined mouse/touch input? I’m pretty sure it’s been deprectated, so if that’s the case then I’m stuck with options 1 or 2.
west oracle
#

future looking though, I recommend using the new InputSystem

#

there wouldn't be a problem using both with compiler directives, but its always ugly to do that kinda thing

steady sentinel
# west oracle there wouldn't be a problem using both with compiler directives, but its always ...

Thanks, I’ll check out that simulateMouseWithTouches as a possibility. But ideally I’d love to be able to use the new Unity Input System, only I’ve run into issues before with it not being 100% feature complete yet, still has some compatibility issues, and asset store users might not like that it’s forced on them.

Is the current state of the Input System pretty stable and feature complete? I tried it a few months back and it seemed close but still not quite there yet.

west oracle
#

its a little better. mobile dev with it is hot garbage though.

#

no Unity Remote support yet AFAIK

steady sentinel
#

Ugh

west oracle
#

the touch inputs WORK on all devices, but holyfuck is it obnoxious to not have Unity Remote

#

i got on ReneDamm's case about it a few months ago

steady sentinel
#

Haha ok good to know

#

What about compatibility with the old input. If I sell it on the asset store would it “force” users into the new Input System or could they use both the new and old Input at the same time?

In other words, will the old Input.GetKeyDown() still work if the new Input System package is installed?

west oracle
#

you can set the input mode to "Both"

#

instead of one or th eother

#

but Keyboard.current[KeyCode].wasPressedThisFrame works well too

#

so a single property with a compiler directive would keep you safe there

#

TL;DR if they're using new InputSystem at all you should default to using that

#

but if its not present, fallback

#
ENABLE_INPUT_SYSTEM
ENABLE_LEGACY_INPUT_MANAGER
#

specifically these two

steady sentinel
#

OK that seems promising. I’m cautious because I’ve been burnt so many time before by trying out one of Unity’s hyped up new and exciting features!! ...only to find out it isn’t fully functional so you and up losing countless hours, scrapping it and going back to the old way. Keeping my fingers crossed

west oracle
#

i did a big ol' series on InputSystem from coder perspective

steady sentinel
#

Awesome, this looks like some good content. I’ve saved it to dive into later today

#

Any major “gotchas” or hidden land mines or roadblocks I should be aware of before diving into the Input System?

west oracle
#

Unity Remote's the big one

#

as well as the "Generate C# Class" checkbox

#

InputSystem has 3 paradigms to use Actions and none of them play well with eachother

#

ie: Generate C# Class doesn't understand what PlayerInput is

#

so Local Multiplayer ( 4 controllers for ex) is not practical/possible with Generate C# Class

#

(if you need that, ping me :P)

#

and two, the default behaviour for anything Action related is "OnDown" only. You dont get OnUp unless you ask for it.

steady sentinel
#

Of the 3 paradigms, which would you recommend for a card game (drag/drop)

west oracle
#

Generate C# Class is fine if you only have 1 "User"

steady sentinel
#

OK, but I’m also planning to add in multiplayer. Would that still work?

west oracle
#

same device multiplayer on a touch screen would be fine

#

really only comes into play if you havev more than one physical input device

steady sentinel
#

It would be separate devices / screens. Kinda like Hearthstone

west oracle
#

ya - ur still good w/ Generate C# Class

steady sentinel
#

OK cool, I’m going to give it a whirl. Appreciate all the info amigo!

west oracle
#

👍

clever spear
#

I'm having an issue using the input manager to replace keybindings in my game.

#

Originally I had hardcoded the keys used for menus into the scripts that controlled them. I wanted to allow the player to switch the controls in an options menu, but to do that I need to switch the controls over to the input manager. Now my menus will scroll all the way to the top or bottom with each key press, instead of just moving up or down one space.

slate jetty
#

How can I get the Touch ID of every touch that happens on the screen without knowing in advance the number of fingers that will touch it, wi th the new Input Actions system ?

rustic oriole
#

I am trying to use the new Input System... and I can't seem to figure out when a button was released this frame. The phase is changing between InputActionPhase.Waiting and InputActionPhase.Started. What I want to know is the corresponding thing to the old Input.GetKeyUp polling behaviour....To be more specific I defined an Action with ActionType Button and I want to poll if the button corresponding to the Action was released this frame

soft basin
#

Maybe it's worth looking into if you should subscribe to the .canceled event

rustic oriole
#

@soft basin yeah i was trying to do it via polling though. My solution was to switch to the preview version of the input system (1.1 preview 2)

#

They added WasPressedThisFrame() and WasReleasedThisFrame() to the action.

ocean wasp
#

This joystick issue is driving me insane. I've yet to figure out what im doing incorrectly.

It's getting stuck in position and no longer updating or responding. (as seen in img1 below)

as far as I am aware all the gameObjects (The Canvas which my Joystick is on, and the Player which is reading that Joystick object) should be persisting through SceneManager.LoadSceneAsync(levelToLoad); i've used asynch and synch both and the issue is still apparent with both

i can reliably repro this by moving my player through a teleportation boxcollider2d (istrigger) and then the load new level script that's attached to it, is as follows

    {
        if(other.gameObject.name == "Player")
        {
           
            thePlayer.canMove = false;
            thePlayer.joystick.gameObject.SetActive(false); // attempted fix
          
            //SceneManager.LoadScene(levelToLoad);
            SceneManager.LoadSceneAsync(levelToLoad);
            thePlayer.canMove = true;
            thePlayer.joystick.gameObject.SetActive(true); // attempted fix
            thePlayer.startPoint = exitPoint;
        }
    }```

 so theoretically i should be  disabling the joystick  before the load happens and then reloading it.  but it seems this is not occurring  (Note: that was an attempted fix )
ocean wasp
#

Upon further inspection it seems all my canvas buttons / ui elements are going "unresponsive when i zone...! lol.

#

at least to input by the player

#

Turns out i needed to make sure my Event System Object was persisting as well..

uncut crater
#

Hey, I wanted to disable ui input and still receive "non-ui" events so I made playerInput.uiInputModule = null but it throw errors. Is there any workaround? Having a reference to dummy uiinputmodule and setting it when I don't want any ui set?

stable coral
#

idk if this has already been asked, but how do i make it so it recognises me holding my button down?

#

like it's def the "value" action type, but i cant figure it out how to do it for one key bind

austere grotto
stable coral
#

first option

austere grotto
#

Also, either way - you can do it with a Button action

stable coral
#

like GetButton

austere grotto
#

Usually you listen for the started event and the cancelled event

#

set a bool to true in started

#

set it to false in cancelled

#

use the bool in Update()

stable coral
#

ah, that actually makes sense

#

thanks a lot!

austere grotto
#

np

stable coral
#

or actually, i might need some more help with this. i'm not so well experienced with buttons using the new input system (only vector 2 composites)

#

like setting it up and whatnot

edit: i might be on to something, so nvm. thanks again doatea

Edit 2: it works perfectly

rancid fractal
#

Hi, I’m pretty new to unity and I want to implement FPS mobile controls, but I don’t know how, can someone help me?

uncut crater
#

how can I move InputPlayer.uiInputModule from one ui to another 😦

west oracle
#

@uncut crater that can actually be a bit tough 😦 especially if you're trying to use the Automatic Navigation stuff.

#

is the context "Local Multiplayer" ?

uncut crater
#

@west oracle I thought about something like small UIs that popup for a player. For example when he uses an inventory chest there would popup a small UI where he can choose an item. I thought this would be as easy as taking that player's PlayerInput and pointing it at that UI's uiModule

west oracle
#

I actually wrote a tutorial on this exact topic but I hated how quirky the MultiplayerEventSystem was I didn't publish it

uncut crater
#

yes it is.
I came up with this problem pretty early. I have a player setup scene where players can press a button and join a game (small panel shows up for them). It is working flawlessly. Players can hit ready and when all players are ready there is a countdown and players are spawned on second scene. First thing was I wanted to disable ui input when player hit Ready. Problem is I wanted this countdown to be interuptable(?) if player pressed Cancel input. So I couldn't just Disable input - I had to disable it only for character setup panel (current panel where player hit Ready) so I could still listen for Cancel input in code to Unready the player and give him back the access to ui.

west oracle
#

but basically the biggest issue is that these actions must be referenced/subscribed/initialized by the input module itself when you switch users

#

lol yep - it can be a bit tricky

uncut crater
#

so along with InputPlayer.uiInputModule = anotherUiModule I would have to somehow reinitialize inputs?

west oracle
#

yea, because its all subscription based

#

worse yet when you disable that UI it'll actually disable that whole asset

#

so you have to be sure you dont shoot yourself in the foot

#

(I'm not sure if they repaired that in 1.02)

#

this conversation is a good execuse for me to explore this again tho 😛

#

so mebbe later today

uncut crater
#

so if I encountered these problems so early on I guess it won't get easier later on if I want to introduce small UIs (like that chest one) 😄

tacit igloo
#

Hello, I'm having a pretty annoying problem..
I'm making a local versus game and on start, a Player Input Manager (component ) spawn one GO per players connected ( left screen. Gamepad + Keyboard and mouse ).
The players have multiple scripts who needs to be called at start in reference of the Player Input Handler script.
But if you look at the inspector, the index of the player and the Mover var are good unlike the skills Projectiles and Skills who are called by the other player.
So if P1 want to open fire, P2 open fire ( oc it's the invert on the second ---Player Input GO.
What could i do please ?

main pawn
#

Hi,

I recently switched my project over to the new Input system. I use the auto-generated C# script to reference it and to enable / disable my player inputs. This works well and i like the modularity of the system a lot.

However, in addition I control a freelook camera with a separate action from the same action map - for this I use the ready-to-use Cinemachine Input Provider and select my action as a reference.

However, if I disable the action map containing the camera controls action, it won't disable and I can still move the freelook camera.

Why does the action not disable with the rest of the the action map?

gilded dirge
#

Hi, i need to make a simple movement code, can anyone help?

tacit igloo
#

The introduction video to the 3rd Person controller series, in this video we discuss the features the series will implement!

► JOIN OUR DISCORD
https://discord.gg/jzmEVx5

► SUPPORT ME ON PATREON!
http://www.patreon.com/SebastianGraves

► FOLLOW ME IN INSTAGRAM!
https://www.instagram.com/tragicallycanadian/

► FOR FREELANCE INQUIRIES E-MA...

▶ Play video
gilded dirge
#

Thanks

gilded dirge
#

Do anyone have also a code to pick objects?

#

i mean right click and pick the object untill i stoph pushing righ click

tacit igloo
#

Just solved my problem OMG !!! UnityChanExcited
The problem was due to a search priority of each scripts on each players
So what i did : create List of each scripts of each players
Convert them into another new variables => Array[] ( the problem occured because of the array ( start at size = 0 and can't add my scripts ===> List.AddRange()
Then tell what the Player Input will control with the right index

tacit igloo
#

I think that the documentation of the new Input System should be more documented and may be show more situations

digital narwhal
#

PC stand-alone build, Input System, URP, and TMP_Input not working. In editor everything works just fine. But in build it doesn’t. No errors or nothing.

#

Looked online, no solution found. Suspect it might be because I put system is enabling touch support, which I don’t need, and the touch support is conflicting with the way input fields work?

digital narwhal
#

Also, is there a performance penalty for setting Active Input Handling to Both?

tame oracle
#

how can i check if a button pressed only for this frame with new input system

#

i want to make a value 1 only for 1 frame

uncut grail
#

huh

tame oracle
#

but it is action not key press

#

i mean something like old input systems getkeydown

#

when key is pressed value becomes 1 for 1 frame

#

and than becomes 0 until player releases button and presses it again

uncut grail
#

so when you press it it goes up and 1 frame later its back again?

tame oracle
#

yeah

#

same as input.getkeydown

uncut grail
#

hmm

#

wait

#

Input.GetButtonDown

#

maybe that

tame oracle
#

no i mean with new input system

#

i just started learning new input system 1 day ago

#

so i am not really good at it

#

for games controls to be portable

uncut grail
#

add more inputs

#

idk

latent lichen
#

@tame oracle search for a performed action

#

Is a delegate you can subscribe

austere grotto
light pier
#

Uh, for InputSystem users question, can you rate is it ready for commercial use or not yet?

digital narwhal
tame oracle
#

no it is something different

#

inputmanager spams making it true

#

as long as key is holded

#

so it will still spam jump

#

but it will work to stop jump

#

ill check praterblues and aburrons solutions

#

thanks for help tho

#

if they dont work ill try that

austere grotto
#

started event to start the hold

#

cancelled to stop

tame oracle
#

actually prolly i can make 2 bools

#

1 gets enabledd when value is 0

#

other one gets disabled when space key is pressed

#

well my brain died from that simple algorithm and i cant continue it now

#

damn

sharp juniper
#

Hey y'all. I'm testing out the new input system and it breaks at low timeScales. In particular it misses click events on our pause screen (as that's where we set the timeScale to .001). Is there a workaround for this?

#

I have the events set to process in FixedUpdate (which must be the source of the issue). So I guess I'll have to process input events manually so I can handle the case when the game is paused.

west oracle
#

@sharp juniper FixedUpdate respects TIme Scale.

#

When I "pause game" and am using InputSystem in FixedUpdate I switch it to Update or Manual

#

working as intended

#

(there is no problem changing the mode at runtime)

neon dawn
#

Hey all! I'm working on a co-op xbox game using the new input system. My game is a top down 'bullet hell' style game. My issue is when I try to aim the barrel of my gun, both players override the other. I cant figure out how to separate them out

#

here's the void I am using for rotations:

    {
        playerInput.Movement.MovementRightStick.performed += ctx =>
        {
            currentMovement = ctx.ReadValue<Vector2>();
            movementPressed = currentMovement.x != 0 || currentMovement.y != 0;
        };
       
        
       
        Vector3 currentPos = barrel.transform.position;

        Vector3 newPos = new Vector3(currentMovement.x, 0, currentMovement.y);

        Vector3 posToLookAt = currentPos + newPos;


        barrel.transform.LookAt(posToLookAt);
        
    }```
#

this matches the player input controller for send messages

unique quail
#

Does anyone know how to implement A Sprint Animation with the new Input system. I am pretty new found close to nothing on that one

austere grotto
#

Those are two different questions

#

Are you just asking "How can I detect when a button is pressed and when it is released?"

#

that's the input-related part

unique quail
#

Well...both lol

#
  • the player should Sprint for the duration the button "Shift" is being pressed
tame oracle
#

Does anyone have any best practices around UIs and using the PlayerInput/PlayerInputManager system?

#

i.e. is it better to create a single UI that all players use, or for each player to create their own unique UI for local MP

austere grotto
#

Depends on if you want them trampling on each other or not

#

You can give them their own UIs and their own Input Modules

#

Input Module is the piece that will map a particular UI/Event system to a particular PlayerInput

west oracle
#

@tame oracle (this was an example made for @uncut crater 's usecase the other day). Each "Crate/Chest has its own UI Canvas that players interact with, and MultiplayerEventSystem interacts with them

untold sun
#

Is there a tutorial or example or something for using the new input system with the new UI package? I'm new to both, and while I can get input events to my own class, and I HAD the UI system generating events (EG: Button was pressed) with the old input system... I don't get any such events since installing the new input. I'm sure I've just configured something incorrectly, but I'm not finding a lot of documentation on combining the two.

austere grotto
#

in the old input system there was the StandaloneInputModule

#

In the new one you need an InputSystemInputModule or whatever it's called

untold sun
#

Yeah, I have an "Input System UI Input Module" component which seems like it's meant to do this, but it's as if it receives none of the events. Nothing I've done gets any reaction from it. But if I use the PLayer Input thing and send test events to methods of my own they do fire. So I know the input system seems to be working itself.

#

Do I need to directly link the relevant events from the Player Input component to the Input System UI Input Module (what a mouthful) component in its "Events" config?

austere grotto
#

this is what mine looks like

#

you need to populate all those fields with events from the input system for it to work

#

(those were all there by default for me)

#

Those actions are all from the Actions Asset which is specified there - the DefaultInputActions asset

#

if you use your own asset you will need to create events to put in all those places

untold sun
#

Yeah, they started that way, I tried making my own Input Actions thing though, and the option to go back and see what the "Default" looks like is gone, because "DefaultInputActions" isn't there now

austere grotto
#

Well there's a screenshot for you

#

al;so the Default one can be found in Packages/Input System/InputSystem/Plugins/PlayerInput

untold sun
#

Ok, thanks, I'll play with it some more

austere grotto
#

If you open that asset you can see how they defined all those actions that they're using in the input module

untold sun
#

Conceptually, I assume "Left click" corresponds to "Pushed button"? I sort of expected the names of the fields to be more "Here's what happens" than "What was pressed"

austere grotto
#

Honestly I'm not sure

untold sun
#

Like, for a mouse you move the mouse to point at a button, then click on it (probably left mouse, but even this isn't a GIVEN for say, lefties). To do the same with a controller (assuming it's not also driving a cursor) you'd highlight the button and press like, "A"

austere grotto
#

Yeah it's named poorly I think

untold sun
#

So I EXPECTED the UI system to have events like "Activate Element" that are more generic. Since that seems to be the philosophy that the Input system is going for by defining actions with different underlying activation methods

austere grotto
untold sun
#

nod Helps to hear that's the case and not that I'm just missing something 🙂

austere grotto
#

It's possible I'm just also missing something though 😄

untold sun
#

haha, will keep it in mind 🙂

#

Hrm. Dragging the default one to copy it elsewhere seems to have been a Bad Idea(TM) as it's been pinwheeling for several minutes straight now.

austere grotto
#

uh oh lol

#

unity doesn't really like it if you modify anything from the Packages directory

#

as all of that stuff actually lives in the package cache and not in the project itself

#

it's all temporary files

untold sun
#

Right, that's why I (intended?) to copy it before mucking with it

austere grotto
#

indeed

#

dragging moves it though, not copies, right?

untold sun
#

It had a big green plus sign icon so I don't THINK I moved it 🙂

austere grotto
#

ah ok you duped it then tried to move?

untold sun
#

It moves by default from my own assets, but appears to copy by default from packages

austere grotto
#

ok

untold sun
#

No, I just duped it and it went to la-la land

#

And finally recovered with no messages. So uh... OK?

#

It really did make a copy too. Renaming the copy does the same extended pinwheeling.

austere grotto
#

That's odd. I'm scared to try it now 🙂

untold sun
#

Moving it seems fine though. shrug

#

Ok, I'm going to try to get basics working with the defaults, which really seem to cover all the events right now anyway. I shoulda just done this in the first place lol

austere grotto
#

¯_(ツ)_/¯

#

I feel like I actually learned a little about Input System trying to answer your questions here

untold sun
#

WEll that's good 🙂

austere grotto
#

like I didn't realize Unity had their own little default Input Actions asset that is used by the input module

#

I wasn't really sure where those actions came from before

untold sun
#

That IS why I usually attempt to start from scratch with new stuff, at least, if I think I understood the docs. I usually end up learning exactly what I didn't REALLY understand

#

And, nothing works with the defaults either.

austere grotto
#

:/

#

Do you ahve an EventSystem?

untold sun
#

There must be some linkage step between the UI stuff and the Input system I'm missing

#

Yes

austere grotto
#

I was pretty sure the input module was that linkage

untold sun
#

Yeah, but like, the Input Module doesn't have an output? Like, WHAT UI Element is it routing things to?

#

Maaybe I've ended up with a weird way of creating the UI in the first place. Since I have no experience with either of these things 🙂

#

I;ve got a UIDocument component here, but nothing seems to tie the Input stuff to that.

austere grotto
#

Ok so

#

confessing my ignorance

#

I've never used UIElements

#

only UGUI

#

and I know Input Module works for UGUI stuff

#

I have no idea how UIElements works

untold sun
#

Me either 🙂