#🖱️┃input-system

1 messages · Page 59 of 1

limpid cradle
#

all fixed

rare siren
#

Hey, i have a small racing game with the new input system. So i have an action map with some actions for accellerating, braking and rotating. Support for Keyboard and Controller. How do i get it working on some Wheels like the logitech G29 (G920 etc) and other wheels? I have read something about "HID" but i dont really understand how i can map them generally to the action. i do not want to create a HID for every single wheel that exist.

prisma crane
#

Any ideas why this situation occurs?:

I have a 2D player that moves in all 8 directions and a tilemap with boxes scattered around.
If I hold 2 keys at the same time (for example W and D) the player moves diagonally until it collides with a box, then it slides along its side (so north/west) until it exists the collider's range. That's all fine, but if I keep holding W and D through all that interaction, once the player passes the box it keeps moving on one axis (north/west) instead of returning to the diagonal movement ( as it should be normal ).

The player is built using the input system for movement, so I figured it has to do something with it.

I can't wrap my mind around why this is happening. Thanks in advance!

pliant spoke
#

I have been following brackets 3rd person movement video
But I don't know how I will use the new input system

#

What if I used the old one?? And can I use the old one??

austere grotto
#

Brackeys uses the old one so you should use the old one with it

austere grotto
prisma crane
austere grotto
# prisma crane

Ok seems pretty simple to me. This is the order of events:

  • You get an OnMove setting your velocity diagonal.
  • Your object hits a box or whatever, so it starts sliding along the dge of that
  • There's no change in your input actuation after that so the object continues sliding in it's current direction after it clears the box
#

You won't receive another OnMove until the actuation of the keys changes

#

Also are you setting up the event subscription for OnMove manually?

#

I see you are using the generated C# class

#

A fix for you would be to switch away from using events for this and instead poll the input in update:

void Update() {
  Vector2 inputDir = playerInput.Movement.Move.ReadValue<Vector2>();
  rb.velocity = inputDir * speed;
}```
prisma crane
austere grotto
#

that's decidedly not using the PLayerInput component

#

Anyway you can get it working with events from the PlayerInput component too. Just take your current code but instead of settign the velocity in the event handler, just save the Vector2 from the input into a variable

#

Then set velocity in Update or FixedUpdate from that stored Vector2

#

e.g.

Vector2 moveInput;

void OnMove(InputAction.CallbackContext ctx) {
  moveInput = ctx.ReadValue<Vector2>();
}

void FixedUpdate() {
  rb.velocity = moveInput * speed;
}```
prisma crane
austere grotto
prisma crane
mossy radish
#

Hi, does anyone know, how to make interaction button with input system?
For example, I want to open the doors or pick up an item with "E" or "BUTTON EAST"

austere grotto
#

Raycasts

#

Most of that is not related to the input system

mossy radish
#

I’m a beginner at coding, so can You explain a little bit? I use 3th person starting asset https://youtu.be/4QuPlKzdq14

Starter Assets are designed to work as a quick start into prototyping and developing character controllers for various game genres, using systems and methods that are easy to build and expand upon for different projects.

▶ Read more on the Starter Assets https://on.unity.com/3gvKQAX
▶ Technical questions and support https://on.unity.com/3cZlo4P...

▶ Play video
vague locust
#

Hello i am reading currently the Documentation of the new Input System from Unity. There is for to create a Simple Fire Type Action this example
var action = new InputAction(binding: "*/{primaryAction}"); And i dont understand for what the "*/{primaryAction}" is. Can someone explain me what that means?

prisma crane
austere grotto
turbid saffron
turbid saffron
#

Alternatively does anybody have a link to download 1.3.0?

#

Well if anyone's searching for the same thing com.unity.inputsystem@1.3.0 is the git url to add

indigo patrol
#

You can add the package with package manager via package-name

ruby canopy
#

Hello, I'm having problems with the new input system. For some reason when I press the screen the framerate of my game goes crazy low, is this a bug from the package or those this have a solution?

unkempt kernel
#

Hello, I it possible to bind an On-ScreenButton component to an Input Action instead of a key?

valid dagger
#

What should I be using if I want to add a 3D looking system? For instance, using the mouse scroll wheel to zoom in.

thick yacht
valid dagger
#

I'm thinking I need a teacher/mentor/partner to help me as in the past I was never able to fully get a good camera system working. Issues with gimbal and maths.

thick yacht
#

how to implement tap & hold interaction with one key (space key)? Like, I need to get the hold value from ctx callback for now

#

yeah, hope someone can help with that, working with camera is a bit tricky for me

valid dagger
#

Hmm

#

Is that the new input system?

dry raven
valid dagger
#

I have the new Input System installed and am trying to use the C# code using UnityEngine.InputSystem; but it's not working saying it's not reconized.

#

I followed the steps but it doesn't appear to be working.

austere grotto
#

Make sure your IDE is configured properly and try regenerating project files.

untold gulch
#

Also if you're using assembly definitions, make sure they have a reference to the input system

ruby canopy
tall iris
#

um so Im making a vr game and im adding a grapple to it, this is my code and error message

#

Can anyone help?

austere grotto
#

as the error says

tall iris
#

k thx

#

Someone helped me with the script so what goes here?

austere grotto
#

press the circle

tall iris
#

ik

#

I just made a trigger input

opal blaze
#

whats the best way to register input from ui clicks and drags etc ?

safe forge
#

Would it be inefficient to use UnityEvents to program my InputAction's responses, or should I use regular delegate events? It would be more of a hassle to have that be the case, as the ease of creation would be greatly increased, but are there any performance issues with that?

visual tapir
#

Is it safe to attach the input actions to multiple game objects? Like to a MoveController and to a CombatController or will it somehow misbehave in calling the invoked methods reliably?

austere grotto
#

There's no problem with that.

hidden coral
#

Anyone know where I might find a good tutorial on implementing “Grab to move, scale, and rotate” regarding player movement for VR/Oculus dev?

valid dagger
#

I having issues with getting the new Input System to "connect" with my C# code.

nova fractal
#

Hi everyone, could someone please point me in the direction of some resources that would allow me to get my head around interactions in the new input system? Trying to use a Press and Release interaction but the official docs are not getting the ideas through my thick skull.

valid dagger
#

I believe the script is attached to the component fine.

glass yacht
#

It's it.

#

You have dragged a script into the field.

valid dagger
#

The C# script has already been dragged/attached to it.

glass yacht
#

and did you drag that component instance into the field

#

or did you drag the script from the project view

valid dagger
#

Hmm. Testing brb

#

@glass yacht Your right.

#

Thank you so much!

#

Now to figure out how to make it send to the correct C# code/function.

#

In regards to getting the C# function to trigger, is this wrong?

#

Nothing seems to trigger the function

valid dagger
#

Is anyone familiar with the new input system able to help me get it setup and working in C#? I believe I have everything setup correctly but the C# code won't trigger/run.

austere grotto
#

Start simple

#

Just the keyboard

#

Add more later

valid dagger
#

For some reason the keyboard isn't showing up as a option to select keys from.

austere grotto
#

Show the action itself

#

Also you're almost definitely adding unecessary interactions

valid dagger
dark tinsel
#

I'm trying to make my weapon sway work with the new Input System but the weapon sway looks laggy and snappy sometimes and I havent found out why.

Weaponsway code

    private void DetermineRotation(){
        Vector2 mouseAxis = playerMovementInput * swayAmount;
        transform.localPosition += new Vector3(mouseAxis.x, mouseAxis.y, 0);
    }

playerMovementInput is the recieved Delta Mouse input but the movement looks laggy. I tried multiple weapon sways out code wise but all end up seeming laggy.

#

This is my Input setup for the camera

austere grotto
dark tinsel
austere grotto
#

that's why

dark tinsel
#

oh?

austere grotto
#

yes

#

should be in update

dark tinsel
#

But how do I keep constant weapon sway regardless of framerate then?

austere grotto
#

Well what I can say is that input is updated each frame

#

in Update

#

so by reading this in FixedUpdate you're missing mouse input from some frames

#

hence the weird stuttering

dark tinsel
#

Makes sense

#

right,

austere grotto
#

mouse input is also framerate independent automatically

#

so the actual mouse handling can safely be done in Update without any adjustments

dark tinsel
#

Aight lemme try that rq

austere grotto
#

your code is confusing me though I have little idea as to what you're repositioning with this code

#

and why you're changing a position inside a method called "DetermineRotation"

dark tinsel
reef summit
#

what's the difference between scroll x and scroll y? I tried doing <Mouse>/scroll for my binding to rotate between weapons, but it's not working.

#

i wanted to maybe try one of those

austere grotto
#

horizontal/vertical

#

some mouses have horizontal scrolling features

#

scroll y would be the "standard" scrolling

reef summit
#

okay so i'd do <Mouse>/scroll/y

#

to read that value would i just do it as a float

austere grotto
#

yes

reef summit
austere grotto
#

I've never seen the input system used this way 😮

#

I'm not really an expert on creating InputActions manually in code like this

reef summit
#

i normally don't do it this way, someone else in my group does though, and i want to keep it consistent since he likes to keep things organized like that

#

i think it could have to do with being a 1d vector

#

and not just a single value

valid dagger
#

