#🖱️┃input-system

1 messages · Page 8 of 1

woeful hamlet
#

ty AurimasK

sudden lagoon
#

👍

woeful hamlet
#

Oh and one last question @sudden lagoon how can I detect if key is selected

sudden lagoon
#

something like this maybe? GameObject selected = EventSystem.current.currentSelectedGameObject;

#

you might want to check ISelectHandler and use something like

public class ExampleClass : MonoBehaviour, ISelectHandler

 {
 public void OnSelect(BaseEventData eventData)
     {}
}
woeful hamlet
#

thanks, if not ill ask the always wrong chat gbt ai

sudden lagoon
#

chatgbt will know, it is amaizing for these kind of things, I use it constatly also 😄

#

I think he will give even better example than I can :"D like 100% sure of it 😄

woeful hamlet
#

honesty its so helpful for learning

#

and if its wrong

#

then we have this awesome community

#

chat gbt likes to use OnPointerDown

sudden lagoon
#

On pointer down is quite nice, as it works for touch and mouse. And also solves quite a lot of problems on webgl.

woeful hamlet
#

hmmm

quiet tusk
#

Too be honest, I haven't looked into the new input system much, but is there a way to map Touch.Phase events to webgl click/drag events so that I can do my intended mobile builds and webgl? I just want to know if its possible before I head down that path. Thanks.

austere grotto
#

when you say "WebGL click/drag events" what are you talking about?
Are you talking about Unity's UGUI OnDrag OnPointerClick OnPointerDown etc? If so, yes you can use the new input system with that stuff, and with touch.

quiet tusk
#

But yes, the built in OnMouse(events)

austere grotto
#

OnMouse events dont work with the new system. You should use the more robust UGUI events

quiet tusk
#

so you are saying void OnPointerDown(PointerEventData eventData) detects both mobile touch and webgl mouse touches ?

quiet tusk
austere grotto
quiet tusk
#

You know how you can map multiple console controllers to the new input system using mapping ?

#

can the same thing be done for mobile touch and webgl pointer events

austere grotto
#

in what way? Like each finger being a separate player or something?

quiet tusk
# austere grotto in what way? Like each finger being a separate player or something?

What I want to accomplish:
Develop a game that builds to mobile devices (Currently using Input.GetTouch(0) / Phases)
Build down the same game in WebGL where the player can use the mouse for click/drag/hold events.
Expected Outcome: (using new input system)
I want to use universal logic that supports both, without writing custom logic for each event.

#

I don't need to support multiple touch events

somber shoal
#

So

#

i want to select Right Stick (gamepad)

#

and it wont let me

#

anyone know why

glass yacht
#