Two days later and I figured out the Input system isn't working because I upgraded a older map to the current Unity version.

reef summit
#

lemme try something

reef summit
#

I think I have the right idea but I don't quite know the string i should use for binding. I want to add a composite binding and do scrolling up and down on the scroll wheel separately, but I only know the string to get input from the scroll wheel itself, not the specific direction

tame oracle
#

hi im using the new unity input system. how can i change the scrollbar value on mousewheel scrolling?

austere grotto
#

It should happen automatically as long as your input module is set up with the defaults for the new system

tame oracle
#

i have 2 canvases

long escarp
#

what is a more convenient way of doing this?

#

is it possible to do something similar using a switch statement for example?

mortal ridge
#

switch - no. just subscribe to the events

mental musk
#

InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.
UnityEngine.EventSystems.BaseInput.GetButtonDown (System.String buttonName) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/BaseInput.cs:126)
UnityEngine.EventSystems.StandaloneInputModule.ShouldActivateModule () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:227)
UnityEngine.EventSystems.EventSystem.Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:474)

Is there a way to figure out which script still uses the old functions?

#

I checked every script, but can't find it

austere grotto
austere grotto
#

Literally says it there: StandaloneInputModule

elfin badge
#

I think this would be the best place to ask for this
I'm modding a game, which we have full access to source code for, but not a buildable version, so everything is done using DNSpy and patching the assembly-csharp.dll file

I'm wanting to inject inputs straight into the game, with as high of precision as I can get
The Unity version the game was written in was 2017.4.10f1
For better clarification, I am trying to inject inputs based on a file I will read, without human input
It will read the file, then figure out what to send to the game, and what to press
I'm wanting this to be in the game itself in order to escape lag

It is a single player game, with simple 2d graphics

mental musk
tame oracle
#

Are control schemes the right thing for split keyboard controls?

tame oracle
#

I set up 2 control schemes 'keyboard left' and keyboard right' one using the wasd keys the other the arrows, but unity seems to not allow to split one device in 2.

#

I tried using the input manager to spawn to player prefabs but it only spawns one, always the keyboard left one too.

mental musk
safe forge
#

Okay, So i have some ideas of how to fix my issue, but I dont feel like they're right.
I am trying to use a PlayerInput component detect an initial press of the spacebar as one action, and the release of the spacebar as another action. This is to get Hold time of Spacebar to create an analog jump height, but that is kinda irrelevant as the issue doesnt lie in the purpose, the issue is that Even though i am using an interaction on the spacebar actions to try to make them only run when its an intial press or a final release, its sending the event on detection of press, hold, and release no matter the interaction.
The attached images are what the relevant InputActions look like.
The root action Jump Press and Jump Release both have ActionType Pass Through and Control Type of Key.
I have both assigned to a JumpPress() and JumpRelease() method in a PlayerScript script, and I put count++; in each method to see if it was triggering properly, and each method was being triggered 3 times, 2 times if i press it fast enough (which makes sense)
I have no idea how to get the desired behavior for each action, and Ive been fiddling with it for hours.
My solutions i have in mind are just use one action and code to ignore the 2nd input to just manually add GetKeyDown and GetKey and GetKeyUp behavior but that wont always work because of this inputsystem only giving 2 triggers if the key is pressed quick enough, and just reading the values directly from Keyboard.current is just the old Input System but with extra steps which ive done in the past and I'd rather use the New InputSystem to its fullest extent.
What should I do?

#

No matter what setting i put my action on, it always reads three triggers of the key and not just one.

#

Okay, more research leads me to say that there is no way for the action to just be triggered once, apparently the input system is designed to be 'open-ended' which in my book means badly programmed

austere grotto
dark tinsel
#

What is the newest prod input system version? is it 1.02 ?

#

Because I encountered some bugs and I can see in the changelog that the newest version is 1.3

#

but I cannot update it in the package manager

#

nevermind, found it.
kinda hidden

dark tinsel
#

every input has a context which gets triggered 3 times

#

started
performed
ended

safe forge
#

how to I check context tho?

#

if its done by a unityevent

dark tinsel
#

1sec I saw it somewhere

safe forge
#

Oh i just put it in the parameters probably lemme test

dark tinsel
#

or just show your line where you assigned the event

#

Somewhere there you can call the context phase to be triggered on

safe forge
#

No, i assigned the event in inspector, using UnityEvents

#

should I not do that?

dark tinsel
#

oh then you are doing the same as I am

#

thats good

#

okey 1sec

#

so you're basically calling a methode in your script right

safe forge
#

yes, does the method need to have the CallbackContext parameter? thats what im about to test

dark tinsel
#

correct

safe forge
#

yeee

dark tinsel
#

heres an example:

#
public void InputProne(CallbackContext context)
    {   
        if(context.started)
        {
        // do your stuff
        }
    }
#

started gets called imidiately once you press it / or hold.
just play around what suits your needs.

safe forge
#

What namespace is CallbackContext?

dark tinsel
#

using static UnityEngine.InputSystem.InputAction;

#

if you are using vs code
just hover over the parameter with the not found namespace
and press
strg + .

#

it should give you solutions

safe forge
#

im using vs

austere grotto
#

Should be InputProne(InputAction.CallbackContext context)

safe forge
#

Got it

austere grotto
#

InputAction is not a namespace

safe forge
#

Yea, thats exactly what i did

austere grotto
#

it's a containing class

safe forge
#

InputAction is a containing class DAMN we typed the same thing

dark tinsel
#

well, it works and makes my code cleaner to read

#

hate to see that in my parameter

#

whatever suits your needs

#

While I am at it
I just switched to the newest input system version and my look methode seems wrong now.

It seems like the mouse delta isnt getting reset.
So it just keeps moving in the last direction endlessly

#

do I need to reset it somehow with the context.canceled ?

austere grotto
dark tinsel
#

its via UnityEvents and this used to work perfectly

    public void InputLook(CallbackContext context)
    {
        playerMovementInput = context.ReadValue<Vector2>();
    }

    private void Update()
    {
        yRotation += playerMovementInput.x * 3f;
    }
austere grotto
#

Just check if it's getting called for the canceled case, seems like not. Do you have any interactions or anything set?

#

And how is the action configured?

#

Value/Vector2?

dark tinsel
#

I only have a processor of a scale vector 0.05

#

correct

austere grotto
#

try pass through

dark tinsel
#

it works fine with the gamepad

#

aight

austere grotto
#

try removing the gamepad binding

#

if you have keyboard and gamepad

#

that likes to not work well together

#

just to see if that's the issue

dark tinsel
#

tested it and its not the issue
issue still exists
1sec

#

pass through didnt work aswell

#

same result

austere grotto
#

add some logging

#

see when and where the method is being called, with what values, and what phase

dark tinsel
#

so canceled isnt getting called
it just gets called once I stop the play mode

performed gets called everytime I move the mouse, that's it

austere grotto
#

wait

#

it's a mouse?

dark tinsel
#

yeah delta mouse

austere grotto
#

ohh

#

yeah I don't think that'll ever give you a cancelled

#

honestly for a "continuous" input thing like this it's probably better just to poll it

dark tinsel
#

isnt there an easier way? o.O
Why did it change suddenly with newer version
It used to reset the input once I stopped moving the mouse

austere grotto
#

Maybe it's a bug

#

idk

dark tinsel
#

no clue

dark tinsel
#

Issue previously mentioned still exists ^

My mouse delta isnt reseting its values, therefore the camera always continue to move in the last direction I moved.

#

Gamepad right stick works just fine, but mouse delta is causing me this weird behavior.
It worked fine in version 1.0.2
but atfer upgrading to 1.3.0 it stopped working properly.
same behavior in 1.2.0, 1.1.1

#
public class CL_BattleCamera : MonoBehaviour
{
    [SerializeField] private float sensitivityX;
    private float xRotation;
    private Vector2 playerMovementInput;

    private void Start()
    {
        Cursor.visible = false;
        Cursor.lockState = CursorLockMode.Locked;
        Application.targetFrameRate = 160;
    }

    public void InputLook(CallbackContext context)
    {
        playerMovementInput = context.ReadValue<Vector2>();
        // this value doesnt reset
    }

    private void Update()
    {
        xRotation += playerMovementInput.y * sensitivityX;
        
        xRotation = Mathf.Clamp(xRotation, -90f, 90f);   
    }

    private void LateUpdate()
    {
        CalculateCamera();
    }

    private void CalculateCamera()
    {
        transform.localRotation = Quaternion.Euler(-xRotation, 0f, 0f);
    }
}
mental musk
#

What am I supposed to do with this error

#

Exception 'InvalidOperationException' thrown from state change monitor 'InputActionState' on 'Stick:/DualShock4GamepadHID/leftStick'
UnityEngine.InputSystem.LowLevel.NativeInputRuntime/<>c__DisplayClass7_0:<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType,UnityEngineInternal.Input.NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType,intptr)

pliant copper
#

I'm trying to add haptics for controllers to my game. I made this IEnumerator to play haptics for a certain amount of time before stopping. However, for some reason, whenever I use StartCoroutine to call the IEnumerator, the haptics just play for a split-second and then stop, no matter how long I set the duration for. This happens even if I'm only calling it once when doing something such as pressing a button on the controller. Can anyone see what is wrong?

austere grotto
austere grotto
pliant copper
austere grotto
#

it matters a lot

#

if it's in Update for example you can end up with multiple coroutines running simultaenously

pliant copper
#

I meant that it doesn't work no matter where I use it

austere grotto
#

what also matters is the parameters you pass in

pliant copper
#

I'm not using it in update

austere grotto
#

so I'd like to see how and where you're calling it, and with what parameters

pliant copper
austere grotto
#

do you have other code that is also affecting the haptics still in your game?

pliant copper
#

No, I'm not even calling the coroutine anywhere else anymore because it's not working for seeminly no reason.

#

When I do it in update the rumble works like normal but continues forever because it's being infinitely called, so it's not a problem with my controller

austere grotto
#

make a fresh scene

#

(you can even get rid of the hasAuthority thing etc for this test)

pliant copper
#

Okay, for some reason the haptics decided to work now. I think maybe it was some sort of problem with my controller, because it was working before and then it stopped working and now it's working again. I'll just hope this doesn't happen again. Thanks for the help tho

rancid valley
#

does anyone know what this binding path was replaced with? i don't see it anymore on the options

#

nvm forgot these

honest imp
dark tinsel
dark tinsel
austere grotto
#

You could've moved on from this hours ago

dark tinsel
austere grotto
#
void Update () {
   Vector2 input = myInputAction.ReadValue<Vector2>();
}```
dark tinsel
#

That makes sense

#

ty
I think I didn't think about that because I was so used to using the Methode with the parameter which only gets called if I move the mouse

valid dagger
#

I'm trying to use the new input system to make a free-looking/rotating camera. Any suggestions?

cobalt ivy
#

is there a way of reading which button i am pushing through Unity events?

        {
            switch(context.action)
            {
                case context.action
            }
                
        }```
kind of like if im calling this inputaction through different events? so i can use different cases for each button instead of writing a lot of functions for each button
valid dagger
#

I've been wondering the same thing.

dark tinsel
#

@valid dagger @cobalt ivy
I would suggest looking up how to rebind keys, as it requires to also get the button that got pressed.
Perhaps you can get smth useful out of it.

https://www.youtube.com/watch?v=dUCcZrPhwSo 08:29 perhaps

This Unity Input System tutorial will teach you how to implement key rebinding in your project. For project files access, check out my GitHub here: https://github.com/DapperDino/Input-System-Tutorials

Multiplayer Course: https://www.udemy....

▶ Play video
valid dagger
#

Looks like it's using separate functions for each action/button.

dark tinsel
#

perhaps deep dive into that and find out how they do it code wise?

valid dagger
#

It's not a big deal for me at just the testing/prototyping phase.

#

Did I think?

#

Oh well

valid dagger
#

I have plenty of time to learn this later.

#

I wonder if eating a little mold is bad...

#

Google says it's fine.

dark tinsel
#

Bug with Delta Mouse not stopping or resetting!
In case anyone gets the same bug as me, it's an official bug now for the input system.
It happend for me when I switched from version 1.0.2 to 1.3.0.

how to fix?
Restarting unity DOES NOT fix it
you actually need to restart your whole Computer for some reason.

just wanted to type that here in case anyone is having the same problem in the future and is using the "search" function in discord! 👍

azure tusk
#

Having trouble implementing two different interactions in an InputAction: a tap and a hold, with different results from either (a dodge and a sprint).

This is the code I have in my OnDodge() function, which I'm fairly certain isn't right.

    private void OnDodge(){
        float holdThreshold = InputSystem.settings.defaultHoldTime;
        //controls.Character.Dodge.

        if (characterIsGrounded)
        {
            if (dodgeInput > 0.0f && Time.deltaTime < holdThreshold)
            {
                // For dodging (backwards)
                characterController.Move(-characterController.transform.forward * dodgeRate);
                return;
            }
            else if (dodgeInput > 0.0f && Time.deltaTime >= holdThreshold)
            {
                // For sprinting
                characterController.Move(characterController.transform.forward * dodgeRate);
            }
        }
    }
austere grotto
azure tusk
#

Sorry.

copper aurora
#

Hey, I have a problem with the new Input System. I'm working on a project, and i'm using Mouse.current to get the mouse position. But then, when my friend tries to open the project in the editor, he suddenly gets a NullReferenceException (that is, Mouse.current is null). I did some research and apparently it the input system does this weird stuff on laptops (which is exactly what's happening here). Any idea on how to fix it?

silent creek
#

Yea, i have the same problem. Did anyone can solve this yet?

austere grotto
#

You can't use Mouse.current safely if you are planning on your game running on devices that don't have a mouse.

#

You should check if Mouse.current is not null

#

But really you should try to avoid reading input from devices directly

#

Instead, use Input Actions

copper aurora
#

Sounds reasonable. Then how can I read the mouse position from the input actions?

austere grotto
#

You make an input actions asset

#

create an action that is bound to the mouse position

#

and read it in your code in one of about a dozen different ways 😛

copper aurora
#

Alright, and should I maybe use "Pointer" instead of "Mouse"? I mean, touchpads in laptops are sadly a thing, and idk how Unity handles those

#

We also have a problem that for some reason, my friend (on laptop) is unable to click UI buttons, while I (on PC) can do it just fine. Any idea on how to fix that?

mental musk
copper aurora
#

The thing is, it works fine on one machine, but doesn't work at all on the other machine. The project was recently synced, so it should technically be the same on both devices. Yet the laptop struggles where the PC does not, and i'd guess it might have something to do with the Event System that is made to be working with the new Input System

#

And similar issue is occurring with the rest of input system - the laptop doesn't want to detect any movement, no matter if mouse is connected or not, no matter if the touchpad is disabled or not

neat quail
#

I think this is where I should ask this question

#

I'm not sure how to fix this

#

I think it happened because I changed the file name

sullen lintel
neat quail
#

How can I fix that?

#

It has the same name in my files too

sullen lintel
sullen lintel
neat quail
#

The only error I have in console is just the same thing

#

The file cannot be found

sullen lintel
neat quail
#

Oh I see

#

I think that worked? The console error is gone

neat quail
austere grotto
#

Does the name of the class match the filename of the script?

neat quail
#

It does now

#

It won't go away though

austere grotto
neat quail
#

Just did

#

It's working now

#

Thanks

sudden inlet
#

ok sorry if this is a stupid question but im getting an error that Input doesnt have a definition for getAxis()?

mental musk
sudden inlet
mental musk
#

Sure you're welcome

sudden inlet
#

turns out i didnt configure VS to work with Unity.

azure tusk
austere grotto
#

You also need to separate the logic into a start dodging bit and a _check if still dodging _ bit

azure tusk
#

Granted, I'm also trying to use these interaction parameters:

reef summit
#

Hey I'm having an issue with mouse scrolling. When I scroll one tick on my scroll wheel, it calls the appropriate function twice instead of once

austere grotto
#

started/performed or performed/canceled

reef summit
#

i added context to started and nothing else

austere grotto
#

wdym you "added context to started"?

#

show your code

reef summit
#

hang on

#

here @austere grotto

heavy rivet
#

Hi I am working on a game right now and I'm having a little trouble and no videos I've seen can really help I'm not sure if its the "new" input system but I can't get my doors to work even if I put them on a hinge I couldn't make it open with an interact button or anything also the player can literally just walk through the door ignoring the collider? I'm doing something very wrong just not sure what

sullen lintel
#

sounds more like an issue with colliders and rigidbodies though

heavy rivet
#

This is the most current code that I was trying to use I changed the input system to both because of the Input.GetKeyDown kept making it pop up errors

sullen lintel
heavy rivet
sullen lintel
#

dont put input reading in fixedupdate

heavy rivet
#

I changed the Character input to have an interact button too and it didn't seem to work i hit play and it worked one time but not the next play

sullen lintel
#

@heavy rivet also you want to use collision.gameObject.CompareTag instead

sullen lintel
#

FixedUpdate occurs every physics update

#

@heavy rivet please post this on #💻┃code-beginner to get more people to see on this, also post useful screenshots of your inspector window too

heavy rivet
#

Thank you

fossil walrus
#

Hello ! I'd like to show these WASD bindings (One text for each) and to do so I add in my prefab's script a specified InputBindingComposite CorrespondingBind to say which one it should shows

I can't find a way to access the inputs of a Vector2, anyone knows how to ?

warm latch
#

Hello. With Unity and a Quest2, I am trying to develop an application that evaluates the pose of the user's head without relying on the images from the Quest's cameras. In other, I need to access the raw data from its Accelerometer and gyroscope. In my use case, the images from cameras wouldn't be relevant at all to evaluate users'pose.
But I haven't found any way to get those raw data.
Is it possible?

pulsar mist
#

I have a door, which can be focussed on through PlayerLogic. But now I want the door to temporarily subscribe to the user inputs so that I can use the mouse scroll wheel to open / close the door. What's a good way of doing so? And is temporarily subscribing to inputs on a gameobject a bad practice?

fossil walrus
#

You can look at the Command pattern

pulsar mist
spark pumice
solid kraken
#

why is Input.GetAxisRaw() Not working

#

it doesnt reference it as a built in thing

austere grotto
#

Are you getting some kind of error? Explain a bit more

solid kraken
#

nvm

viscid garden
#

I currently have the cursor changed to a aiming sprite, but when I switch from mouse to gamepad, I thought the best strategy would be to then start moving around a secondary(duplicate) aiming sprite based on the gamepad input. This means I have to deal with the cursor image, and the secondary duplicate aiming sprite. But ideally i'd rather have the right stick of the gamepad & the mouse both move just one, so I dont have to have two images that I turn one off/on based on gamepad usage.

What's the best way to do this?

tame oracle
#

and I want the solution to be expandable, so if I ever want to add IJKL for input it wouldn't take much

#

but in practice I get some key press ghosting which is not present when I only use Player Input with a single control scheme

mental musk
fossil walrus
#

Hello, is it possible to self send a performed event on a specified action ?

#

In code and in run-time

molten nest
#

So I'm using the send message style of control input (because of it's ease of use with local multiplayer) which will duplicate a given player gameobject whenever new input is detected to create an additional character. Is there an intuitive way to select that gameobject instance to write data into it (such as player index, color, etc) without resorting to having an auxiliary script watching the root where player objects are created and writing data into them? Honestly I'm just curious what the proper data structure is for this and that's the best way I could think how but I could be way off the mark here.