Not sure as to the terms (I don't have Unity open) but I think your control is set to a single value whereas you need a Vector2 to work with the Right Stick

somber shoal
#

Ok ty i will check that out once the new unity installs

#

worked

somber shoal
#

i think my issue might be input system related for my player action map

#

my playercontrols script aint working

#

i cant move

austere grotto
#

probably missing something simple

#

like an Enable() call

topaz jasper
#

hi, how would you manage multiple gamepads and UI, with old input system? where each gamepad can only interact with certain ui elements. (for context, I'm trying to make a character selection/editor screen)

tropic solar
#

yoo im having some trouble with the input actions
so the joystick works fine but the wasd inputs are only down for like .1 seconds

#

im not sure if this will interfere

austere grotto
tropic solar
upper lance
#

How to map inputs to images to show what button it is?

tropic tulip
#

anyone who uses new input system who could help me with some joystick movement

#

the problem is

#

that when i drag my joystick i have to keep dragging it i want it to keep moving as long as i have dragged it from its rest position

#

and i want to add a keep moving function for that

#

can anyone help me out please

maiden grove
#

Hi,

I'm having an issue with the New Input System (1.4.4) with Unity 2022.2.1. I have two objects with a PlayerInput component: Game Engine, and a Player. Both work fine in editor, but the one in the Game Engine doesn't work in build. The Player is spawned later which I would guess has something to do with why it works... Race condition?

tame oracle
#

Your code prolly has a value thats overwritting the Editors Value during runtime @maiden grove

tame oracle
#

Idk i would have to see the code lol

devout basalt
#

hi I was trying to create an input system with the help of the built in Unity input system. However it is not working for some reason and I am not sure why

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

namespace SG 
{ 
    public class InputHandler : MonoBehaviour
    {
        public float horizontal;
        public float vertical;
        public float moveAmount;
        public float mouseX;
        public float mouseY;

        PlayerControls inputActions;

        public Vector2 movementInput;
        Vector2 cameraInput;

        public void OnEnable()
        {
            if (inputActions == null)
            {
                inputActions = new PlayerControls();
                inputActions.PlayerMovement.Movement.performed += inputActions => movementInput = inputActions.ReadValue<Vector2>();
                inputActions.PlayerMovement.Camera.performed += i => cameraInput = i.ReadValue<Vector2>();
            }

            inputActions.Enable();

        }

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

        public void TickInput(float delta)
        {
            MoveInput(delta);
        }

        private void MoveInput(float delta)
        {
            horizontal = movementInput.x;
            vertical = movementInput.y;
            moveAmount = Mathf.Clamp01(Mathf.Abs(horizontal) + Mathf.Abs(vertical));
            mouseX = cameraInput.x;
            mouseY = cameraInput.y;
        }
    }
}
#

here is my code

#

I am assuming the first half of the code is working as the "movementInput" is giving me values however there is no change of values in both horizontal and vertical

#

horizontal and vertical are simply extracting the x and y coordinates from "movementInput" without including anything complicated and so I am really confused why it is not working

vocal jay
#

Also I would remove the closures in this code, as they make this a lot harder to read

#

(Basically replacing your lambdas with proper methods)

devout basalt
#

But is it the reason why it is not working?

devout basalt
vocal jay
#

If your MoveInput method is never being called it's not going to do anything

devout basalt
#

Thanks so much for the help. I will take a look and see what I can do tmr. It's like 4.40 am in my country and I am going to bed🤭

#

But really appreciated for the help🙏

vocal jay
#

All good 👍
Since you asked earlier, I'll rewrite it to remove the closures, you can look at it tomorrow if you like.

devout basalt
#

Sure. Thanks for the extra effort🙏

vocal jay
# devout basalt Sorry I am new to unity and coding so I do not quite understand what are you ref...
        public void OnEnable()
        {
            if (inputActions == null)
            {
                inputActions = new PlayerControls();
                inputActions.PlayerMovement.Movement.performed += MovementPerformed;
                inputActions.PlayerMovement.Camera.performed += CameraPerformed;
            }
            inputActions.Enable();
        }

        private void MovementPerformed(InputAction.CallbackContext context)
        {
            movementInput = context.ReadValue<Vector2>();
        }

        private void CameraPerformed(InputAction.CallbackContext context)
        {
            cameraInput = context.ReadValue<Vector2>();
        }

This is what I meant

#

It just makes it easier to see what is going on without the variable capture

tropic solar
#
public void HandleCameraRotation(float mouseX, float mouseY)
        {
            lookAngle += (mouseX * lookSpeed);
            pivotAngle -= (mouseY * pivotSpeed);
            pivotAngle = Mathf.Clamp(pivotAngle, minPivot, maxPivot);

            Vector3 rotation = Vector3.zero;
            rotation.y = lookAngle;
            Quaternion targetRotation = Quaternion.Euler(rotation);
            myTransform.rotation = targetRotation;

            rotation = Vector3.zero;
            rotation.x = pivotAngle;

            targetRotation = Quaternion.Euler(rotation);
            camPivotTransform.localRotation = targetRotation;
        }

can sum1 tell me why my camera is kind of glitchy? when i run HandleCameraRotation in void update its smooth but the player goes all blurry, in fixed update its a bit jittery, and in LateUpdate it's also blurry

subtle grove
#

my controls file was accidentally made into a visual studios file instead of an action input file, how do i change it back??

subtle grove
#

anyone plz im so lost : ((

tropic solar
#

make a new control file?

arctic elk
#

Hello, I have this function that gets called when I press the left mouse button. this is Character class and I have two more classes, GunSlinger and Warrior. When I inherit from Character on GunSlinger it works fine. But when I inherit from warrior. I don't even get the print. What is wrong with this new input system?

#

@here

arctic elk
austere grotto
#

show full scripts for warrior and character

arctic elk
#

ok, this photo is in the base class "Character"

#

the one above

#

this is the one on warrior

austere grotto
#

this doesn't show how OnPrimaryAttack is called

#

show full scripts please

#

!code

sonic sageBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

tired notch
#

how can i make sure that two buttons/keys need to be pressed to trigger a certain action

arctic elk
#

Ok I'll use those

#

Can I tag you when I want to send them ?

austere grotto
tired notch
arctic elk
austere grotto
#

modifier is the second key

arctic elk
austere grotto
#

you are only conditionally calling the base method

arctic elk
#

I tried putting it above and that also doesn't work

austere grotto
#

you are not calling base.OnEnable

#

so it never runs

#

and the subscriptions never happen

arctic elk
#

I also don't do that on gunslinger tho

austere grotto
#

gunslinger is fine because it doesn't define OnEnable of its own

#

only warrior does

arctic elk
#

ok ima try that

austere grotto
#

and anything else you "override" in subclasses

arctic elk
#

I'll let you know

austere grotto
#

(you'll need to mark them virtual)

#

I'm 100% confident this is your main issue

#

I've seen this problem many times before

tired notch
# austere grotto modifier is the second key

okay so i found the modifier plus binding but it seems i can only have a singular binding for either the modifier or the key. i want to try setup a sprint so i can have the left shift as the binding but i need wasd as the modifier in a 2d vector? is this possible?

austere grotto
#

a move action and a sprint action

arctic elk
#

@austere grotto THANK YOU SO MUCH

#

It works lez gooo

#

I get it now

#

I didn't know it automatically overrides other functions

austere grotto
#

then just move using moveInput and speed

tired notch
#

sorry im a pretty amateur coder

austere grotto
#

just a short way of writing that

tired notch
#

okay great so i just use the sprint key to change the speed of the walk

austere grotto
#

yep

tired notch
#

is that still possible to do if i want my sprint key to also be my roll key. im trying to copy the dark souls movement scheme for my controller if this is any help in understanding

austere grotto
#

doesn't really change much here

tepid swift
#

i want to crate a joystick with on 8 axis movement also i want to normalize the value i tried the process and using .normalized but it does not work idk what's wrong

tired notch
# austere grotto sure why not

to do that would i have to use interactions, like if it is tap then roll but if held then sprint? would that work with one action being held and one action being tap?

#

also may seem really stupid at this point but how can i reference like sprintAction.IsPressed() in my script?

austere grotto
austere grotto
#

either using public InputActionReference sprintAction; and dragging/dropping. Or doing like InputAction sprintAction = myPlayerInput.actions["Player/Sprint"] or if using the generation actions class myInputObject.Player.Sprint;

#

or directly defining it public InputAction sprintAction; etc..

#

there's many way sit all depends on how you set things up

tired notch
#

is there a way i can some how import my input system and then do like inputSystem.sprintAction so i dont need to define all my actions or is that not possible?

austere grotto
tired notch
austere grotto
#

it'd be:
myInputObject.MapName.ActionName

tired notch
# austere grotto it'd be: `myInputObject.MapName.ActionName`
    {
        if (controlInput.Gameplay.Sprint.IsPressed())
        {

        }
    }

okay so when i press left shift, the if() will be true right? sorry this may seem really basic but ive been trying this for days and i understood nothing and today i think i might be getting it

austere grotto
#

also just make sure controlInput.Enable() is called in OnEnable or Start or something

tired notch
#

would it be fine in Awake()?

austere grotto
#

sure, but kinda better if you Enable() and Disable() it in OnEnable/OnDisable

tired notch
#

why is it better to do that?

austere grotto
#

in case you disable your script it will stop it from capturing input (wasting resources)

tired notch
#

ah alright that makes sense, thank you

#

ive also been using float horizontal = Input.GetAxisRaw("Horizontal") float vertical = Input.GetAxisRaw("Vertical"); to get my input but now im using a pass through action and a 2d vector, can i some how just easily store the data froom the 2d vector in the horizontal and vertical floats?

austere grotto
tired notch
#

ive been trying literally for a week now and i havent got it working

#

thank you so much

stoic bolt
#

Somebody save my sanity, there must be a better way!
keys 1-9 will be able to select menu items from my menu system. In the base menu class, I'm setting up the callbacks:

#

is there a way I can pass a value through with this binding, so that I only need one method; SelectOption, instead of 9 methods...

#

because I'm about to copy out 9 identical wrapper methods that just pass an int to SelectOption

#

:V

austere grotto
stoic bolt
#

I really need to wrap my head around all the ways you can use deltas, don't I? 😄

austere grotto
#

lambdas*

#

and yes 😂

#

you were in the right alphabet at least.

stoic bolt
#

pfft haha, just goes to show

#

this is probably the 5th or 6th time this project that my problem has been not understanding proper lambda use

#

(thanks!)

#

ookay next problem. doing this requires SelectOption() to take a callback context parameter

#

but I'm not sure how to get that

#

I think that's the problem: Argument type 'lambda expression' is not assignable to parameter type 'System.Action<UnityEngine.InputSystem.InputAction.CallbackContext>'

austere grotto
#

or even just:
+= _ => SelectOption(n); since you're ignoring it you can use a discard

stoic bolt
#

more lambda magic! The discard worked, and that's all I need

jagged wyvern
#

I thought assigning it that way was wrong because it causes memory leaks or something

#

All the tuts i see say you need to be able to remove a listener to prevent mem leaks and you cant remove an anonymous method when you use lambdas

austere grotto
#

THis may or may not be a problem in this person's specific case

#

It won't be a memory leak though

jagged wyvern
#

Ah ok

#

I wish i knew what was going on in the back end but whenever i try to learn about this stuff in technical documents from ms it just goes over my head

#

Also for the method that just reads a numbers key in onr of my projectsi just made an action with bindings tied to all number keys and the method extracts which key was pressed

#

So i only need to assign on method to one actio

#

Ill post the code when im at my pc

tired notch
#

so im trying to assign sprint and roll to the same button (button east) and have put tap interaction on the roll and set the max duration to 0.2 (default). i have put the held interaction on the sprint and set hold time to 0.4. im under the assumption that if i let go of the button in under 0.2 (units im not sure what units) then the roll will play but if i hold it for more than 0.4, the sprint should activate

#

am i right in this assumption?

austere grotto
#

and yes as long as you are looking for the action's performed event

vapid yarrow
#

ProcessEventsInDynamicUpdate vs ProcessEventsInFixedUpdate
What is the pros and cons ?

chrome walrus
ornate gust
#

Hi there, I'm trying to get a pinch gesture to work on touch. I'm using this custom composite: (https://forum.unity.com/threads/implementing-pinching.1369809/) trying to make a uniform input action for zooming.
The issue I am having is that the phases of touch #0 and touch #1 always return 'none' (in fact, each touch has all fields at 0/none although other touch reliant behaviours work). I do also enable enhanced touch in an awake function and am quite certain I have the inputs wired up correctly, since my Debug.Log calls do fire at the appropriate locations to make sure code executes that far. If anyone wants to help, I'm happy to post github gists of the relevant code, just wondering if there are any commonly known errors or esoteric knowledge about the numbered touch inputs in the input-system. Any help would be greatly appreciated as I can't seem to find anything in the forums or on stackoverflow either.

limber sky
#

Hi everyone, I was wondering if anyone knew how to access the Home button either through the PicoSDK or through the new Input System, I've seen online that there are ways to disable the home button, but not ways to actually run code on it being pressed.

The official docs don't say much in terms of how to access it
https://developer-global.pico-interactive.com/document/unity/input-mapping

And the Input System doesn't have anything for the home button.

chrome walrus
limber sky
#

I considered this, but I'm not sure how to get the Pico working with the PC in the editor. I've seen that you can do this through steam VR but thought that might be an issue since its not the correct input system

limber sky
#

Hmm, I was assuming it would be a controller key, but looking at it in terms of the keycode it may work with KeyCode.Home, I'll look into this, sorry

#

Thanks btw

grizzled fractal
limber sky
#

Thanks, I ended up finding a work around actually. I realised that what I wanted did the exact same thing as using OnApplicationFocus(...) when this returned false. Since the Home button takes focus from the game and onto the main menu, this would run first and then go to the menu. ^-^

I think in the future I would want to see if I can access the Home button input action properly but for now this works well xD

#

Thank you though

grizzled fractal
#

It might not be possible to get it after all, since it's a system button that shouldn't be possible to override

#

Sounds like a good enough workaround

limber sky
#

Yeah, I did try using the Home refernce from the keyboard at first since that was the only one that seemed to share the same KeyCode, but didn't seem to work. Though this makes sense since this may refer only to the keyboard one.

tepid swift
#

i want player to move diagonally on button press - e.g get vector2(1,1) or something like that

#

or are there any composite part for movement like (north-east) instead of just up down left right

austere grotto
#
Vector2 northEast = new Vector2(1, 1).normalized;```
tepid swift
austere grotto
#

just define it somewhere it and use it wherever you need it

#

e.g.

static readonly Vector2 northEast = new Vector2(1, 1).normalized;

void MyButtonHandler() {
  Vector2 direction = northEast;
}```
tepid swift
#

hmm i think there is a miscom

#

wait

#

what i want - press q to move composite part or get vector 2(1,1)

austere grotto
tepid swift
#

so i was wondering if i should write one custom vector2composite

austere grotto
#

just read the data

#
Vector2 input = myInputAction.ReadValue<Vector2>();```
#

or

Vector2 input = myCallbackContext.ReadValue<Vector2>();```
tepid swift
#

the vector(1,1) / diagonal movement is only possible when you press 2 button at the same time like press w and d you would move north-west

#

i want to click just one button to get north-west

#

the composite part [Up] would only give me 0,1 value

austere grotto
#

can you elaborate

#

how would that work

#

are you trying to basically "rotate" the whole composite?

#

So that up would go up-right and left would go up-left?
and down would go down-left, and right down-right?

tepid swift
#

so when i press wasd i move up, down, right and left

austere grotto
#
Vector2 input = myAction.ReadValue<Vector2>();
input = Quaternion.Euler(0, 0, 45) * input;```
#

^rotates it by 45 degrees clockwise

tepid swift
#

the how would i move up and down?

#

basically wasd for up, down, right and left
qezc for up-left, up-right and so on

austere grotto
tepid swift
austere grotto
tepid swift
#

for touch button

austere grotto
#

add them together

austere grotto
tepid swift
austere grotto
#

Make two actions

#

Move and MoveDiagonal

tepid swift
austere grotto
# tepid swift following

Then you can just do this:

void Update() {
    Vector2 normalInput = moveAction.ReadValue<Vector2>();
    Vector2 diagonalInput = diagonalAction.ReadValue<Vector2>();
    diagonalInput = Quaternion.Euler(0, 0, 45) * input;
    Vector2 finalInput = (normalInput + diagonalInput).normalized;
}```
tame quest
#

How do I reference XR inputs in different scripts e.g trigger button or like the select .

tired notch
austere grotto
#

either subscribing to the performed event or checking if the current phase of the action or callback context is Performed

tired notch
austere grotto
#

the callback context is just the parameter to that delegate

#

I'm not telling you to switch to that if you're not doing it already. That's just one option.

tired notch
#

so far i havent got anywhere with it so im open to any ideas. is there a way i can implement my sprint (holding the button east down) easily into this code just by changing the if. before my sprint used to be a seperate button so isPressed() worked

                    currentMoveSpeed = sprintSpeed;
                    anim.SetInteger("condition", 2);
                    Debug.Log("is sprint / anim2");
                }
austere grotto
#

if you want to just know if the button is currently pressed, that works fine

#
if (controlInput.Gameplay.Sprint.WasPerformedThisFrame()) {
  isSprinting = true;
}
if (controlInput.Gameplay.Sprint.WasReleaseThisFrame()) {
  isSprinting = false;
}``` for example
#

depending on how you want it to behave

tired notch
#

ah alright im getting that now

#

and for tap can i do WasPressedThisFrame() which returns as True only the first time i press the button right?

austere grotto
#

if you want to actually use the Tap interaction you'd do the same thing as here (just with an action configured to use the Tap interaction). Tap will be performed if you press and release within a certain window of time.

#

WasPerformedThisFrame()

#

you can also go event-based 😉

tired notch
austere grotto
#

I wouldn't say that

#

It's different

#

I think you should use whatever you're most comfortable with

tired notch
#

alright i think im gonna stick with this then, seems easier to me

#

im not gonna run into problems later on where by not using the event system ive made something much harder for myself will i?

austere grotto
#

¯_(ツ)_/¯

tired notch
#
            if (controlInput.Gameplay.Roll.WasPerformedThisFrame())
            {
                PlayerRollStart();
            }

am i doing this right, i still can't seem to roll/sprint with the same button and i think this is the issue as i roll before i sprint even if im holding

austere grotto
tired notch
#

the code by the way is the same i just moved the roll to below the movement

austere grotto
tired notch
#

but good news is it all works now, i just need to adjust timing so its more snappy

#

thank you very much though, youre single handly saving my input

azure hearth
#

I'm having two problems with the new input system

#

when first starting unity, it picks up a seemingly non-existent controller

#

but I can remove it from the input debugger

#

the second is when reloading scripts, it stops getting any kind of input

austere grotto
azure hearth
#

yeah

austere grotto
#

that basically never works

#

for anything

#

not just input system

azure hearth
#

no fixes exist?

austere grotto
#

the fix is use only scripts where every single bit of state is serialized

#

it's not practical

#

when you change code, just go out of play mode

azure hearth
#

its kinda frustrating when I'm debugging a specific piece of code and I have to restart the game every time

#

well what about the first thing?

austere grotto
#

no idea

#

double check there's no stray controllers plugged into your computer

#

or on bluetooth

azure hearth
#

no bluetooth, and I only have the keyboard and mouse plugged in

#

completely sure of that

pseudo jolt
#

Hello, how can I separate game input from UI input ? For example, when I click on a button, my script from a totally different game object also recognizes the click

austere grotto
#

For example while the pause menu is showing you could disable the main game action map and enable the UI one

pseudo jolt
#

That would work, but in my case the player can interact with the UI at any moment :/

austere grotto
#

You can probably fix whatever it is by migrating that other code to use the event system too, rather than handling the input yourself

pseudo jolt
#

moves the player at cursor coordinates

austere grotto
#

yeah - that can be fixed by doing that with the event system

#

e.g. IPointerClickHandler / EventTrigger on some object in the game world (like the terrain or ground or whatever)

pseudo jolt
#

Okay I'll check that, thanks

#

This works ! Do you know if the same kind of interface exists with other inputs ?

austere grotto
#

could you give an example of another input you mean?

pseudo jolt
#

keyboard

austere grotto
#

but in what context?

#

The keyboard generally is not associated with a pointer position for example

pseudo jolt
#

same as for the click, changing weapons with some keys, so that they are not registered when the user is typing in a text box
but it's not really a problem for now

twilit dagger
#

Hi, I'm just learning to use unity and for some reason my camera keeps going to the top left continuously, I can't control it with the mouse but it still shoots in the FPS microgame. I've tried reloading Unity, disconnecting and reconnecting all my devices, and ive spent nearly an hour looking online for solutions but the only relevent post I could find on the forems seems to be unresolved back from 2019. I havent got any controllers or other devices connected to my pc other than my mouse and keyboard and still no luck.

frail tendon
#

How can I have 2 PlayerInputs in the same scene without one of them switching to another control scheme?

#

I have one PlayerInput that I use for general camera control, and I set up another one for specific function in this scene. But when they both exist, one of them switches automatically to controller and one to keyboard + mouse.

thin rain
#

is using new input system for "demo" games the right choice? I tried to start my side project on my own and the new input system is starting to make me crazy (I know unity in a level of jr to mid-ish)

delicate parcel
#

Hi, I have a problem with callback context controls/action controls. I have an action with with Negative/Positive composite and when I bind DPad Left/Right to it, it somehow shows dpad left in the action's active control, despite being triggered by dpad right. Dpad right is also marked as pressed in action controls. Am I missing sth?

chrome walrus
tardy belfry
#

Im following a tutorial and I can't find the 2d vector composite

austere grotto
tardy belfry
#

Thank you soooo muchhhhh!

#

Have a great day!

tardy jewel
#

how do i fix this

#

i cant find an input setting

thorny river
tardy jewel
#

what do i change in that setting?

thorny river
#

oh wait nvm sorry i didn't see you forgot the space

#

you could also rename the axis to MouseX using that setting though

tardy jewel
#

thanks man

#

i fixed it

thorny river
#

np

wintry dragon
#

has anyone here successfully setup multiple gamepads with the input manager? the second gamepad will create another instance of the player prefab, but either gamepad will then control both players

abstract zinc
#

Hey yall, This probably isn't the place to ask, but I was recently tasked with installing a new vr game onto a beat saber arcade cabinet. I have the game in unity, but I have no idea how to access the card reader from usb (At least I think it's usb). Does anybody have an idea on how to do so in c#?

#

I have a boolean that's set to false, but I need to set it to true once someone scans their card

tardy jewel
#

Why can't I jump in unity
First person 3D
I followed a tutorial because I couldnt get it to work
But it still doesnt work
Idk if its just my computer
Could someone please help

austere grotto
pulsar scarab
#

I'm not able open any .inputasset, anytime I double click it or click the edit asset button, nothing opens. What could be a likely issue

chrome walrus
pulsar scarab
chrome walrus
#

Let me fire up a project with input real quick

chrome walrus
pulsar scarab
chrome walrus
#

And clicking on edit asset? Does nothing?

pulsar scarab
#

double clicking on the file and clicking on the edit asset does nothing

chrome walrus
#

Oh wait, is that inside a package?

#

You are in the package part of project view, right?

#

You gotta copy that to your Assets Folder for it to be editable

chrome walrus
pulsar scarab
#

I don't think that's the issue, I get the same thing when I create a new one in the Assets Folder

chrome walrus
#

You could also just try to reinstall the input system package and see if that fixes the issue

#

The screen is empty btw

true quiver
#

I'm embedded a unity client within a WPF application and I'm having issues with, as far as I can tell, Input.GetAxis("Mouse X"/"Mouse Y"). It works fine when not embedded, but does not work when embedded.

Here is part which deals with rotating camera around the object

        if (IsCameraRotationAllowed())
        {
            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible = false;

            Camera.transform.RotateAround(HeadModel.position,
                                    Camera.transform.up,
                                    Input.GetAxis("Mouse X") * Time.deltaTime * MouseSpeed);

            Camera.transform.RotateAround(HeadModel.position,
                                Camera.transform.right,
                                -Input.GetAxis("Mouse Y") * Time.deltaTime * MouseSpeed);
        } 

IsCameraRotationAllowed just checks if the left button is pressed. The cursor's lockstate changes as expected but the camera's transform is not modified

fossil walrus
#

Hello ! is there any way to have more than one .WithCancelingThrough in a rebind operation or should I just cry in my bed for eternity ?

chrome walrus
# fossil walrus Hello ! is there any way to have more than one `.WithCancelingThrough` in a rebi...

Did you check the docs on this?

var rebind = new RebindingOperation();

// Cancel from keyboard escape key.
rebind
    .WithCancelingThrough("<Keyboard>/escape");

// Cancel from any control with "Cancel" usage.
// NOTE: This can be dangerous. The control that the wants to bind to may have the "Cancel"
//       usage assigned to it, thus making it impossible for the user to bind to the control.
rebind
    .WithCancelingThrough("*/{Cancel}");
fossil walrus
shrewd lodge
#

Hey. My input is not performing myaction that ive set up

#

I press space bar and nothing happens, its supposed to log into my console.

#

here's the code...

#
using UnityEngine;
public class PlayerControl : MonoBehaviour
{
    private Rigidbody2D player_rb;
    public float jump_power = 5f;
    // Start is called before the first frame update
    void Start()
    {
        player_rb = GetComponent<Rigidbody2D>();
    }

    public void Jumping()
    {
        Debug.Log("Jump!");
    }
}
#

I think i have all the steps made correctly, am i wrong?

#

This is my first time working with the new input system

chrome walrus
#

Well your character should jump when you detach your device 😄

shrewd lodge
#

OH

#

WAIT

#

oh

#

which one should i use? reassigned or changed?

#

regained it says

#

nvm i know

#

.. ithink..

chrome walrus
#

These events are for when a input device gets detected I think. You need to hook into the performed action

#

This might help you understanding the input system setup 🙂

shrewd lodge
#

wait... okay i understand what's wrong.. my Jump action is nit showing in the Events tab

#

ah... because i didnt press the drop down menu :)))

chrome walrus
#

Not sure where you mean, never worked with the playerinput, always doing the manual coding with input system 😄 But glad you found it 🙂

shrewd lodge
#

needed to press that

#

so this shows

#

i swear to god its the dumbest things that hold us for the longest times

chrome walrus
#

I totally agree on that 😄 Been there a lot of times. glad you found it 🙂

topaz jasper
#

hi, I'm using the new input system. Is it possible to have multiple gamepads control the same UI?

#

What I'm trying to do: all gamepads can control the same UI (main menu). Then each gamepad is controlling its UI during character selection.

mighty lance
#

I am looking for a good tutorial on controlling ui with keyboard and gamepads. If it includes steamdeck then even better

austere grotto
#

Just make sure you select one of the UI elements at first

mighty lance
#

My ui is more complex than the automatic navigation can handle out the box

fossil walrus
#

You should be able to override the different classes that inherit from Selectable (Button, Toggle, ...) and then override different methods like OnSelect() and FindSelectableOnRight() / Left()

#

Or making a general state machine script for your UI

rough pumice
#

is there any good way of telling which index is what action, as i have a Move action that is 0, but now i have a Teleport action, and i can't seem to find what index it is... Is there a way to tell? Or do i just trial and error until success?

#

this really seems annoying to do via trial and error, perhaps im doing something wrong? ```cs
UnityEngine.Object.FindObjectOfType<PlayerInput>().actionEvents[0].AddListener(ThrowInputs);
UnityEngine.Object.FindObjectOfType<PlayerInput>().actionEvents[1].AddListener(ThrowTeleport);

frigid ridge
rough pumice
#

aha i worked it out, in the inspector you can copy property paths, which then allows you to grab array indexes from the actions yayyy

solar orbit
digital dune
#

You need to set the binding of the action

worldly echo
#

if I want to destroy a game object via touching it do i need the touch position and game object position to match for that to happen or is there another way?

#

like when u touch the game object's collider with ur finger it gets destroyed

digital dune
#

The usual way is doing a raycast from the touch position to find what object was touched

austere grotto
#

Even better/easier way is use OnMouseDown or IPointerDownHandler

amber wigeon
#

does someone know how to adjust thumbstick dead zone? i changed it in project settings but it doesnt really change anything. im using new input system

scenic socket
#

In a mod I wrote I'm using InputSystem.DisableDevice() to lock out control to a game so only my UI can be interacted with. Everything functions as expected, however doing it on the mouse [ InputSystem.DisableDevice(Mouse.current) ] after like 5/10 seconds the mouse cursor disappears from my UI, but can still interact with the UI as expected. Is there a better way to block out controls?

austere grotto
#

the typical approach is have one action map for gameplay and one for UI, and you just disable the gameplay one when in a menu

scenic socket
austere grotto
#

Action maps are there for this exact reason

scenic socket
scenic socket
#

going to dig into it a bit more, but I doubt this will work for me - the game dev isn't exposing the action map to anything public and I'm still currently of the opinion a mixin for this would be excessive

scenic socket
#

patch

#

mixin all the same thing lol

austere grotto
#

i don't know the context of what you're talking about jsut saying this is the standard approach

#

getting an action map reference is quite easy, it just depends on the setup

scenic socket
#

I'm not writing a game, I'm working on a mod

#

patch == harmony runtime injections

austere grotto
#

well idk what you do or don't have access to

#

never done modding myself

#

find it hard to believe you wouldn't have access though if you have access to input data

#

but that all depends on how they've set their game up I suppose

mighty lance
fossil walrus
austere grotto
inner star
#

Is there a way for the player input manager when a player joins for it to call a function?

inner star
austere grotto
#

that's why the delegate is Action<PlayerInput>

inner star
bold jackal
#

so I have those 2 functions

#

and these 2 subscriptions

#

yet only the Jump one works

#

and the other doesn't

#

why

austere grotto
austere grotto
#

Also how are you checking if it's working

#

And how did you set up the action/bindings

inner star
bold jackal
bold jackal
bold jackal
#

sorry for the 3 pings lol

#

I am sortof sure that it's not the fault of the InputAction since it worked before, the only change I've made is that I made the PlayerInputActions object external from a singleton, instead of within script

#

the Jump function works and it's set-up in the same way

#

and _runHeld also works correctly (it's fixed update)

#

Also the control key works for crouch but S doesn't

#

for some reason

austere grotto
#

Or at least Value/float

bold jackal
#

It worked before as Value

#

like I said, I only changed the position of the PlayerInputActions variable from being a member to being referenced from a singleton

#

and I've made sure the execution order runs the InputManager before the other scripts

bold jackal
#

but changing it back to S stopped it from working

#

Yep, WASD keys are not working

#

changed left to z and right to c and crouch to x, all work

#

what is happening

#

Seems to be a Unity problem

bold jackal
#

@austere grotto any idea?

bold jackal
boreal ruin
#

Hey, is there a way to save on a JSON file the bindings in a input action asset

#

and to load them as well?

rough pumice
#

i have a joystick (logitech attack 3 specifically (does it count as a joystick?) ) and it automatically just worked for the ui, but i cannot get my player movement to work with it... No matter what binding i give my player movement it doesn't seem to do anything... Is there anyway i can work out what binding i need in order to get a vector2 from this joystick?

woeful furnace
#

Using the new Input System package, I am trying to get multiple axis and buttons working on the same action. I thought it would be pretty straightforward, but it doesn't seem to work at all. I'm only testing with a Steam Controller right now, but it seems like for some reason only one of the many buttons/axis I've assigned to the action will actually trigger the action. Any idea what I might be doing wrong?

austere grotto
supple jungle
boreal ruin
#

Hey, i have multiple errors with rebinding UI, When I click on the button (from the prefab), the rebinding UI is appearing, but the first time I'm pressing a bind, the game freezes, and i have those kind of errors :

#

I don't really know how to fix it

spark spire
#

Hey guys, I am trying to simulate clicks on my UI for my unit tests in unity using the following function:

        Camera camera = GameObject.Find(cameraName).GetComponent<Camera>();
        Vector3 screenPos = camera.WorldToScreenPoint(uiElement.transform.position);
        Set(mouse.position, screenPos);
        Click(mouse.leftButton);

Currently, I want to test if the menu changes from the main menu to the settings menu. When I run the test code using this function code(^) it does not simulate the click. I have a few questions:

  1. Does the InputSystem's Mouse have a different cartesian layout than Input.mousePosition?
  2. Does the type of camera (i.e. Orthographic or Perspective) affect the clicks? Since Perspective was giving me the screenPos as (0.00, 0.00, 0.00) where as Orthographic was giving me the screenPos as the position mentioned in the editor...
agile otter
#

i am trying to implement a checkpoint system, but when the player respawns at the checkpoint, pressing spacebar reloads the scene

#

i have no idea what could be causing this as the only script reading input from the spacebar is the playercontroller

agile otter
#

fixed, turns out i forgot about my respawn button

night dew
#

Question 1:
Is there a way i can see /check which bindings and overrides are actually active? I try to use the InputSystem Rebinding-Example and it does not work.

Question 2:
I'm using an instance of the class whose sourceCode is generated from an InputSystem-Asset. The Unity InputSystem Rebinding-Example however works on the asset. Are those linked to the same instance at runtime or does the C#-Script create a whole different instance?
Edit: Question 2 got answered and the answer is "no, they are not the same, they dont interact with each other and the Unity InputSystem Rebinding-Example does not work with C#-Generated classes" ...oh well.

boreal ruin
#

yeah i got it, but the input system doesn't answer as i need, so it's ok i revert it ^^

tepid badger
polar timber
#

how do i better organize this im having issues with the coding rn since i gotta reference each dash action one by one and its getting repetitive and messy

chrome walrus
polar timber
#

im kind of new to the new input system so heres my code

private void OnEnable()
    {
        movement = playerInputActions.Player.Movement;
        dashUp = playerInputActions.Player.DashUp;
        dashDown= playerInputActions.Player.DashDown;
        dashLeft = playerInputActions.Player.DashLeft;
        dashRight= playerInputActions.Player.DashRight;

        movement.Enable();
        dashLeft.Enable();
        dashRight.Enable();
        dashUp.Enable();
        dashDown.Enable();

        playerInputActions.Player.DashUp = 
    }
#

its unfinished

chrome walrus
#

Okay, so you can use the .performed value to know, if some key was hit. Where would you go from there?

polar timber
#

no im not asking how to continue the code

#

is like

#

i gotta reference dashup dashdown dashleft dashright

#

is there a better way to do this

chrome walrus
#

Why do you need to reference them?

chrome walrus
polar timber
chrome walrus
#

playerInputActions.Player.Enable();

#

that should enable everything

polar timber
#

oh

chrome walrus
#

or maybe even playerInputActions.Enable(); not sure 😄

polar timber
#

is there any way to sort of group multi tap input actions

digital dune
polar timber
digital dune
#

You would need to implement that logic yourself, yeah

#

But otherwise you can't group them

violet niche
#

Hey, i just noticed that using a Gamepad and binding a trigger (Left or Right, with Press and release button interaction), when i release slowly the button stays pressed until i press that button again

#

Is there any way to avoid this? Is this intended to work like that or an issue?

#

im using wasReleasedThisFrame to check

chrome walrus
small phoenix
#

Hi, I have a script implementing IDragHandler interface, but the OnDrag method is called with the Trigger button of my XR Controller. I don't know why, I'd like to change it for the Grip button. Anyone can help please ?
I am using new input system and XR Toolkit

violet niche
#

it can perfectly be the controller

chrome walrus
violet niche
#

im not really sure but i believe its because of the way wasReleasedThisFrame works

#

is possible that because of the slow input it is not considered "pressed"?

#

public bool wasReleasedThisFrame => device.wasUpdatedThisFrame && !IsValueConsideredPressed(value) && IsValueConsideredPressed(ReadValueFromPreviousFrame());

chrome walrus
violet niche
#

im tired of these bugs fr

chrome walrus
# violet niche im tired of these bugs fr

These days, you will not find software without... they just keep too much work on features everywhere 😄 But yeah, so the wasReleased is a bug because of the slow movement?

violet niche
chrome walrus
#

At least they seem to have some workaround in the forums

violet niche
#

yeah it perfectly worked, thanks for the feedback btw

chrome walrus
proud bison
#

The PlayerInputManager class exposes a method to manually join a player but I can't find how to remove one?

proud bison
#

@chrome walrus That's just a callback to notify the player has left

chrome walrus
proud bison
#

Aye

chrome walrus
#

Cant you just destroy the player? Not sure about it tho

proud bison
#

Ah, yeah they prob tied the state to the prefab created with join

#

good call

chrome walrus
#

thats maybe why you got a playerleft event but not a leave function, even if I would expect that, but I guess the join functino is just named badly here 😄

proud bison
#

Another Q input systems friends,

I'm trying to manually read values from an input actions asset within a certain class. All values read default regardless of whether or not they should, unless there is a PlayerInput class somewhere in the scene. If there is a PlayerInput class, proper values can be read.

Why is this happening?

chrome walrus
proud bison
#

@chrome walrus No way to manually listen to input without the PlayerInput class?

chrome walrus
proud bison
#

@chrome walrus I'm unclear on what you're saying. What is YourPlayerClass supposed to be? Are you proposing I inherit from PlayerInput?

chrome walrus
proud bison
#

@chrome walrus Cool, thanks

tough hatch
#

Hey! I'm trying to copy state from the controls of an input system-managed device into the state of a custom "virtual" input device. Next, I'm trying to queue the state of the custom device using InputSystem.QueueStateEvent in the OnUpdate method included with IInputUpdateCallbackReceiver. The values displayed in the Input Debugger are unexpected and constant across updates.

Here is a snippet of my code. Both my custom device and the rightHandDevice extend the XRController device type.

CustomXRControllerDeviceState state = new CustomXRControllerDeviceState();

state.triggerPressed = rightHandDevice.GetChildControl<ButtonControl>("triggerPressed");
state.buttonSouth = rightHandDevice.GetChildControl<ButtonControl>("primaryButton");
state.gripPressed = rightHandDevice.GetChildControl<ButtonControl>("gripPressed");

...

InputSystem.QueueStateEvent(this, state);

Documentation is lacking for custom input devices (I've watched the excellent Rene Damm tutorial). Quite stuck - if anyone has experience with this, please let me know. Thank you!

desert mauve
#

InvalidOperationException: Instance not valid
UnityEngine.InputSystem.InputActionSetupExtensions+BindingSyntax.Erase () (at Library/PackageCache/com.unity.inputsystem@1.3.0/InputSystem/Actions/InputActionSetupExtensions.cs:1483)
FirstPersonController.Update () (at Assets/Imported Assets/ModularFirstPersonController/FirstPersonController/FirstPersonController.cs:304)

austere grotto
desert mauve
#

Ok i'll see what i can change

austere grotto
#

I just linked you to the property

desert mauve
#

oh ye i'm lookiong

#

I'm not seeing anything but boxes telling me that its a InvalidOperationException

austere grotto
desert mauve
#

Basically i'm saying, that i'm seeing a whole lot of nothing

#

I'm looking at the doc

austere grotto
#

I don't understand what you mean then

desert mauve
#

I'm saying that i dont know what i'm looking at in the doc

austere grotto
#

that is the property to check if the binding accessor is valid

austere grotto
austere grotto
#

and that is how you check if the binding accessor is valid

desert mauve
#

ok

austere grotto
#

if you check that before calling Erase on it for example, you will never get the InvalidOperationException

desert mauve
#

this is the code

austere grotto
desert mauve
austere grotto
#

FirstPersonController.cs:304 is the relevant part

desert mauve
#

okay

desert mauve
#

its just showing declerations

austere grotto
desert mauve
austere grotto
#

it's not the code that is invalid, it's the binding accessor

#

I'd guess it happens when you try to call "ChangeBinding" with a binding string that does not exist on the Action.

desert mauve
#

So this isnt what i'm supposed to put?

austere grotto
#

i have no idea

#

it depends what bindings are on your Action

fallen wasp
#

How can I make the values smoothly go from -1 to 1? Right now it can only have three values: -1, 0, and 1. I want it to quickly lerp between values like the old input system with axis did

#

Does it have something to do with this?

chrome walrus
fallen wasp
sonic sageBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

lavish prairie
#

Why does this think I'm using the new input system? When I'm not

chrome walrus
lavish prairie
#

probably something to do with updating AR Foundation.. but there's no package showing

chrome walrus
stoic wolf
#

what action do i subscribe to if i want to call a function on press and hold?

w press   ---  foo()
          ---  foo()
          ---  foo()
          ---  foo()
w release ---
stoic wolf
#

new input

chrome walrus
# lavish prairie nothing in there

Weird. Maybe clean up the project, library folder and reimport after backing up. But I would google, never heard of that happening. 😄 What happens ify ou switch to Input system package in your active input thing?

#

Does it call you to install the package? Maybe just do that and remove it

grand obsidian
#

Hello, I wanted to see how good the new input system works for touch controls. It is working fine when i swipe left or right, but when i swipe it top/down it is kind of acting wobbly. Can't get my hands on what exactly is this issue. Thought would get my answer here.

#

this is the code i used for the movement.


    [SerializeField] InputAction mousePos;
    [SerializeField] float speed = 1;

    void OnEnable()
    {
        mousePos.Enable();
    }

    void OnDisable()
    {
        mousePos.Disable();
    }

    void Update()
    {
        float xValue = mousePos.ReadValue<Vector2>().x;
        float yValue = mousePos.ReadValue<Vector2>().y;
        transform.position = new Vector3(xValue * Time.deltaTime * speed + transform.position.x, transform.position.y, yValue * Time.deltaTime * speed + transform.position.z);
    }```
#

and the mouse values i am using.

austere grotto
#

since they're already framerate independent by their nature

grand obsidian
nova quartz
#

im trying to create a local multiplayer on one kwyboard
keyboard

#

i gave one object the first action map and another object the otherone but nothing is moving

azure hearth
#

you should probably use different Input Actions

#

instead of different mappings

nova quartz
#

so have 1 action map with both actions

#

like this

austere grotto
#

you'd have to show your code and, if you are using the PlayerInput component, the way you set that up.

nova quartz
#

ok

#

wait

#

in this case this is the player one object and i only put in callback functions under its own event mapping

#

and leaving the event maping in the other mapping blank

austere grotto
#

ok and what are you doing in the code

nova quartz
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerMovement : MonoBehaviour
{
    public CharacterController2D controller;

    public float runSpeed = 40f;
    float horizontalMove = 0f;
    private bool isJump = false;
    private Vector2 Movment = Vector2.zero;
    public GameObject bulletPrefab;

    public Transform firePoint;

    public float bulletForce = 20f;
    // Start is called before the first frame update
    void Start()
    {
        
    }


    public void OnMove(InputAction.CallbackContext context)
    {
        Movment = context.ReadValue<Vector2>();
    }

    public void onJump(InputAction.CallbackContext context) 
    {
        isJump = context.action.triggered;
    }

    public void onShoot(InputAction.CallbackContext context)
    {
        if (context.action.triggered)
        {
           Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
            
            
           
        }
    }

    // Update is called once per frame
    void Update()
    {
        horizontalMove = Movment.x * runSpeed;

        
    }
    private void FixedUpdate()
    {
        controller.Move(horizontalMove * Time.fixedDeltaTime, false, isJump);

    }
}
#

and the CharacterController2D is brackeys charecter controler

#

btw evrything worked when i intianly set it up for controler and keyboard

austere grotto
#

also using PlayerInput this way is super weird

#

probably broken because you're trying to use the same device for multiple players

#

PlayerInput component expects itself to have exclusive access to a single device

nova quartz
#

i see

#

so how would i do split keyboard

#

@austere grotto

zinc ember
#

Hiya, I've spent ages scouring the web and every time I find a forum where my question is asked there's 0 replies. I've been learning to use Unity's new input system and have been making it so my game can run mouse/keyboard, gamepad, and mobile, for mobile, my joystick controls the character's movement and swiping the screen rotates the third-person camera. The issue I'm having is that anywhere you touch on the screen counts as swipe input, so moving the joystick will also rotate the camera. I've tried using a canvas group to block raycasts but this doesn't seem to affect touchscreen input. Is there a way with the new system to either block touch input or designate a specific area of the screen to allow it?

austere grotto
zinc ember
austere grotto
#

do what

#

input system just reads device input

#

it doesn't know or care about what's happening on screen or in game

#

that's why would want to do this at the eventsystem level

zinc ember
#

I see, thanks for confirming that

chrome walrus
grand obsidian
chrome walrus
# grand obsidian You mean multiply the x and y values with deltatime?

you are setting your position to Time.deltaTime, which will vary on every frame, cause its the time between frames. So this can be any floating value. You use time.deltatime to have a frame independent value to lerp your position from current to the new position with your speed * Time.deltaTime.

grand obsidian
chrome walrus
grand obsidian
#

yup

chrome walrus
#

Can you paste your code again as its now?

grand obsidian
#
    [SerializeField] InputAction mousePos;
    [SerializeField] float speed = 1;

    void OnEnable()
    {
        mousePos.Enable();
    }

    void OnDisable()
    {
        mousePos.Disable();
    }

    void Update()
    {
        float xValue = mousePos.ReadValue<Vector2>().x;
        float yValue = mousePos.ReadValue<Vector2>().y;
        transform.position = new Vector3(xValue * speed + transform.position.x, transform.position.y, yValue * speed + transform.position.z);
    }```
zinc ember
#

Hey, I've been up all morning trying to figure out how to get the touch joystick AND having swipe as a way to rotate the camera working and I've found a scuffed workaround after being completely unable to achieve something that works how I want. Instead I've told the game to ignore inputs in dead zones. The problem at the moment is only the first finger that touches the phone can rotate the camera, and if it touches a dead zone it won't initially rotate the camera, but when a second finger is put down outside of a dead zone, the first one now controls the camera.
Anyone know what I can do to let any number of fingers be eligible for the input, and how to tell it to completely ignore all input from swipes that start in dead zones?

tame oracle
#

i made a first person core project then when i added player input component to an object, the movement stop working completely , is it becuse theres 2 player inputs?

#

it was

stiff silo
#

Im a little confused by the examples Ive found for the new input systemn

spark spire
#

Hey guys, is it possible to simulate clicks for testing UI or 3d object picking in unity?

#

Is there any link to achieve this?

amber wigeon
#

does it make controller left stick have 1 and 0 variables?

#

i want to make thumbstick have only 1, 0, -1 values so it doesnt make player move slower when thumbstick isn't pulled fully

austere grotto
amber wigeon
amber wigeon
#

i dont see it

#

in the move field or xbox controller field?

austere grotto
#

The action

#

Move is the action

#

you can also do it on the xbox binding if you want

#

either one

amber wigeon
#

hi! i have made player movement with new unity input system and when i pull thumbstick left and right, it works normal, but when i move it to upper left or any thumbstick corner it makes player slow down. does anyone know how to make move script ignore Y axis and only operate with X axis? move script: rb.velocity = new Vector2(horizontal * speed, rb.velocity.y);

#

oh wait

#

i edited video wrong

#

wait guys

#

done

amber wigeon
# amber wigeon

you see? player slows down when i pull thumbstick slightly down or up while still having it on left or right

ruby needle
#

any ideas why when I first use wsad, arrows wont work. When I use arrows first then wsad wont work? It doesn't print the inputVector

austere grotto
#

Also where and how are you calling GetMovementVector?

ruby needle
#

It's for a XZ plane camera movement that's why 3d vector

austere grotto
#

you're still only reading two axes

#

all you have to do is swizzle them to x/z

#

not use 3D vector

#

it's a 2D input

austere grotto
ruby needle
#

in my camera controller script

austere grotto
#

show the code

ruby needle
#

you are right about 2d input yeah

austere grotto
#

no matter what is happening with the input

#

so you should get a log output every frame

ruby needle
#

I am yeah

#

but why arrows wont work when I first press wasd or vice versa, that's what I didn't understand

austere grotto
#

show how the action is configured?

ruby needle
#

I did above

austere grotto
#

No you showed the bindings

#

not the action itself

ruby needle
#

its my first time using the new inputs so I am not sure what the actions are

austere grotto
#

click that

#

"WSAD" and "Arrow Keys" are the bindings

ruby needle
austere grotto
#

what happens if you turn off Digital normalized

#

does it change anything

ruby needle
#

No changes I've tried all 3 options

#

sec

#

yeah same

#

setting it to 2d vector fixed the problem but I wonder why it didn't work on 3d

ruby needle
#

How can I return 1 when I press q and return -1 when I press e? Created an action with action type: value and control type: integer but they both return 1

#

do I need vector2 again?

austere grotto
#

and create a 1D axis composite

thorny epoch
#

i beg for assistance

old matrix
#

How do I get the current active input asset? I want to get the bindings to show keys to the player in dialogue

chrome walrus
chrome walrus
old matrix
chrome walrus
old matrix
#

oh i forgot the samples tab existed my bad

plain carbon
thorny epoch
quiet tusk
#

Alright who has the best tutorial on the new input system. I want to switch over to the dark side.

quiet tusk
#

So If I select Button North Gamepad as a binding and I don't specifically add Y-Xbox controller binding, will the xbox controller not work ?

thick bay
#

Just starting with this new input system and I don’t see how to do this:
I have an InputActionAsset in which I'm trying to create a composite Action for “CameraControl”, the value I want to get out is a 2D vector.
I’ve got it working fine with WASD and the 4 arrow keys, but I also wanted to give the user the option to use the mouse scroll-wheel for forwards/backwards, and just do left/right using keys.

Things I’ve tried:
The controls it allows me to select for each of the composite binding elements are ONLY buttons, it won’t let me select the mouse scroll wheel. (Which makes sense- it’s looking for a single bit for each of the elements; UP and DOWN)
It also won’t me select the scroll wheel when it’s NOT a composite binding (which also makes sense as in this case it’s looking for a 2-d input, not the axis input the scroll wheel provides)
I’ve been able to create 1-D (axis) ACTION that allow me to select the mouse scroll wheel as the control- but it doesn’t look like I can make THAT action, provide input to uh.. “some” of my CameraControl action’s bindings.

How can I implement this?

thick bay
#

^ solved: solution- TYPE in the path to the mouse scroll wheel

quiet tusk
#

Problem:
I'm assigning context.ReadValue<Vector2>().x to a global _horizontalMovement variable
I use a teleport ability that resets _horizontalMovement back to 0 and the controls are locked until the player stops teleporting.
The input system doesn't detect any changes from the controller because its still on -1 or 1 (which the player should start moving after teleport is over)
How do I force an update to the Movement action so it continues to read that the player has the joystick in a movement position?

The only way to regain movement is to move the joystick from whatever position it was at before teleport started which is horrible player experience.

quiet tusk
#

I figured out to loop through the player input's actions array looking for my movement event name and force update my player's _horizontalMovement to that of the ReadValue and it works.

crystal narwhal
#

what is the best approach to have some button in my canvas to simulate inputs, is the best solution to implement my android controller?

polar timber
#

whats the difference between tap and press

swift spade
#

How do you switch back to the old input system ?

quiet tusk
narrow seal
#

when my player dies they get deactivated which also deactivates the player input and prevents me from pausing the game

#

also the player is a prefab so i cant just separate the input into another object

quiet tusk
narrow seal
#

ive tried that but it doesnt work

#

it disables the inputs on the other player input controller

#

is that not intentional?

quiet tusk
# narrow seal is that not intentional?

No that's right. It is still on the same .inputactions asset. Maybe create another .inputactions asset that is for UI ? If not that, try a different route of achieving what you want and not setting your player's object to disabled?

narrow seal
#

making another input action doesnt work either

narrow seal
quiet tusk
quiet tusk
narrow seal
#

that would be a really nice solution but it doesnt work, for some reason the second player input takes priority over the input thats on the player

#

so you cant move as long as the other player input is active

#

ig i could try disabling it while the other player input is active

#

that seems extremely unnecessary why cant 2 player inputs just work at the same time

quiet tusk
#

Well I got it working on mine just now

narrow seal
#

you have multiple player inputs in the same scene??

narrow seal
#

im just using sendmessages and not doing anything with generate c# class

quiet tusk
#

my behavior is Invoke Unity Events. I find it a lot easier. But that shouldn't have anything to do with the object being active or not

narrow seal
#

is this a bug?

#

i dont believe i cant use multiple player inputs in the scene

quiet tusk
narrow seal
#

i have a player input on the pause menu gameobject

#

then im spawning a player as a prefab and they have another player input on them

quiet tusk
#

And you have assigned different inputactions asset to them both?

narrow seal
#

ive tried different inputactions and different maps

#

the one on the pause menu always takes priority and just prevents the other one from working

#

the other player input just doesnt read any inputs

#

how did you manage to get yours to work?

quiet tusk
#

Do you see this when running 2 in the scene ?

narrow seal
#

no im not using input system ui at all

#

do i need to?

quiet tusk
#

After I disabled my character, I pressed the start button on my gamepad and that is what's firing, which is firing from the UIInput object

narrow seal
#

my player is instantiated so ill try assigning the UI module with code

quiet tusk
narrow seal
#

the player has a lot of stuff on him and just due to the nature of how my game works i need to keep the player on the scene

#

it doesnt work

#

it seems like once a player input is in the scene it takes priority over anything even after its been disabled

#

im just gonna try some weird janky workaround

#

ok well now i have another problem

#

im trying to switch to unity events

#

but this doesnt show up on the list?

#

is it because of the inputvalue

quiet tusk
#

public void FirePaintGun(InputAction.CallbackContext context)

#

expand events > player and assign via script

#

for move you would do

public void Movement(InputAction.CallbackContext context)
    {
        if (GetControlsLock()) return;
        PlayerController.Instance.MovePlayer(context.ReadValue<Vector2>().x);
    }
narrow seal
#

ah

#

thank you

#

my janky solution kinda works now but i just have one more problem

#

is there a way to assign functions to an event at runtime

quiet tusk
#

not sure on that one but I feel like the functions you need to subscribe to should also live on the prefab if it has to do with the player

narrow seal
#

i made an empty gameobject and placed it in the player prefab and told it to basically disconnect itself from the prefab when it spawns

quiet tusk
#

I use a PlayerInputManager class that deals with all the events, then i just dispatch out where i need to go

narrow seal
quiet tusk
#

Also I feel like you could've nested your player object in a container object and have the input component on the container if you were going be deactivating your player itself so then the input system still works. But I don't have a clue exactly what you are doing.

narrow seal
#

basically the player spawns with a controller object and that object loses its parent when spawned

#

so it remains in the scene

quiet tusk
# narrow seal how does that work

I do something like this. All my player abilities have their own script and a single instance of them that live on the player object so I can always call on them when needed via their instance. This also will allow to swap out abilities to buttons using player prefs or something.
https://pastebin.com/S5dTWHnD
So on the Player Input component I only ever add the PlayerInputManager script to reference

narrow seal
#

how does input manager work?

#

ive tried using it but theres almost no documentation about it

quiet tusk
#

No lol, thats a custom script I created

narrow seal
#

oh

#

i thought you were talking about the player input manager component lol

unborn hemlock
#

Hello can you help me in my code because i'm making game like flappy bird and my sprite (player) don't fall down and don't move up when space pressed

#

pls help me FAST!

#

its my school project

#

@everyone

tame oracle
#

For some reason, setting VSync to the highest level under Quality completely eliminated input lag. Why is it like this?

#

Setting it to 1 or 0 causes a relatively huge (around 500 milliseconds) of delay even though the game is running at 60fps

quiet tusk
minor current
#

I'm using the new unity input system and Im trying to create a local multiplayer but when referencing the PlayerInput through the script it uses the same one for every charcter so when I jump all the players jump is their a way to change this?

austere grotto
minor current
austere grotto
#

You are using your generated C# class

#

Use PlayerInput instead

minor current
#

if I use playerinput instead how would i go about assigning things through a script than like this line for example playerControls.Player.Jump.triggered?

austere grotto
#

By reading the article

minor current
#

quickly before I read It will this allow me to use if statements or will it all have to be done through events?

swift wagon
#

How would I go about using 2 joycons as a single controller in unity

dry token
#

my functions aren't being called when I press the keys related to each action, any idea why?

zinc stump
#

Looks like it should be working at glance. Checkout Code Monkey video on new Input System. Might find what you are missing.

dry token
#

yeah I did exactly the same steps as I did in my other project and it works there notlikethis

#

could it have something to do with the player being a prefab

zinc stump
#

I didn't have problems trying this approach from just following the video. It's when instantiating class you get additional gotchas of having it enabled properly.

dry token
#

right

#

I'll check it out

dry token
#

I... did the exact same things 🥲

dry token
#

I found out the issue is with the control scheme thingy

#

atwhatcost it was an oversight on my part

ruby needle
#

do we really need to use update in order to check if user holding a button in new input system? like to check if holding shift then sprint. Not talking about the hold .5 sec to fire an event

austere grotto
ruby needle
#

How do you do it with events? I subscribed both performed and cancelled. Created a bool to check if holding and set true if performed, set false if cancelled in update

austere grotto
ruby needle
#

still we have to use update then

austere grotto
#

If you want to do something every frame you have to use update. This is unrelated to the input system

#

But what are you actually doing in Update

ruby needle
#

placing tiles while holding left button

unborn hemlock
#

hello i have next problem

#

i dont see pipes

austere grotto
unborn hemlock
#

but where can i have help on this server

#

idk

dry token
#

to add onto the question earlier, how does holding one button continuously work, is there not an option when setting the action in the input manager? do I have to do it with a subscription and a book or can it be done from the inspector too

austere grotto
dry token
#

ah could I use smth like button pressing down/release for start/cancel? @austere grotto

thick bay
#

Working on converting my project to use the input system. I have the UI stuff on Canvas working fine. But I also have a custom map upon which I use the mouse-posiiton to determine which “map-tile” the mouse is over- this is custom code, not event based, (though it does generate its own events).
I have the following code in that MouseOverMapTile monobehavior:

    InputAction moseOverAction => inputActions.FindAction("MouseOver");
    InputAction selectAction => inputActions.FindAction("Select");
    Vector2 mousePos => moseOverAction.ReadValue<Vector2>();

    HexIndex2D previousMouseOver;
    HexIndex2D mouseDownOver;

    void Update()
    {
        Debug.Log("mousePos: " + mousePos);
         …stuff…
     }

In the inspector I dragged my configured InputActionAsset (see pic) onto the public field above. The problem is that the debug log output ALWAYS show the mouse position as (0,0)- no mater where I move the mouse.
What am I doing wrong?

versed venture
#

I'm trying to add playercontrols for ps4 controller for a 2D-project with this piece of code:

float moveVertical = Input.GetAxis("Vertical");
            float moveHorizontal = Input.GetAxis("Horizontal");
            transform.Translate(new Vector3(moveHorizontal, moveVertical, 0) * moveSpeed * Time.deltaTime);

I'm still using the old input manager and for a reason, my vertical movement doesn't work. only horizontal. If I'm setting the y-axis to x-axis for "Vertical", then it moves both right and up (but not directly up.)

#

Could someone help me with it? Idk what could be the problem

thick bay
thick bay
thick bay
#

hmmm, then it LOOKs ok to me.. what do you mean by " If I'm setting the y-axis to x-axis for "Vertical", then it moves both right and up (but not directly up.)" was that just a test?

#

also what do you get if you Debug.Log(" horiz: " + moveHorizontal ); does it ever have a non-zero value?

versed venture
#

if I set the axis from Vertical to X-axis instead of Y-axis, then it moves both to x and y axis

#

simply said, if vertical is y-axis, then the player only moves like the left side of the drawing.
If the vertical is x-axis, then the player moves like on the right side of the drawing.

It seems like it doesn't repond when it's set to y axis

thick bay
#

ok, THAT makes sense: the diagonal direction is simply due to the fact that your using the same value for the X and Y components of the Vector3 you use in translate. What do you get for the Debug.log, I suggested above (when vertical is set to you Y-axis).

#

afk fam

versed venture
#

(the problem is in the vertical axis, so I changed it for horizon: to vertical:)
I only get the 0 value. It seems to not respond on the y axis.

thick bay
#

hmmm, lets confirm it's not a hardware issue. Add some keyboard inputs for vertical (one for positive, one for negative) and see if THOSE give non-zero output in the debug log. If they DO, I'd start to wonder if there is a problem with the controller.

versed venture
#

Keyboard controls give a normal reaction

#

with a normal debug.log

thick bay
#

Can you test that controller some other way? does it work when playing (not-your) games?

versed venture
#

yeah, I play other games with it too. it reacts normal

thick bay
#

hmmm, I don't have any other ideas other than the sanity-check of testing this on a new project.

#

(to confirm nothing else in the project is messing this up ... somehow)

versed venture
#

Hmm, I'll test it.

thick bay
#

oh! doubt this is it.. but do you have the same "dead" value for vertical and horiz (in input manager)

versed venture
#

yeah, everything is the same

#

0.19 deadvalue

thick bay
#

ok, was a shot in the dark. Could TRY setting it to zero, but doubt that'll do it.

versed venture
#

no, doesn't work indeed

#

thnx for your help. I'll try later with another controller. If that still doesn't work, then I'll change it to the new input system

thick bay
#

sure thing, sorry we had no luck 😦

#

lemme know how it goes, pls

versed venture
#

ah, you did everything you could. It's prob smt with my settings or controller

versed venture
tiny ivy
#

Quick Question, what is CallbackContext duration supposed to represent, I thought that it represented the time between performed and cancel, but it seems to always be 0? Am I not including some setting to have it keep track of that time?

verbal remnant
tiny ivy
#

There is little documentation on that, i generally expected it to be the time between start pressing and cancelling which is very useful.

verbal remnant
dry token
#

any idea why MoveLeft gets called twice whenever I press the button?

#

MoveRight behaves just fine

#

NVM

fierce turret
#

I can't understand why it doesn't work. It worked, but when I something changed it stopped working((. I can't find it

austere grotto
fierce turret
#

I wrote a code and it worked. However, I changed something. And I can't find it for 2 hours

lavish nacelle
#

does anyone know why im not given the option to select 2d axis for the type

zinc stump
#

It's only for Value action types

lavish nacelle
zinc stump
#

yes

lavish nacelle
#

alright thanks a lot

regal osprey
#

hi there
does anybody know how to handle multiple action maps with player input at one?
Specifically, I have an action map for controlling the camera from an isometric perspective and one action map for doing so with a drone type perspective (free roam)
both are driven through one playerinput instance, which gets its action map changed depending on the mode the camera is in
now. how do I handle global actions with playerinput (like pausing the game) without having to add the action to all action maps?

austere grotto
#

leave that one always enabled

regal osprey
#

Id have to enable it manually somewhere right?

austere grotto
#

don't use SwitchCurrentActionMap, you can control the maps individually as you wish

#

through myPlayerInput.actions.GetActionMap("actionMapName")

regal osprey
#

should that work well with control schemes? I'm trying to differentiate between MKB and controllers

strange bison
#

Hi guys, I am loading my InputActionAsset into my InteractionSystem through Resources.Load - This of course allows the InputActions in the project to be dragged into any inspector fields.
I also want to enable the use of code to access those same InputActions, for example: InteractionSystem.PCGamepad.heldItem.primaryAction
However, it seems to be impossible to have the code reference the same InputActionAsset as the one loaded through Resources.Load, because PCGamepad myPCGamepadInputActionAsset = new(); Creates a new instance of the InputActionAsset in memory
and myPCGamepadInputActionAsset.asset = theResourcesLoadedOne; is not possible because .asset is read-only.

My Interaction system is managing the enabled state of all the maps throughout the state of the game.

Does this mean that if I intend to support both editor drag and drop and code access to InputActions, I need to hold two InputActionAssets in memory and keep them both in sync inside my InteractionSystem?
Is there any way to create a code accessor (InteractionSystem.PCGamepad.heldItem.primaryAction) to the asset loaded by Resources.Load?

odd steppe
#

How do i add new things or edit existing ones in input system

austere grotto
odd steppe
#

Dash under shift, jump to W

#

@austere grotto

austere grotto
#

that's just creating basic input actions with bindings

odd steppe
#

Yeah but i saw that there is already some basic inputs

#

like "jump"

#

how do i access them

austere grotto
#

That's only in the old input system

odd steppe
#

oh

#

really?

austere grotto
#

And you just set those up through Edit -> Project Settings -> Input Manager

odd steppe
#

thank you

#

which one do you recommend more?

austere grotto
#

if you're a beginner stick with the old one for now

odd steppe
#

Why?

austere grotto
#

it's simpler

strange bison
#

Any thoughts on my question? Many thanks if you can help

austere grotto
#

I thought myPCGamepadInputActionAsset is already an InputActionAsset

#

why does it have a .asset field

#

oh it's the autogenerated class right? That's a bit different from the InputActionsAsset you're loading from Resources.Load

#

it's a wrapper

strange bison
#

It's not an IAA, it's the c# class generated by one

austere grotto
#

But I'm not sure I see why you would want to use the loaded one if you're using the autogenerated one

strange bison
#

Yeah the wrapper

#

Because the resources.Load one is the one I can drag references to into inspectors

#

I understand that if I load that into my interaction system and start enabling and disabling maps, the asset in the generated c# isn't the same thing, therefor the management of maps is out of sync between the two

austere grotto
#

Yeah I'm not sure you'll get away with mixing and matching like this

#

Also look into InputActionReference if you haven't

strange bison
#

Yeah I've used that a lot in places. I wish I could do some kind of input action asset reference.

#

Shame it's one way of working or the other, not both raw code and inspector references.

austere grotto
#

but no you won't get the wrapper like that

#

I'm actually kinda curious

#

is there a constructor for the wrapper that takes an asset?

strange bison
#

Yeah :/ I guess my only solution to support both is have the interaction system hold on to them both and keep them in sync.

#

Sadly not

#

The generated code makes it all readonly in a partial class, I even tried writing my own supporting partial that would allow it, but no luck.

slim tusk
#

i just hopped in Unity, is using the input system good on performance when it goes into multiplayer networks?

austere grotto
slim tusk
austere grotto
#

what kind of problems

#

performance is not a problem in general, no

slim tusk
#

im trying to learn the engine and im seeing stuff that i havent seen like 6 years ago

strange bison
#

Here's a mad one, anyone know where the code is that generates the C# classes for the InputActionAssets?

  • I want to add my own custom public constructors
fallen wasp
#

How can I ReadValue<float> from a button type action?

strange bison
fallen wasp
#

No option for ...AsButton

#

only AsObject

strange bison
#

one sec...

fallen wasp
#

Can I do ReadValue<bool>() ? 1 : 0;?

strange bison
#

mayyyybe I think that's an odd one and is why ReadValueAsButton exists
What is your HandBrake type?
Here my context is an InputAction

fallen wasp
#

2020.3.29f1 (Input System v1.3.0)

strange bison
#

In full for my example (It's a debug UI showing the values of various InputActions

fallen wasp
strange bison
#

I'm running 1.4.4

fallen wasp
#

ReadValue<float> worked though

#

0 if not pressed, 1 if pressed

#

Thank you for sharing your script

strange bison
#

Brill 🙂 no worries, glad it helped