jovial pasture
#

guys idk what's wrong when i add this script to my player unity crash

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

public class camemove : MonoBehaviour
{

    public float sens;
    public float xrot;
    public float yrot;
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        xrot += Input.GetAxis("Mouse X") * sens;
        yrot -= Input.GetAxis("Mouse Y") * sens;
        transform.eulerAngles = new Vector3(yrot, xrot, 0);
    }
}

and i have a camera connected to the player

austere grotto
#

I doubt this script is the problem

sweet crown
#

Hopefully this should be quick i installed the new unity input system package and restarted unity but i tried importing it in a script and it is saying the namespace doesnt exist. Any fixes for this?

devout panther
#

In the experimental version of the new input system, you could declare input systems as public/private InputMaster (I am following the brackeys tutorial to learn it) but I don't think this works anymore. Does anyone know what the new version is if there is one?

austere grotto
austere grotto
sweet crown
#

im pretty sure my ide is configured and i already tried regenerate project files with no luck

devout panther
austere grotto
devout panther
#

let me figure this out quick

austere grotto
#

Reread what I said it has all the information you need

devout panther
#

okay

#

Sorry for my noobiness

#

I see

#

Thanks

#

I got it working

#

this has some weird syntax

nova fractal
#

Hi everyone, could someone possibly help me work through an implementation that is tying me in knots? I think I might be using the wrong kind of inputs but I just don't know.

In a nutshell, the game has guns - some are semi-automatic, some are fully automatic.

I have created a single 'Fire' action, given it the 'Button' action type, and added a 'Press and Release' interaction (so that the full auto gun can stop firing on release and start firing on press - or fire a single shot on press for a semi auto)

However, how would I check whether the button is being pressed or released in code? I can't seem to find the syntax anywhere.

nova fractal
#

presumably the button still returns a value between 0 and 1?

subtle knot
#

how can i get the inputs from my snes controller

#

usb snes controller

austere grotto
#

Get rid of all interactions

#

Listen to started and canceled to get the press and the release

opal blaze
#

Should i use a binding in input action with new input system or use Mouse.current.leftButton.wasPressedThisFrame to get left mouse clicks in world?

austere grotto
#

Making an input action will make it easier to rebind it etc. If you don't care about that, it's fine to use the other way

undone shard
#

I've created a dash mechanic using a button, but whenever I start pressing the button, it doesn't change canDash to true. However, if I replace canDash = true with a print statement, it does actually run. Why is it not allowing me to dash/always calling canDash false?

austere grotto
#

Why are you adding event subscriptions here?

#

Also canDash is just a local variable so none of what you're doing really matters

#

You need to make it a member variable

cold hollow
#

hi guys, im following along a unity tutorial on youtube and im running into this issue, does anyone know a fix

mortal ridge
austere grotto
# cold hollow

Just some simple spelling/capitalization errors on your part. Get your IDE configured

cold hollow
#

thanks guys

solar sand
#

Hey I'm trying to get my player to jump and after everything works but I can't get it to jump when it takes the "Player Controller" as the Input Controller. However it works just fine using the AI Controller so I know it isn't any of the variables that are wrong. Why isn't it letting me input as a player?

#

My code uses GetButtonDown("Jump") to to get the input and I already checked in the project settings that I'm pressing the right button

austere grotto
#

You'd need to share a lot more details than that. Nobody knows what "Player Controller" or "AI Controller" you're talking about.

solar sand
#

Oh right

#

I have an InputController script that provides the basis for two scriptable objects: Player Controller and AI Controller. The code looks like this

#

The both controllers override the methods, but while the AI Controller just uses default values, the Player Controller gets input

#

The both the move and jump method are then called in their own scripts. While movement works completely fine, jumping doesn't

#

So I think that Unity is somehow not getting my input but only when I get the jumping input?

austere grotto
solar sand
austere grotto
# solar sand

and what do you do with that desiredJump value? You'd have to make sure you use it immediately that frame

#

Since it's a GetButtonDown, it will turn false the very next frame, since you're reading it into that variable every frame

solar sand
#

It's used in an if statement in FixedUpdate

austere grotto
#

you need to do this:

void Update() {
  if (input.GetJumpInput()) {
    desiredJump = true;
  }
}```
OR a little more advanced with the same result...
```cs
void Update() {
  desiredJump |= input.GetJumpInput();
}```
#

This is because FixedUpdate doesn't run every frame

#

so you can miss that one frame where it's true if you just blindly assign that input value into the bool every frame

#

the higher your framerate is, the worse that effect will be.

solar sand
#

Ah ok

#

Can I ask how does the |= operator work? I've never seen it before

austere grotto
#

In this case | is just the "logical OR" operator

#

it returns true if either desiredJump is true or input.GetJumpInput()

#

In english... it just says "make desiredJump true if it already was true, or if there's a jump input this frame (or both)"

#

otherwise it stays false

solar sand
#

Thanks

viral herald
#

Anyone know if this is a bug? I'm using EnhancedTouch w/ mouse simulation in update(), and sometimes it will skip the Began phase, but then call it multiple times equal to the times it skipped with only one Ended phase (so multiple touches beginning all ending on one phase). Its like the Begans are weirdly stuck and then somehow repeat sequentially. The active finger count is always only 1 during this, so it's not multiple fingers or anything (and again this is with a mouse in the player so that shouldn't even be possible).

#

I'd be less confused if there were equal Ended phases, but all those Begans that happen on sequential frames with a single Ended. If I click 3 times with no Began phases appearing, the 4th time will have 4 Began calls across 4 frames (the exact number to trigger this seems to change randomly, and it sometimes works properly)

nova fractal
#

All those += and <= thingies are totally new to me, feels like i'm going to have to strip out a lot of my old code to fix it up 💀

tame oracle
#

and it gives me this in the input debugger if I setup 2 control schemes with a optional keyboard device

#

and if I disable control schemes both characters move the same way and both react to wasd and arrows

fathom thunder
#

Hi, I started implementing a playerInputController which alternates between actionmaps (for example between gameplay and UI). At the beginning I put the script on the GameManager object in the scene, now I realize the script belongs to the Player object. But when on the Player object, the script isn't able to turn off the gameplay actionmap when changing to the UI screen (player is still moving when navigating UI) but on the GameManager it works as intended.

Why is the script able to turn off an actionmap on an object and not on the other?

tame oracle
#

plus if I use input manager for only bindings, like you said, it only spawns one character

tame oracle
fathom thunder
#

So, why would a script work on an object not on the other, and after deleting it from the first object and putting it back again, it doesn't work anymore?

tame oracle
#

did you use any event subscriptions ? I belive those subsist after game stop

fathom thunder
#

Maybe if I restart unity it works back again

fathom thunder
tame oracle
#

so basically you have to delete those on game stop

fathom thunder
#

you mean like -= and or Disable() right?

tame oracle
#

ye

#

same way you add them

fathom thunder
#

the thing is....IT WORKED

#

by placing the script on another object, it didn't work anymore

#

by deleting the script from the original object that used to work, and putting it back on, it stopped working

#

you see my issue?

tame oracle
#

probably because you broke the event link and or changed the code inbetween

fathom thunder
#

Yes I guess🥺

tame oracle
#

restarting might fix it

fathom thunder
#

I don't think unity is playing a prank on me, I guess....?

#

yes ridiculous

tame oracle
#

but if the code still adds event subscriptions without removing them you will encouter it again

fathom thunder
#

i restarted it and it workd with the original object

#

🤦‍♂️

#

no lets see if I restart with the other obejct

tame oracle
#

modify the code and in awake add Object.RemoveAllListeners()

#

so now you clean all the past links and make sure to add it too OnApplicationQuit()

fathom thunder
#

I will try this, thanks a lot 👍

tame oracle
#

You-re welcome

tame oracle
#

Does anybody know how to do split-keyboard with the new input system ?

surreal moth
#

Using New Input system, I have it set up for WASD controls, but it will only read a single of the 4 keys, and wont do diagonals from two keys held. If you press another key while holding the first and then let go of the first, it will continue to input the vector of the first and I'm not sure why

#

How do I figure out what's going wrong?

#

I debugged the value but the value doesnt change when I change keys held unless I fully let go of all keys first

spark pumice
austere grotto
#

show us:

  • The Input Action(s)
  • The bindings
  • The PlayerInput component (if there is one involved)
  • Your code
surreal moth
#

With further debugging it looks like its not sending a new vector, after I press a single key, it sends it once and stops.
Sure let me get those screenshots

#

digiMovDir doesnt get set every single frame the key is held

#

I copy and pasted this code from my own unity project and it worked there so I am confused why it doesnt work here despite nothing changing

austere grotto
surreal moth
#

W+A shouldnt be "faster" than W or A individually

austere grotto
#

try letting it be whatever the default is and just do digitalMovementDirection = context.ReadValue<Vector2>().normalized;

surreal moth
austere grotto
#

can you show the input action setup

#

PlayerInput is sometimes finicky about whether to send the events for "cancelled" to zero out your vector

surreal moth
#

I'm not sure which thing refers to the input action setup
Is it this?

austere grotto
#

no

austere grotto
#

just click on MoveDigital itself

surreal moth
austere grotto
#

change Action Type to value

surreal moth
#

Ahh it is a button, I bet in my other project its not

austere grotto
#

and Control type to Vector2

surreal moth
#

That figures, when I coped it over I had to remake it by comparing the values, I likely didnt realize/remember that I made this change to the input type

surreal moth
surreal moth
# austere grotto and Control type to Vector2

Sorry to bother you again but I switched over to the other project, where I got the original code from.
In that other project, it WAS working, but for some reason all my copies of unity are completely fucked up, someone in Unity-Talk told me to delete my Library folder, and after doing that, now the input system is totally broken and I have no idea why or how to fix it.

This one's move buttons ARE set to value and Vector2, all the same exact code, but this one is behaving like a Button, not like a value

#

Debugging the value shows that its acting like a button not a value, it sets one single time on initial press

#

but its not set to button, at all

#

how would deleting library affect new input system?

#

Is there steps I need to do to regenerate this?

austere grotto
surreal moth
#

Im not sure which thing refers to an interaction or a binding

#

Unity told me to change my unity version to a newer one, I just wiped out my project and github pulled the pre-changed one, Input is working again there

#

Except

austere grotto
surreal moth
#

I cant tell you WHY its working because its set to button

#

so as far as I know it shouldnt be working, but it is

surreal moth
austere grotto
surreal moth
#

You may have told me to and either did it and turned it back, or never did it, because its set to normalized atm

#

Its also set to button, which means none of this should be working, but it is working

#

and thats concerning

#

I cant explain it and I cant figure out why its working in 2020.3.13f1 but not in 2020.3.32.f1'

austere grotto
#

It's certainly possible that there's differences

#

IDK

surreal moth
#

me either

#

Ill go back to trying to fix my FPS toilet and revisit this after

exotic badge
#

anyone have experience with hooking up a hotas to the system

grave birch
#

How do i use the keys

#

input action wont work

austere grotto
#

You can't have fields outside your class

#

That's a basic C# thing, nothing to do with the Input System itself

grave birch
#

How do get the axis of mouse x / mouse y with the new input system

gleaming harness
#

Hello everyone, is there any way to trigger an Input Action from the UI Toolkit? Like, I have a 'Travel' Input Action which is executed on 'T' key presses, I'm trying to do something like "travelButton.clicked += simulateTKeyPress;" or any way to do the same Input Action from a UI Toolkit button, all the info I can find is related to canvas/old ui and can't understand the documentation pretty well, any tip would be appreciated, excuse is my english is not perfect and thank you for the help!

grave birch
#

How do i assign a task to a button in inptu sustem

austere grotto
austere grotto
austere grotto
grave birch
#

key board button

#

like w

#

a sd

gleaming harness
# austere grotto wdym by "task" and "button" in this context?

Okay, so from input handling code I would call something like this, because the performed callback needs a callbackcontext right? I made it public to call the same method from the UITK, and passed a 'new InputAction.CallbackContext' from the button.clicked callback since I dont have a context there, do you think that I'm doing this correctly?

austere grotto
#
void Travel() {
  Debug.Log("Travel");
}```
#

Then you call that in both places

#
public void DoTravel(InputAction.CallbackContext ctx) {
  Travel();
}```
#

likewise, you call Travel() from your UITK stuff

gleaming harness
#

Awesome, thank you so much @austere grotto !

south cypress
#

I have posted this questions in two threads but I think this might be the appropriate place to ask. I do apologize if I make anyone feel like I'm spamming.
I'm currently playing a strategic match-three game so I want to create a piece of software that can quickly receive input from the game and test the moves so I can see what the board will look like after I make a certain move. I think the base of this software is a 8x8 match-three game in Unity but I don't know how to quickly provide input for it. What methods would you recommend to quickly transfer the board from the game to my software? Thank you very much.

austere grotto
#

Oh wait you;re saying... there's some existing built game and you are trying to write a program in Unity that plays that game?

#

also I don't see how this is the right channel for this at all

south cypress
#

I thought it's about input?

#

sorry, then I'll leave

#

thanks

wild rover
#

Hi im having an issue where I am pressing a button and a function which is assigned to a different button is being activated instead of the function assigned to the button im pressing. is there any way i can fix this?

austere grotto
#

or wait unless you mean keyboard button?

wild rover
quartz copper
#

how would I make it so a inputs method would run over and over while its being held down

austere grotto
#

Use Update

#

either:

  • poll the action in update:
InputAction whatever;...

void Update() {
  if (whatever.IsPressed()) { ... }
}```

Or use events:
```cs
void MyHandler(InputAction.CallbackContext ctx) {
  if (ctx.started) isHeld = true;
  else if (ctx.canceled) isHeld = false;
}

void Update() {
  if (isHeld) ...
}```
quartz copper
#

ty

#

New Input System: Does The Mouse Scroll Wheel Go by Scroll(Mouse)? If it does what value do i use for it? I tried using double and it just get getting 0

quartz copper
#

this is input sytstem

austere grotto
peak peak
#

Hi, i'm trying to find either the pointerdata or raycast result for current hover, or the currently hovered gameobject. So far i found that i had to override InputSystemUIInputModule, copy the internal corresponding editor logic and override UpdateModule(), where i check GetLastRaycastResult().
The problem here is that it is documented everywhere that the pointerid should be negative for mouse input, but for me the pointerid is 2,
which makes me think that whatever i build upon this will at some point behave unexpectedly.
So my question is, is there a better way to get the result i need and if not, how can i get a consistent or reliable pointerid ?

cyan shoal
#

heya

#

cant find any real information on this

#

how can i get the mouse's world position with the new input system?

austere grotto
#

the ways to convert that to world space are the same as they always have been

cyan shoal
#

oh

#

awesome, thanks a bunch :)

lavish crystal
#

if there a way to know when an action is performed and when it stops?

delicate pollen
#

Bit confused, folks - I'm trying to detect a double-click-and-hold, but detecting a multi-taps only seems to detect the start of the double-click (ie. each single click) and when the double-click has been released. Any clues?

austere grotto
delicate pollen
austere grotto
# delicate pollen

You can't count on those WasPressedThisFrame etc functions for complex interactions

#

Those are basically for basic buttons only

delicate pollen
#

Oh.

#

Hmm. Okay, back to the docs, then.

austere grotto
#

Check if it's in the performed phase

#

Or listen to its performed event

delicate pollen
#

So that would be the performed event of MouseRghtClickDouble, right?

lavish crystal
lavish crystal
#

should i use an if statement to say if started then change this and same for canceled?

delicate pollen
#

Still can't seem to get Unity to recognise a double-click-and-hold... =/

#

I can't test for the double-click-and-hold because I seem to need to release (cancelling the 'hold') in order to register the double-click.

#

Should I just assume this is impossible for the Input System? Seems like a simple timer testing for two 'started' events would fix it, but I could be missing something.

whole mist
#

I want to replace the old input system with the new input system (The script uses Input.GetAxis(Axis)) which the best choice two axis or one vector 2??

sullen lintel
whole mist
whole mist
#

I have a button for jump how I can get the equivalent to the GetKeyUp and GetKeyDown??

whole mist
#

I have something like that

#

how I can integrate it to this?

sullen lintel
#

well idk it's different everyone uses a diff method. I'm still not used to it completly , i'm using a simple boolean with sendmessages in my inputs class cs public void OnJump(InputValue value) { JumpInput(value.isPressed); }

#

then i docs public void JumpInput(bool newJumpState) { jump = newJumpState; }

#

so for me is simple if(inputClass.jump){//dooJumping}

#

@whole mist I learned this a year ago from one of the Unity projects, so not sure, maybe someone else has a better answer . Hope it helps

whole mist
#

ok thanks

viral herald
#

Anyone know if there has been any update regarding the Input System Mobile/Unity Remote situation? Everything i found was like 2 years ago saying SoonTM

red widget
#

There we go, I'm on the Docs now and I can see it

#

It's the "Add Positive/Negative option"

ivory moss
#

what a bout the pos/neg i want it to be keyboard

red widget
#

Wait no, that makes it a 1D vector

#

You need a 2D vector, which is the "Add up/down/left/right composite" option, which you seemingly don't have

#

Can you select the Movement action and see if you can change its type from Button to anything else

ivory moss
#

whatt

#

found it

whole mist
#

How I can modify this Input with the new Input System

whole mist
#

I found the solution

gilded moat
#

hi so im trying to fix an issue where after you stop pressing keys to move for a second or 2 you still glide slowly decreasing to come at a stop at whole. how an i fix that. i tried increasing friction but my game has platforms and its hard to get on slanted platforms

jade aspen
#

is there a way to simulate touch input from a mouse using the new unity input system? when i enable it it starts throwing pointer should have exited errors

whole mist
#

Does anyone knows how to convert that to the new Input System?

rare siren
#

Whenever i press the gamepad actions, i am not able to use the keyboard actions, so they dont get called. before i hit a key, keyboard actions are working fine. any idea why?

austere grotto
#

that might be contributing

rare siren
#

i split keyboard and gamepad because i need that the keyboard controls can only move horizontally in a range of -0.5 to 0.5, while the gamepad can -1 to 1

#

processors on the binding action itself did not work somehow

austere grotto
#

I understand that I'm saying the gamepad binding doesn't need to be a composite binding

rare siren
#

you mean that i can put them together in one composite binding?

#

but then i do have the problem i mentioned above

austere grotto
#

No

#

I mean the keyboard uses its own composite

#

And the joystick just has a normal binding for Left stick/horizontal

rare siren
#

i dont understand what you mean. can you name an example?

#

@austere grotto

austere grotto
rare siren
#

composite is a default property, i cannot remove it

austere grotto
#

I have no idea what you mean by that

stark notch
#

Did the new input system have a way to easily find which control scheme is currently used? like if i have a Keyboard&Mouse or Gamepad control scheme, i would like to do some code differently depending on the control scheme currently used by the player

#

Mostly for stuff like aiming with a mouse or the stick

devout panther
#

Is there any way to disable a single action in the input system?

austere grotto
#

Yes InputAction has a . Enable and Disable methods

devout panther
devout brook
#

hypothetically speaking if you were going to use a special input registry common in fighting games IE: ⬇️ ↘️ ➡️ punch = fireball, how would you go about implementing that?

lofty girder
#

so i updated to the new input system but it seems there is no way to reference it in code

#

fixed it

lofty girder
#

is there a way to rebind these directly through code?

mental musk
#

In the Last of us 2 you can shake the ps4 gamepad to toggle the flashlight. Is there a way to detect that in Unity as well or is it some sort of license you need to buy from Sony

surreal moth
#

I am getting this error with the new input system and I'm not sure how to fix it. It says something is null but i'm not understanding what is null. The input action isnt null afaik

#

Double clicking it to find out where/what is null doesnt open visual studio

surreal moth
lofty girder
#

How do i get a 2D vector binding through code and how can i change it at runtime

gaunt salmon
#

How do I properly dispose of the actions from a previous scene that I've listened to? OnEnable for a script I assign an action like so: _rollAction.performed += OnRoll; and OnDisable I remove it like so _rollAction.performed -= OnRoll;
But when I switch scenes I sometimes experience the action calling from the previous context and failing due to null reference exception

austere grotto
#

Maybe share an actual example of an NRE you're getting and the corresponding code?

gaunt salmon
#

No need, thanks for confirming that is correct. For anyone else that may stumble upon this issue, I just fixed it by ensuring that the Disable code above was called after the Enable code. I had an InvokeRepeating function that was enabling the input actions just after I had called to switch scenes, so I just cancelled that and it worked

onyx shuttle
#

I seem to be having trouble figuring out how to get a touch position return from an input path that also performs a cancel call when the touch is released. Is anyone able to help out with how that can be done from one action?

austere grotto
#

Why are you trying to do that from one action

jade aspen
#

is there an on touch up event in the new innput system?

jade aspen
#

Thank you!

onyx shuttle
#

Basically, I made a click and drag for mouse and keyboard. I always have the mouse position from Drag(). But now I'm updating it for touch, and only have the touch position at the time of touch. I need that initial position before the execution of my main method, Click(), but the order is sometimes random, so i get bad results.
So, now I need to make sure my Drag action is called before Click action each frame they both occur

lofty girder
#

does upgrading to the new input system makes OnMouseOver and OnMouseExit stop working?

austere grotto
#

they are not supported in the new input system

#

you should migrate to IPointerEnterHandler/IPointerExitHandler

lofty girder
#

yeah discovered it by noticing one thing in my game suddenly not working anymore

robust harbor
#

How to read "Jump" Action as a trigger when subscribing to his events ? I don't like the idea of checking WasPerformedThisFrame() in Update. Is There a better solution?

austere grotto
#

Subscribe to the performed event

robust harbor
#

it will set bool to true but i want to let bool act like a trigger.

perfomed => true then false

austere grotto
#

IDK what you mean

#

your subscription code will do whatever you want

#

you don't have to set something true there

#

you could have it call the Queen of England if you have her phone number

austere grotto
#

something like that

#

or just...

void HandleJumpInput(CallbackContext ctx) {
  rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
}```
#

¯_(ツ)_/¯

robust harbor
#

No, thats ugly for me.

    public event Action IsJumped;
    public bool JumpInput;

private void OnEnable()
    {
        _jumpInput.action.performed += OnJump;
        _jumpInput.action.canceled += (ctx) => JumpInput = false;

    }
private void OnJump(InputAction.CallbackContext ctx)
    {
        IsJumped?.Invoke();
        JumpInput = ctx.ReadValueAsButton();
    }

Came up with this solution

austere grotto
#

huh

#

how is that a soluition? What does it even do? What if you release it before the jump is actually performed? The jump won't happen

#

what's the point of JumpInput = ctx.ReadValueAsButton(); - you already know this is a performed call

robust harbor
austere grotto
#

that's not really going to be feasible when the jump input thing is something that needs to be consumed by the jumping code

robust harbor
austere grotto
#

you will need to.

#

regardless with my example the FixedUpdate doesn't need to be in the same class as the input callback

#

it was just an example to illustrate how the "trigger" behavior works

#

you consume the user intent when you do the jump

robust harbor
#

I could just

public bool jumpInput

private void Update()
{
  jumpinput = false
  if(jumpAction.WasPerformedThisFrame())
  {
    jumpInput = true;
  }
}

austere grotto
robust harbor
austere grotto
#

Just be careful it depends how you are using this. If you read this value in Update somewhere else it will be ok. If you try to read this in FixedUpdate it won't work reliably.

robust harbor
#

Is read input in FixedUpdate wrong? When do you need to read input in FixedUpdate?

austere grotto
#

Reading update like this in FixedUpdate is wrong because FixedUpdate doesn't run every frame

#

WasPerformedThisFrame will only be true for exactly one frame

#

so if FixedUpdate doesn't run on that particular frame, you're out of luck

robust harbor
#

Ok, you didn't understand my question, nevermind. Thanks for help

onyx shuttle
# robust harbor Ok, you didn't understand my question, nevermind. Thanks for help

It's not that you would need to read the input in fixed update, it's if you need the input result for physics related actions.
Since jumping typically involves physics, that would be checked in FixedUpdate. However, you would need to check the input for that. You would get bad results sometimes since FixedUpdate is not run every frame.

timber robin
#

The answer was yes (it's wrong), and never (in FixedUpdate).

#

Not sure how the above answers didn't read that way though, they clearly say the same thing with much more detail.

#

Saves the inevitable "why" response.

onyx shuttle
#

Some people can't read context clues, especially if English isn't their first language and they're communicating in English.

#

Not saying it to be mean, it's just how it is sometimes

timber robin
#

Always can ask to clarify rather than dismissing the answer as not having understrood the question.

onyx shuttle
#

Very true

robust harbor
#

Yes, I'm not a native English speaker but i know that read input in FixedUpdate is not a good idea.

onyx shuttle
#

Btw, does anyone know if I'm able to force the event order of actions that occur in the same frame?

robust harbor
#

My question was to look if I don't see some secret techniques that involves trying to read input in FixedUpdate. But anyway, thanks for conversation

austere grotto
onyx shuttle
#

Dang, might need to resort to 1frame delayed coroutine if I don't want to refactor my entire script 😅

onyx shuttle
onyx shuttle
#

hmm.. I also seem to be having trouble figuring out how to get the specific action cached like you would in your example. I've got the input component cached, but can't seem to go further.
I'm asssuming I use the actionMap with a string of the action name?

austere grotto
#

There are many ways to approach using the new input system, all with differences in how things work

onyx shuttle
#

I've got the PlayerInput component attached to an object with the action asset referenced.

#

I just recently started learning this system and this was how I learned to do it 😅

austere grotto
#

ok so PlayerInput is what you're talking about

#

that's a very specific thing

#

PlayerInput is meant to be operated in one of three modes - you've selected Invoke Unity Events

#

so it will call the functions you set up inside the > events foldout there in your inspector

onyx shuttle
#

Yup, got that part. So I'm guessing your example doesn't work with this setup?

austere grotto
#

no not really

onyx shuttle
#

😩

austere grotto
#

You can still get at the input actions from a PlayerInput

#

but it's cluckier

#

clunkier**

onyx shuttle
#

ya, I'm realizing that as I go down this rabbit hole of properties lol

austere grotto
#
PlayerInput pi;
InputAction jumpAction;

void Awake() {
  pi = GetComponent<PlayerInput>();
  // this is <action map name>/<action name>
  jumpAction = pi.actions["Player/Jump"];
}```
onyx shuttle
#

Oh, so the string is the path like from ctx control path?

austere grotto
#

not sure what ctx control path is

#

it's <action map name>/<action name>

#

from your Input Action Asset

onyx shuttle
austere grotto
#

no it's different

onyx shuttle
#

Ya, figured that out 😅
Thanks for the help

austere grotto
#

an alternative is simply don't use PlayerInput

#

I like to use InputActionReference

onyx shuttle
#

Unfortunately this is the only way i know how to use the new InputSystem and everything is almost done already 😅 The only thing it doesn't work for is touch support. Mouse and keyboard works exactly as intended

austere grotto
#

you can do this:

[SerializeField] InputActionReference jumpRef; // assign this in the inspector to the correct input action

void Update() {
  if (jumpRef.action.WasPressedThisFrame()) ...
}``` etc
onyx shuttle
#

But i will keep it in mind for next time i use the system

austere grotto
#

There are many ways to use it

#

it's very flexible

#

which unfortunately can be intimidating if you're new to it, because there's a lot of confusing options

onyx shuttle
#

Ya, I was very used to the old system, but my partner wanted to use the new system for a reason that I forgot and it was about time I learned it anyway.
Just gonna take some time

tardy geyser
#

Hey, how can one integrate controls from input devices like a drone transmitter in unity?

livid glade
#

Can someone help me with the new input system? I've used it before, but now I'm in a new project and it's seemingly not working for no reason. Here is the script I'm using to read the input:

using UnityEngine;
using UnityEngine.InputSystem;

public class CharacterController : MonoBehaviour
{

    CharacterInputs characterInputs;
    CharacterInputs.DefaultActions actionMap;
    InputAction movement;

    Vector2 moveVector;

    Rigidbody2D rb2d;

    void Awake()
    {
        rb2d = GetComponent<Rigidbody2D>();

        characterInputs = new CharacterInputs();
        actionMap = characterInputs.Default;
    }

    void OnEnable()
    {
        characterInputs.Enable();
        actionMap.Enable();

        movement = actionMap.Movement;
        movement.Enable();
    }

    void FixedUpdate()
    {
        moveVector = movement.ReadValue<Vector2>();
        Debug.Log(moveVector);
    }
}
#

Here is the asset:

#

It's auto-generating a script

#

Is there some setting somewhere that would disable the new input system? I looked at my old project, this is EXACTLY how I have it in that project but it works there and not here.

#

Also these are literally the only two assets in my project (besides my scene). I just attatched my movement script and a rigid body and a capsule collider to a simple capsule sprite in the game and made a rectangle for the ground.

austere grotto
#

right now you're showing the binding

livid glade
#

What do you mean the actual configuration?

austere grotto
#

Click on Movement

#

in the input action asset

#

to show the configuration for the Movement action

#

also can you explain what you mean by "it's not working"? What is happening that differs from your expectation?

livid glade
#

Oh sorry. moveVector always reads 0,0

austere grotto
livid glade
#

Yes, give me a few minutes I will give a screenshot. It might be a little bit though. Should I @ you when I do?

austere grotto
#

sure

livid glade
#

@austere grotto

austere grotto
#

whatever the normal thing is (I forget)

livid glade
#

Yea i’ll try. Its weird though because that’s how i have it in my other project

#

Does my script doesn’t look like it’s the problem right?

austere grotto
#

maybe also try reading the input in Update instead of Fixed?

livid glade
#

Yea i tries that too, didnt do anything

austere grotto
#

silly question but did you enable the backends for the new input system in this project?

#

Edit -> Project Settings -> Player -> Active Input Handling is set to Input System (New)?

livid glade
#

yes I did. I actually clicked the button that was supposed to to that automatically, but it wasn't done. I had to manually do it. Is it possible there was something else that was supposed to be enabled?

austere grotto
#

when you did it manually

#

did it ask you to restart Unity?

#

And did you do so?

livid glade
#

before I asked for help here and it restarted unity by itself

austere grotto
#

the only other thing I can think of is something with control schemes?

#

I don't really know how control schemes work and sometimes they trip things up

livid glade
#

by the way this is what you're talking about right?

#

in the player settings

austere grotto
#

yeah that's right

#

looks good

livid glade
#

I deleted the control scheme and it still doesn't work

#

like im stuggling to understand why it wouldn't work if I have everything exactly the same as in my other unity project. Is it the version? I'm on unity version 2021.2.3 with input system v1.1.1

#

the other unity version was 2021.2.13

austere grotto
#

I wouldn't put "unity bug" out of the realm of possibility

#

maybe try upgrading the project to the latest LTS version

#

which coincidentally was released today: 2021.3.0

#

(after taking a backup or committing to version control)

livid glade
#

I'll try converting to 2021.2.13 since I don't have to download that, and my other project works in 2021.2.13

livid glade
#

it works in the newer unity version

tame oracle
#

I don't know if this is directly an issue with the input system, but I might as well ask here. I've got a function to shoot my gun, but sometimes at random times, when I click the gun will shoot infinitely (until it runs out of ammo or you press the mouse button again), and I've got so many checks to see if the mouse is really being pressed, I've got no idea here.

void Update()
{
    if(Input.GetKey(KeyCode.Mouse0) && currentBullets > 0 && reloading == false)
    {
        if (Time.time - lastfired > 1 / fireRate && Input.GetKey(KeyCode.Mouse0))
        {
            lastfired = Time.time;
            Shoot();
        }
    }
}

void Shoot()
    {
        if(Input.GetKey(KeyCode.Mouse0) && currentBullets > 0)
        {
            RaycastHit hit;
            if(Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
            {
                Debug.Log(hit.transform.name);

                StartCoroutine(bulletHole(hit));
            }

            shootSound.Play();
            muzzleFlash.Play();
            StartCoroutine(illuminate());

            recoil_script.RecoilFire();
            weaponHoldRecoil.RecoilFire();

            currentBullets--;

            shellParticles.Play();
        }
    }
tame oracle
#

long script lol

tame oracle
tame oracle
austere grotto
#

Once a frame?

#

Or it's just continuing to shoot once a second until the ammo is gone

tame oracle
#

I've got it at 10 shots per second

austere grotto
#

oh right firerate

#

yeah that's what I mean

#

is it shooting 10 per second still

#

or it's shooting really fast, like once per frame

#

Basically I'm asking if your issue is that the game thinks you're just holding the mouse button down, or if the timing part of your script is not working

tame oracle
#

When it goes out of control, it's still going at 10 shots per second

austere grotto
#

Do you happen to have any extra mice attached to your computer?

#

bluetooth one maybe?

tame oracle
#

Nope, just the one

austere grotto
#

or maybe your mouse is dirty? 😛

tame oracle
#

Lmao maybe

austere grotto
#

and sticks a bit

#

I think the logic is a little convoluted but generally OK

tame oracle
#

I'm currently using a wireless mouse, I'll try plugging in my wired one.

austere grotto
#

yeah maybe try that

tame oracle
#

yeah

austere grotto
#

and turn the wireless one off so it doesn't interfere by accident

tame oracle
austere grotto
austere grotto
#

Like it gets stuck held down and the program loses focus and it still thinks it's held down?

#

idk

tame oracle
#

I just did some debugging, and I found out that even when I'm not holding the mouse down, the game still thinks I'm holding the mouse down. I checked that with this script:

if(Input.GetKey(KeyCode.Mouse0))
{
    Debug.Log("MouseDown");
}
else
{
    Debug.Log("MouseUp");
}
austere grotto
#

(it shouldn't)

#

do you have a touch screen btw?

tame oracle
tame oracle
gleaming oar
tame oracle
gleaming oar
austere grotto
gleaming oar
#

this is the new way to do it. You'd create an input action in your PlayerControls() input action asset that fires off your performed event when held down

austere grotto
tame oracle
austere grotto
#

it returns true as long as you hold it

tame oracle
gleaming oar
austere grotto
#

ah yes

austere grotto
gleaming oar
#

and it shores up the Update vs FixedUpdate input issues that have plagued beginners for forever

austere grotto
#

so switching input systems right now is not going to help them

gleaming oar
#

hmm, sometimes I've had mice with a double click issue

#

logitech made some G502 series with crappier switches inside that I had to replace

tame oracle
gleaming oar
#

do you get double click issues any other time or just in this game

tame oracle
gleaming oar
gleaming oar
#

are you mashing the mouse or just clicking normally

tame oracle
#

Fast double click

gleaming oar
#

it turns red for me if I mash it, but my mouse doesn't have a double click issue

tame oracle
#

My finger's doing that tho

tame oracle
gleaming oar
#

I mash it with 2 fingers and I can get it to turn red

#

if you're getting it with one finger then your mouse might have that issue

tame oracle
#

With my gun, holding down the mouse button works normally, it's only when I mash the mouse button

gleaming oar
#

by chance is it a logitech mouse?

tame oracle
gleaming oar
#

you could try using an autoclicker on your game to test

#

take the hardware out of the equation

tame oracle
#

I'll try that

gleaming oar
#

For reference I had to replace my logitech switches with Kailh GM 4.0 Mouse Switches. They were some other brand before

#

Omron's I think

tame oracle
#

I tried with the autoclicker, no issues from what I've seen

young linden
#

Hi i have an issue, my character (the tank) have not the same rotation speed when i switch the resolution (see the video)
i use this code (see screenshot 1) for rotate the tank
and the input actions of new input manager in the second screenshot
Someone know how i can solve that please ?

austere grotto
young linden
cursive needle
#

Hi guys. New here. Hoped to get some directions on how to solve the touch input problem I have. Have you played Townscaper? I a trying to implement a similar Camera controller. Touch/hold pan, but touch/release place an object. Currently when I touch the screen and hold I can pan but also I place an object 😦

austere grotto
young linden
drifting sandal
#

does UI not work with touch in new input system? I can't press a button with my finger in my iOS build, and all my googling tells me others seem to be going back to standalone input

austere grotto
analog siren
#

PlayerInputActions _playerInputActions = new PlayerInputActions();

#

seems to not work

#

is this not the proper object name anymore?

misty locust
analog siren
#

Nvm im just a little braindead

misty locust
proud heron
#

How would I got about something like: if space is pressed, do x? Google told me to use GetKeyDown, but apparently Input System Package doesn't work with that.

old matrix
#

Suddenly my input module is listed as disabled in the input debugger? Why is this?

#

the component is enabled...

sweet trench
proud heron
sweet trench
old matrix
serene zinc
#

Is there a way to add directives to the auto-generated class? I provide a prefab which supports both new and old input like so:

  public class PlayerInput : MonoBehaviour {
#if (ENABLE_LEGACY_INPUT_MANAGER)
        public FrameInput GatherInput() {
            return new FrameInput...
        }
#elif (ENABLE_INPUT_SYSTEM)
        private PlayerInputActions _actions;
          
        // omitted for brevity

        public FrameInput GatherInput() {
            return new FrameInput...
        }
#endif
    }

Which works fine, but people will still get a bunch of compile errors due to the auto generated script. I can uncheck it when exporting my package, but there's no guarantee I'll remember each time.

#

Ideally the generated class should contain these directives by default, right?

serene granite
#

The video show the problem:
I was doing camera for third person game and i got into a bug when I move backwards (toward the camera position) the camera "sallow" the player
its to much code files for me to send in here So please DM as soon as possible

ivory eagle
#

Everytime I press the "Jump" input it shows this error and i'm not sure how to fix it, the error information doesn't give me any guidance

#

I need the specify the generic value?

viscid mural
#

Hey all, I know there have been many conversations about this, but I don't see a concrete answer on forums or pinned in this chat. I am following https://forum.unity.com/threads/implement-a-mouse-drag-composite.807906/ on how to get drag functionality on the new input system. I have included the two scripts and set up the input map per example. I am getting "Started" on any click "Performed" on click release and "Cancelled" twice after pointer move after any click is performed. I am not sure if that's the best we have currently, but I would expect "started" to only fire when click held + movement occurs. "Performed" to occur continuously while held and moving, and "cancelled" once click is released.

#

It does work in between the early firing and double cancel, but I would have to play Boolean gymnastics to sort out am I actually in a drag state or not

tame oracle
#

does anyone know the layout for a retroflaf snes controller

sullen lintel
dawn forum
#

Hi, i'm learning how to make an fps with unity's Microgame FPS tutorial, and i noticed that they basically use the old input system, if i want to advance in the game (especially just add a splitscreen), is it better to keep the old one or try to redo a new project with the new one ? (or its just a matter of taste? ahah) thanks

sullen lintel
slim pike
#

Is there a way to use the input system manager to implement an onEnter and onExit function for a specific buttom?

#

I wanna make it so that an action will be performed as long as a button is being pressed down

austere grotto
#

Or wait are you talking UI button

#

Or input button

slim pike
#

input button

serene zinc
sweet trench
#

whoa its Taro lets go!

tame oracle
#

anyone have a guide on setting up analog movement on gamepad?

ornate oasis
#

At around 4:11 it has something similar to that

#

Though the green header thing will need to have the pass through vector 2 for the analog to work right

tame oracle
#

thanks

tame oracle
#

was it moved somewhere else

ornate oasis
#

That’s strange, I have no clue

#

Only know this much since I saw this video like yesterday by chance

lime nymph
#

can anyone help please i have two sound devices and look to make my game to pick up which one i want it uses anyone know or point me in to the right place on how to do this please

terse pebble
worldly fulcrum
#

hey does anyone know how i would get the exact position of the mouse?
i believe it has something to do with how i set up my input action map

#

i'm using the new input system package i believe

#

version 1.3.0

austere grotto
#

Just make an input action bound to Pointer Position or Mouse Position

spiral galleon
#

^ your input action also has to be of Value or Pass Through (any) and not Button

worldly fulcrum
#

whenever i try printing it, it just prints out (0.0, 0.0)

spiral galleon
#

Delta = pixel change from last frame

worldly fulcrum
#

i just tried it, does the same thing

#

would it help if i sent my code?

spiral galleon
#

Yeah, and a new screenshot of your current input action

austere grotto
#

and why are you using PassThrough

worldly fulcrum
austere grotto
#

value/vector2

spiral galleon
#

you need to enable your input actions

#

InputActions.Enable();

worldly fulcrum
#

in the awake func?

spiral galleon
#

for now yeah sure

worldly fulcrum
#

hey, works perfectly now

#

thanks all

worldly fulcrum
old matrix
#

hey im using the new input system. i restarted my computer and now my mouse polling rate is really low, but only in game? My game isnt lagging, and my mouse works fine otherwise. I looked in the input debugger and yeah, mouse events only come in every second or two in play mode

austere grotto
#

they definitely all do 😛

old matrix
#

this is very bizarre

austere grotto
old matrix
#

i did restart unity, let me try my computer though

worldly fulcrum
austere grotto
#

That's not... how memory leaks work

worldly fulcrum
#

so no?

austere grotto
#

There are good reasons to disable it at certain times but doing so is not related to preventing memory leaks

old matrix
normal crow
#

Hey guys, I'm using Input System 1.3. Any idea why this is happening?

  1. Give gamepad input
  2. Give keyboard input
  3. Player Input > Events > UI > Point (CallbackContext) gets triggered
    It's almost as if keyboard & mouse is seen as one device, so switching to keyboard triggers the mouse to fire a point event. I couldn't find a way to distinguish between this and a true point event.
olive mortar
#

Hello! Im changing my codebase to the new input system, but im stuck on this...

        if (weapon.isAutomatic) shooting = Input.GetMouseButton(0); //hold
        else shooting = Input.GetMouseButtonDown(0); //tap``` how would i change this to the new input system?

```cs
    public void OnFire(InputAction.CallbackContext context)
    {

    }```
untold gulch
#

The way you "ideally" should use the input system is fundamentally different to how you're using the old one in the example there
A quick and dirty equivalent though would be to use Mouse.current.leftButton.isPressed/Mouse.current.leftButton.wasPressedThisFrame

dapper narwhal
#

yeah that would be quick and dirty indeed

#

probably have two different actions for Hold and Tap interactions right?

untold gulch
#

It definitely works as a quick "I want to port this to the input system", but ultimately you would want to use interactions yeah

dapper narwhal
#

and then ReadValue triggered or some shit

olive mortar
#

i want to do it the propery way, aye

#

the relevent interactions are set for each

dapper narwhal
#

yeah so

olive mortar
#
    public void OnFireHold(InputAction.CallbackContext context)
    {
        
    }

    public void OnFireTap(InputAction.CallbackContext context)
    {

    }```
dapper narwhal
#

i don't think you even need the methods tbh

#

just thing.triggered contains the bool

olive mortar
#

I am 1 hour deep into input system

#

i need abit more than that 😛

dapper narwhal
#

true

olive mortar
#

all my other actions are a method, plugged into the inspector

dapper narwhal
#

try ```cs
shooting = YadaYada.FireTap.triggered;

olive mortar
dapper narwhal
#

hm

olive mortar
#

i think it'll make more sense to keep to the system

dapper narwhal
#

i guess

olive mortar
#

especially if i come back after a break or sommit

dapper narwhal
#

yeah makes sense

olive mortar
#
    public void OnFireHold(InputAction.CallbackContext context)
    {
        PlayerStats.Instance.weaponStats.ShootButtonType = context.interaction.Equals("Hold");
    }

    public void OnFireTap(InputAction.CallbackContext context)
    {
        PlayerStats.Instance.weaponStats.ShootButtonType = context.interaction.Equals("Tap");
    }``` im confident this isnt correct
#

yea no, this is wrong

#
        if (weapon.isAutomatic) shooting = Input.GetMouseButton(0); //hold
        else shooting = Input.GetMouseButtonDown(0); //tap``` i only need to change the right-hand assignment of this right
austere grotto
#

something like this