#🖱️┃input-system

1 messages · Page 58 of 1

austere grotto
#

you have two copies of the script in the scene

#

Ya

stable coral
#

Yes

#

Still doesnt explain why the player that actually uses the joystick refuses to move

austere grotto
#

well that'd be related to your other code

stable coral
# austere grotto well that'd be related to your other code
    public void PlayerThrottleJoy(float inputJoy)
    {
        //Multiplies ThrottleSpeed and ReverseSpeed with input, all are independent float variables
        //Sets the independent variables to the front/back axis and creates some new independent vector variables

        float throttleForceJoy = (inputJoy) * throttleSpeed;
        float reverseForceJoy = (inputJoy) * reverseSpeed;


        //If there is a positive input, lerp from the current velocity to what the max speed is (throttle force) with an interpolation of the acceleration force
        //Joystick
        if (inputJoy > 0)
        {
            currentVelJoy = Vector3.Lerp(currentVel, new Vector3(0, 0, throttleForceJoy), throttleAccelerationForce * Time.deltaTime);
        }
        //If there is a negative input, lerp from the current velocity to what the max speed is (reverse force) with an interpolation of the acceleration force
        //Joystick
        else if (inputJoy < 0)
        {
            currentVelJoy = Vector3.Lerp(currentVel, new Vector3(0, 0, reverseForceJoy), brakeStrength * Time.deltaTime);
        }
        //if there is no input, lerp from your current speed to zero
        else if (inputJoy == 0 && currentVel.z != 0)
        {
            currentVelJoy = Vector3.Lerp(currentVel, Vector3.zero, throttleDecelrationForce * Time.deltaTime);
        }
    }```
austere grotto
#

well none of that actually moves anything

stable coral
#

oh yeah mb

#
    private void FixedUpdate()
    {
        Vector3 direction = transform.TransformDirection(currentVel + currentNitroVel);
        rb.AddForce(direction - rb.velocity);

        float speedovalue = rb.velocity.z;
        speedovalue = Mathf.Abs(speedovalue);
        speedovalue = Mathf.RoundToInt(speedovalue);
    }```
#

the thing is that it works for kb but not for my joystick

austere grotto
#

none of that reads currentVelJoy

stable coral
austere grotto
#

so I can't see how the above code would affect it

stable coral
#

forgot to add it there

#

it does work, just hella slow though

#

atleast thats one issue solved

thorn fulcrum
#

Is this the right place if I have a question regarding input and I'm using Rewired?
I have a specific case that I can't find a solution too and would love some new ideas to try.

austere grotto
#

Yeah this would be the best channel probably

#

But Rewired I believe does have its own forums and/or discord

thorn fulcrum
#

I didn't find a discord or forum, only a help section with FAQs. But I do remember in the past seeing a forum... If anyone have the link please let me know.

vivid junco
#

what's the input for nintendo switch joy cons

thorn fulcrum
#

Here's the challenge I'm facing :
I am using Rewired, my game supports controllers, keyboard and keyboard mouse.

In my UI I have selectable buttons with transitions handled by an animator (press, highlighted...)
When I use the mouse and over on a button, the highlighted state is on (expected).
If at that moment I move my controller joystick to another selectable button (switching input mode) , the previous selected button stays highlighted (since the mouse cursor is still on it).

I can't find a working way to force that previous button to stop being highlighted.

UPDATE
Finally found a solution that works. I'm still surprise that this is not handled more gracefully by Rewired / Unity.
I made an adaptation of this solution : https://answers.unity.com/questions/1130654/clearing-mouse-hover-effect-when-cursor-is-hidden.html

UPDATE 2
Here's a simpler way that works too.
// Put this code in a Controller changed callback if (controller.type != ControllerType.Mouse) { Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; } else if (controller.type == ControllerType.Mouse) { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; }

coral flame
#

this is the issue righ there

#

i cant crop it because it breaks

wicked kestrel
#

Anyone possibly know how it's possible that I'm getting an error where

InputAction.CallbackContext MoveInputCtx;

MoveInputCtx  <====== is not null
MoveInputCtx.action  <====== is null
random edge
tame oracle
#

if i have all my inputs in 1 script and generate a single instance of the PlayerInput script my inputs work fine, but when I split the keyboard and gamepad inputs into their own scripts each generating their own instance I get Null Reference Exceptions when i press my inputs, anyone know why?

tame oracle
#

nevermind, twas me being silly

topaz hill
#

I'm looking for some input (pun intended) in regards to the different ways to implement the "new input system." Specifically, a comparison of the PlayerInput component vs using the class and interface generated from the InputActionAsset. Any good links/blogs comparing the two methods? Or maybe someone's personal experience?

austere grotto
topaz hill
#

Yep, aware of those as well. Didn't seem like good options unless you have reason to believe so...

austere grotto
#

InputActionReference is my go-to

#

the generated class is alright too

topaz hill
#

I like the generated class and interface. Just wondering about shortcomings and any caveats/gotchas that will rear their ugly heads later on.

untold gulch
#

PlayerInput on a singleton that you use to dispatch events can also work pretty nicely

#

Reduces the amount of manual work involved overall

#

The generated class "works" but it's pretty janky

topaz hill
#

I discussed the word janky with my protocol droid and it did not compute. Can you be a little more specific? 🙂

untold gulch
#

Awkward to work with and the code it generates is a bit of a mess

#

It also unfortunately doesn't implement the interfaces it provides on the generated types, which I remember being a pain point

topaz hill
#

What type of messaging are you using on your Player Input singleton?

untold gulch
#

The singleton has a PlayerInput component and then another component that receives the input events from that via SendMessage, which then call C# events

topaz hill
#

Got it.

untold gulch
#

It can be handy when you want to use PlayerInput but don't want it to be on the actual player object itself

#

i.e. in a multiplayer game

#

Since that would result in multiple PlayerInput components active at one time, when you only one want to represent the local player

topaz hill
#

So your not capturing the InputAction.CallbackContext? That's not possible with SendMessage, correct?

untold gulch
#

The SendMessage approach receives a type that wraps the callback context

#

Specifically, it gets an InputValue, which gets recycled between messages to avoid allocations

topaz hill
#

Didn't know that. Haven't seen examples.

untold gulch
#

So for example, I might have something like:

public event Action<Vector2> Move;

private void OnMove(InputValue value)
{
    Move?.Invoke(value.Get<Vector2>());
}

On my "listener" component

topaz hill
#

Yea, I see it now. Guess that's what I get for watching outdated youtube videos.

untold gulch
#

There's a surprising number of those for the input system lol

topaz hill
#

Worked like a charm. I kept wondering why the Unity Event and C# Event message would have a context and the SendMessage not. Thanks.

austere grotto
#

SendMessages is unfortunately pretty limiting

untold gulch
#

Yeah, I don't quite get why they don't expose the CallbackContext inside the InputValue

austere grotto
#

you can't distinguish between started, canceled and performed

untold gulch
#

If it weren't for that, it'd be perfect

austere grotto
#

You can always put your PLayerInput in C# events mode and use the playerInput.onActionTriggered event

#

if you want to do it all in code

untold gulch
#

Yeah, but at that point you lose most of the benefits of using PlayerInput (aside from like, automatic gamepad/keyboard switching)

topaz hill
untold gulch
#

Luckily though, so far SendMessage + callbacks has been good enough for me, whenever I need more granularity like started, performed, etc I can add a manual subscription via input.actions["Move"]

austere grotto
#

that's what it's made for

topaz hill
#

Ok.

austere grotto
#

PlayerInputManager + PLayerInput

#

is for local multiplayer

untold gulch
#

PlayerInput itself is useful because it handles switching automatically

#

PlayerInputManager though yeah, that one you don't need unless you're doing MP

austere grotto
untold gulch
#

It recognizes when you press something on a gamepad and switches the control scheme

austere grotto
#

Ok so like gamepad / kb + mouse switching

untold gulch
#

Yeah

austere grotto
#

or gamepad -> gamepad

#

w/e

#

interesting 🤔

untold gulch
#

Switching between gamepad and kb/m based on your inputs

#

You can of course implement it yourself, but why bother when PlayerInput has a working implementation

#

It also exposes events for when the switch happens so you can update your UI and stuff accordingly

#

From the docs:

If control schemes are present in actions, then if a device is used (not merely plugged in but rather receives input on a non-noisy, non-synthetic control) which is compatible with a control scheme other than the currently used one, PlayerInput will attempt to switch to that control scheme. Success depends on whether all device requirements for that scheme are met from the set of available devices. If a control scheme happens, InputUser signals ControlSchemeChanged on onChange.

austere grotto
#

Control schemes are still an area of the new input system that I don't fully understand

lost swift
#

What is best way to save rebinded inputs?

untold gulch
#

There are so many ways to do it that I don't think there's really a "best" way, but one option is to have an array of input binding overrides that you serialize to json or something

#

You'd basically iterate over all of your actions, collect the binding overrides active on them, and save them out

lost swift
#

Thanks!

topaz hill
#

@untold gulch How are you delineating between phases when using InputValue?

untold gulch
#

You unfortunately cannot because they don't expose the callback context for some reason

topaz hill
#

Ok. That's what I read and wondered if I'm missing something.

untold gulch
#

There's a hack you can do to get the value but ideally Unity would just expose it properly

#
using System.Runtime.InteropServices;
using UnityEngine.InputSystem;

public static class InputValueExtensions
{
    public static ref InputAction.CallbackContext GetContext(this InputValue value)
    {
        return ref new InputValueUnion { InputValue = value }.RawInputValue.Context;
    }

    [StructLayout(LayoutKind.Explicit)]
    struct InputValueUnion
    {
        [FieldOffset(0)]
        public InputValue InputValue;

        [FieldOffset(0)]
        public RawInputValue RawInputValue;
    }

    class RawInputValue
    {
        public InputAction.CallbackContext Context;
    }
}
austere grotto
untold gulch
topaz hill
#

@austere grotto Are you willing to share how you use the InputActionReference?

austere grotto
topaz hill
#

Got that part. The part I'm missing is what you put in the serialized field.

austere grotto
#

Or:

[SerializeField]
InputActionReference moveRef;

void Update() {
  transform.Translate(moveRef.action.ReadValue<Vector2>() * Time.deltaTime);
}```
austere grotto
#

you can usually just press the circle thing on the right and choose from all of them

topaz hill
#

Hmmm....pulled one in and it successfully "set" it. Didn't work, though.

austere grotto
#

I'm usually not dragging/dropping, just selecting from the circle menu

#

they usually all show up there for me

topaz hill
#

Yea, they are there and can be selected. Checking other stuff.

austere grotto
#

YOu may have to enable your asset from somewhere

topaz hill
#

The InputActionAsset, correct?

#

So your creating an instance of it somewhere in your code?

austere grotto
#

no

#

just referencing the real one

#

I generally have a single script that manages enabling/disabling action maps

#

Probably I enable the asset from there

#

Don't remember off the top of my head

topaz hill
#

Disregard. It works. Unity was not detecting mouse clicks. Moving it to the keyboard worked. Have to solve the mouse issue now.

#

@austere grotto I think you are tired of talking about it, but I have one other question. Using the generated C# wrapper class for the InputActionAsset is strongly typed, provides a convenient interface to implement and eliminates the need for serialized fields. Are there any pros/cons to doing it your way vs the C# wrapper? Simply personal preference?

austere grotto
#

I like my way because I don't have to manage my own instance of the actions asset. Also last time I checked the generated code didn't contain quite the entire interface of InputActionMap and such, but that might have changed since last I used it. I also like the directness of being able to reference the input action in the inspector like any other ScriptableObject or what have you. I can reassign it without changing the code. It feels very "Unity" to me.

#

It is of course my preference

topaz hill
#

Ok. Cool.

outer ermine
#

Looks like I just enable/disable the appropriate keywords

#

oops wrong chat

zealous widget
#

Hey guys, does anybody know how to get middle mouse button hold state and at the same time mouse position? Trying to make camera rotation script when middle button is pressed

crimson crater
#

can i identify a device with any data from PlayerInput.devices[]? I need to pass the player devices to another scene but the deviceID returns another device with InputSystem.devices[deviceID] . I can use a foreach loop to check which devices match but if there is a better way i would be happy to know

#

NVM found how

mental musk
#

I have set up several input devices (PS4, XBox, etc.) and a general gamepad profile, but when I connect the PS4 gamepad, etc. it uses the general gamepad profile rather than the PS4 one. Is that a Unity bug or intended behaviour?

balmy badge
#

I think there are major issues with Unity's new input system right now regarding gamepad controllers.
I'm having issues where my controllers are just randomly disconnecting, when I can play games fine while Unity thinks they are disconnected.
Someone else is having this issue too https://forum.unity.com/threads/xbox-controller-stopped-working-in-unity-but-still-work-outside.1246507/ and i've submitted a bug report.
But I would like to know if anyone else is experiencing this too?

tight nebula
#

hello, i'm trying to get ahold of the new input system, and i'm having this issue where despite (to the best of my knowledge) i set up the input as a 1axis float, it isn't read as a float. how can i convert from teh input value read to a float?

mental musk
balmy badge
tight nebula
#

some of those old comments are just old code i'm keeping around for reference, so don't worry too much about those

austere grotto
#

Method invocation requires () in C#

tight nebula
#

okay, but if i try that, then enter float, it returns as invalid

#

same with input, axis, int, bool, vector2, and vector3, under this context;

#

nor does it work if i do something akin to;
throttleAmnt = ReadValue(verious destinations)

#

i converted teh control type to a double, and tried to search for a double instead of a float, or other variables, and it's still unhappy

#

given the documentation, it implys i should use one of the two i've already used, but this doesn't seem to work basically at all

austere grotto
#

it's just a simple C# syntax issue on your side

shut aspen
#

Hi. I'm working on learning the input system to move/rotate a box using either WASD and arrows or an XBox 360 controller. I set the sticks to 2D Vector and analogue, yet the thumbsticks act like 8-way switches. In other words, it's like I'm stuck with the digital-normalized mode, when I want the analogue mode. All three options 2D composite modes seem to behave the same. Any idea where to start?

austere grotto
shut aspen
#

Just tried it for the 12th time, and it works. I could've sworn I tried those settings before. Thank you!

#

The only change I can think of was rebooting the project.

tight nebula
#

anyone have any idea why this script to rotate my empty wont work? debug.log reads an input, but when i try to turn it it jsut sorta freaks out in place like it wants to turn but cant

#

(turn force is set to 100f just to try see any result)

glass yacht
#

🌈 .rotation is a Quaternion

tight nebula
#

yes, i'm aware, but i need to use quaternion.eular(variable) to convert the roll, yaw, and pitch into a quaternion

#

if i remove it, it errors out

#

specifically with this

#

because when i try to create a quaternion, i cannot seem to specify a w, so i need to use a vector, then convert that vector to said quaternion

#

so as much as i appreciate a meme, i do feel like your comment fails to understand what i'm getting at, and i'm sorry if i didn't explain it well enough.

austere grotto
tight nebula
#

i have, and i've erased basically every reference

austere grotto
#

What may help is to understand that you can compose Quaternions by multiplying them together. I.e. transform.rotation * Quaternion.Euler(0,1,0) will give you a new rotation that is the object's current rotation rotated by 1 degree in the y axis

#

Maybe you can extrapolate from that

tight nebula
austere grotto
#

You haven't fixed what I described above

tight nebula
#

for aditional context, this the entirety of where the variable is being called except for where it's established

austere grotto
#

You're still trying to read x y and z from a quaternion

tight nebula
#

and i will try that in a second, i'm simply just trying to show why my confusion might be so

austere grotto
#

Your confusion is that you think x y and z in the quaternion represent rotations around the x y and z axis but they do not

tight nebula
#

x is roll, y is yaw, z is pitch

#

to be blunt, i've done game development in unreal engine before, i understand the fundimentals.

#

i understand rotating is like if you stuck a rod into it, and rotated it around that

austere grotto
#

They are not angles. Not around anything.

#

What you're describing are Euler angles

#

Trying to stick quaternion components into Euler angles is like sticking a round peg into a square hole. It doesn't fit

#

Try printing out transform.rotation. See what it prints

tight nebula
#

okay, well, then i guess that is my issue, and the tutorial i found is nulll

#

and okay

austere grotto
#

(but that's not your issue)

tight nebula
#

yes, my bad, and after teh debug, the x, y, z, and w

#

after using transform.rotation, i have the issue where unity is asking for the w input

#

so unless i need to do like in unreal, and plug 3 vectors and a float into this, i don't understand the issue

glass yacht
#

Don't use or set individual values of a quaternion

#

.eulerAngles/.localEulerAngles are the Vector3 euler angle values

#

also that's not how you create a vector

#

The problem I was initially talking about was this

#

not how you used Quaternion.Euler, which was fine

tight nebula
#

then what is the issue with it? i see no reason this might be wrong

glass yacht
#

you are creating a Vector3 out of values from a quaternion

#

it makes no sense

#

Quaternions are 4 dimensional normalised values. They are not degrees like euler angles

tight nebula
#

i'm literallty just trying to rotate an empty

glass yacht
#

.eulerAngles/.localEulerAngles are the Vector3 euler angle values

#

seeing as you have a rigidbody, you can get the euler angle rotations from the quaternion using rotation.eulerAngles

#

An easier way to do it might look like rb.rotation = Quaternion.AxisAngle(Vector3.up, 5) * rb.rotation;

tight nebula
#

i appreciate the attempt at helping, but i tfeels like the time is being wasted, i awknowlege i was using quaternions wrong, and i'm understand that adn will do my best not to do it again, however, the issue is, i feel liek i've been told a whole lot of what not to do, but not how to do it.
i'm sorry, but simply saying i should use x without context of where is very confusing, and i'm having to google practically everythign you're saying after to try understand where to properly impliment it

#

trying to follow what you've been saying has led me here

glass yacht
tight nebula
#

do you mean i use that to get the vector "newRot"

austere grotto
#

It creates a new quaternion

#

not a Vector3

#

a Quaternion

tight nebula
#

do you mean i use that to adjust the output

#

yes, i understand that

#

but my point still stands

austere grotto
#

transform.rotation can be assigned to a quaternion

tight nebula
#

okay, again, where

austere grotto
#

in your code...

#

ger rid of newRot

tight nebula
#

where in my code

#

there is 3 things happening at once, and just telling me to do so, is not helping as i am both a novis and inexperianced with c#, coming from unreal with c++

#

okay, will try

austere grotto
#

I don't want to completely spoon feed you here, I want you to understand a bit.

#

Just try this for a second:

transform.rotation = transform.rotation * Quaternion.Euler(0, 1, 0);```
#

see what this does

#

I recommend not trying to understand what the x, y, z, w are. Don't even think about them. Just think of the rotation as a whole.

tight nebula
#

what you fail to understand, is if i'm clearly not understanding this, having the expectation of me just getting it is not helping.
i'm fine with you wanting me to try something, however i think it would save us both time and energy if you did just treat me like an idiot lol

and okay, i can do that

#

and it appear to be doing nothing after replacing the last line of my code

austere grotto
#

this line of code replaces all of the code inside your if statement

tight nebula
#

okay, i will try that

austere grotto
#

yep

tight nebula
#

doing this does perceivably nothing

austere grotto
#

is your joystick deadzone over the threshold?

tight nebula
#

i'm not saying it is, i just cannot see anything at a glance that is different

austere grotto
#

Or wait - did you run it?

tight nebula
#

i pulled a 404, i forgot i actually needed to press the joystick lol

#

yes, it is spinning in a cw fashion

austere grotto
#

Is it spinning the way you want? (don't worry about the speed for the moment)

#

but the nature of the rotation

tight nebula
#

i need it to spin both ways.
turnAmnt is my left joystick y, so to explain my thought process, i'm imagining i need to multiply that 1 by my turnAmnt variable

austere grotto
#

Seems reasonable to me

glass yacht
#

you should be able to replace that 1 with whatever you want now

austere grotto
#

Don't forget your turningForce and deltaTime as well

tight nebula
#

very true

glass yacht
#

I'm also not sure as to the context of the code but you may want to Mathf.Abs the turningAmt in your if statement if you expect it to be negative, that way negative values pass that check

austere grotto
#

To try to explain what actually is happening here:
Unity represents rotations with Quaternions. A quaternion represents some rotation away from the "default" rotation. You can "compose" quaternions using the * operator. So all we're doing here is taking your object's existing rotation (transform.rotation) and composing a new rotation of some degrees around the y axis with it, and then setting that composed result back to the object.

#

hopefully that makes sense 🤔

tight nebula
#

it does enough

#

ty

#

and just with a reply

glass yacht
#

And what was wrong before was that you were composing a euler angle rotation using values you got from a quaternion

tight nebula
#

this is no longer working

austere grotto
tight nebula
#

just did

#

and still nothing

#

because i caught that just i posted it

austere grotto
#

brackets are still wrong

glass yacht
#

the braces are not wrapping around the content of the if statement

#

if statements without braces only affect one statement (the log)

austere grotto
#

although if tbh it should still be rotating just fine anyhow, just not respecting the deadzone

tight nebula
#

lol, i was looking at a different bracket

glass yacht
#

regardless, you probably just need to scale your turningAmt by a larger value now it's being tempered by deltaTime

tight nebula
#

i think you call them parenthesis or something

austere grotto
#

() are parentheses
{} are brackets or curly braces

tight nebula
#

the finale working statement

#

key word working

#

and ty for the help

#

and for a dash of context, i'm in SW canada, and i've basically only ever heard of () as brackets

#

not saying you're wrong, just a mental roadblock lol

#

grey vs gray as far as i'm concerned

austere grotto
#

sorry about the confusion, yeah maybe parentheses is an American term? idk

tight nebula
#

for context, i learned pedmas as bedmas lol

#

and it's fine, just felt like with this i should be as clear as possible, not trying to come across as rude, and i really appreciate the help

#

but if something wasn't working, i feel like i should call it out

#

and yeh, at the end it felt like ti was working much better so woop

summer veldt
#

Hey, If im pressing or releasing 2 buttons at the same time, unity doesn't register one of them, any work around to that issue?

austere grotto
summer veldt
#

which talks about it

high skiff
#

I'm having an issue with the Input System that I hope someone could help me out with. I am trying to implement basic left/right movement in a 2D game, and it works great for KBM. But I'd like to also have gamepad support, so I added another 1D axis binding under my movement action and assigned the positive/negative bindings to the appropriate direction on the gamepad. However, when I plug in my controller to test it, while the player character is moving, it is doing so at a much slower rate. I wrote a quick Debug.Log() line and discovered that while the keyboard is giving out perfect readings of either 1, -1, or 0, the controller is reading very inconsistently between about .5 and .8 (or the inverse if holding the other direction). This is happening even when I push the stick as far as it goes. How can I make the inputs consistently read max value when held fully in one direction?

#

Just tried with the controller's dpad and that works as it should (reading 1, -1, or 0)

lost swift
#

Hello! How can i save specific button from up/down/left/right composite after rebinding?

#

I can't just action.ApplyBindingOverride(path); it does nothing

earnest vector
#

how do you disable a action map during runtime?

#

ive tried doing ```csharp
private PlayerInput InputSystem;
InputSystem.actions.FindActionMap("Player").Disable();
InputSystem.actions.FindActionMap("Menu").Enable();

#

and ive also tried like 3 other ways with no success

#

so whats the proper way to disable and enable action maps, or am I doing something in the setup wrong thats not allowing this stuff to work

distant glacier
#

hi all, i have a little problem with buttons in gameover screen.. on click they dont do anything.. any ideas please ?

toxic folio
#

So... I made a small app for android (its only a cube object and touching the screen, moves the cube to that area... but I'm noticing a input lag when I do that (about half a second)...

#

also, when I update the engine with the new input system (1.3.0), my phone no longer recognise any input

austere grotto
toxic folio
#

okay... found a tutorial that explained how to use the new input system

hot notch
#

can anyone help me with the swipe inputs. Left and right swipe works fine but up and down swipe works only 6 or 7 out of 10 times.

distant glacier
austere grotto
delicate pollen
#

Just asking this here as it's an input question. I'm getting the mouse position in the manner below...

public Vector2  MousePosition   => controls.BipedMovement.MousePosition.ReadValue<Vector2>();

I'm using this to rotate a rigidbody on the Y axis based on the movement of the mouse on its X axis. The problem is that the speed of rotation is affected by the overall size of the screen or viewport - and given I'm hoping to put this program onto browsers and a variety of platforms, I'd like to find a way to make my code screensize agnostic. Any clues? =)

yRotDesired     = (iC.TurnInputRaw.normalized.x + iC.MouseDelta.normalized.x) * (speedTurn * speedCur) * Time.fixedDeltaTime;
moveRotDesired  = rbBody.rotation * Quaternion.Euler(0.0f, yRotDesired, 0.0f);
austere grotto
delicate pollen
#

Roger, understood.

#

Any chance you could clarify 1) ? Just curious.

austere grotto
#

Mouse Delta is in absolute terms

#

It's the number of pixels the mouse moved since the last reading

#

By definition this is already framerate adjusted

delicate pollen
#

Right.

#

Also, I'm an idiot for not even posting the relevant input code for the mouse. Thanks @austere grotto , you're bang on the money.

austere grotto
#

Although if this is FixedUpdate, you may have an issue of double reading or missing mouse input unless you set the input cadence to be FixedUpdate in the input system

delicate pollen
#

The input is captured outside FixedUpdate, then applied within FixedUpdate.

austere grotto
#

That's a little dangerous. FixedUpdate may run 0 times in a frame or multiple times in a frame. If you do that you need to consume the input in FixedUpdate

#

So it won't be read twice

#

And accumulate it in the other place

delicate pollen
#

Hmm. Okay, this is sorta new to me.

#

By 'dangerous', are we talking about 'potential harm to hardware/os' or 'harm to the running of the Unity program' or 'may cause the player behavior to be wonky'?

austere grotto
#

Wonky behavior

#

Sorry dangerous was the wrong word

delicate pollen
#

I've been basically using this methodology for years on multiple projects and haven't encountered a problem, so I'm very interested to hear details, if you can spare the time (or point me in the right direction). Always looking for better practices.

delicate pollen
#

I'm currently storing, for example, rotation data in the class variable moveRotDesired.

austere grotto
#

If you haven't noticed any issues I guess don't worry about it

#

It's possible I don't fully understand your setup

delicate pollen
#

Honestly, I'm interested in learning about 'consuming'. Are we basically talking about calling a function from fixed update with the data fed to parameters?

#

I'm guessing 'no'. =)

#

Don't want to waste your time, though.

distant glacier
delicate pollen
#

Disregard that, I'm an idiot, apologies, carry on.

delicate pollen
#

Btw, @austere grotto , now I have the scalar in for the Mouse Delta, I'm definitely seeing the wonky behavior you described.

delicate pollen
#

God, apologies in advance if I'm being dense. Let me just get the current relevant code...

public Vector2  MouseDelta      => controls.BipedMovement.MouseDelta.ReadValue<Vector2>();

This ^ is from my inputController script, talking to the new InputSystem.

yRotDesired     = iC.TurnInputRaw.normalized.x + (iC.MouseDelta.normalized.x * iC.MouseSensitivity) * (speedTurn * speedCur) * Time.deltaTime;
moveRotDesired  = rbBody.rotation * Quaternion.Euler(0.0f, yRotDesired, 0.0f);

This ^ is from my PlayerTraversal script, called from Update().

private void FixedUpdate()
    {
        if(sendToRigidbody)
        {
            // moveDirDesired.y = 0.0f;
            Vector3 position = rb.position + moveDirDesired * Time.deltaTime * speedCur;
            rb.MovePosition(position);
            rbBody.MovePosition(position);
            rbBody.MoveRotation(moveRotDesired);
        }
    }

That ^ is my FixedUpdate() event.

So, to fix this, I'd be... List<quaternion> ListOfMoveRotations.add the desired rotations as they're processed in the Update() event. This would accumulate the input every frame.

Then, in FixedUpdate, I'm basically doing,

rbBody.MoveRotation(ListOfMoveRotations.pop);

After the .pop operation, I'd basically do,

ListOfMoveRotations = new List<quaternion>;

...making it ready to be filled by the code in Update.

Does this make sense? Apologies @austere grotto , the whole consume thing is sorta new to me.

plush stone
#

Using the new input system, I created an action that takes mouse delta

#

How can i apply this vector 2 to my camera?

#

I don't know how to get the vector2 value in code

dapper narwhal
thorny osprey
#

Hi! There is any way to have multiple ways of calling a button? For example, in a inventory, equip with the north button/shift click, throw with the east/supr etc

glass yacht
#

You can use bindings with modifiers, but there is no way currently to make modifiers disable other actions that are a subset of the binding. You have to do it manually

thorny osprey
#

Yeah but I dont want to prevent another action. I want to call a ui button with another input button

azure storm
#

are you asking about secondary keys do the same thing ?
like multiple keys can trigger same action ?

glass yacht
#

I don't get what you're asking. You can do what you want with the action, you can have multiple action maps if you want to switch between UI and another state that has different usages of the same controls

thorny osprey
#

I have an inventory which is a grid of buttons. Now, I want to do two things with that buttons. If I press key1 when I have the button selected I want to do thing1, if I press key2 with the button selected, I want to do thing2

glass yacht
#

So do different things in those callbacks, you can check which button you've selected and do whatever you want

thorny osprey
#

Yeah, probably Im overcomplicating this

sly marsh
#

does anyone know how I can do this?

distant glacier
sly marsh
astral dragon
#

Input System doesn't work in Console Build?

opal peak
#

Hey, when i try to make a new axis with ctrl and shift it deletes my words for some reason. any clue? cheers

austere grotto
plush stone
#

How can i access the values of this action?

#

I have this code, but the Log outputs 0.0, 0.0

    public void Move()
    {
        Vector2 input = new Vector2(0, 0);
        input = actions.aMove.ReadValue<Vector2>();

        Debug.Log(input);
    }
austere grotto
plush stone
#

Yes

austere grotto
#

Show the code

plush stone
#
    private PlayerActions playerActions;
    private PlayerActions.DefaultActions actions;

    #region Defaults
    private void Awake()
    {
        // Initialize input components.
        playerActions = new PlayerActions();
        actions = playerActions.Default;
    }

    private void OnEnable()
    {
        actions.Enable();
    }
#

I got the other action to work

#

aLook

austere grotto
#

Also why not use a normal Vector2 composite

#

2d composite

plush stone
#

I was following a tutorial but the guy had an option that i didnt

#

Which one are you talking abvout?

#

Oh found it

austere grotto
#

Up down left right composite

plush stone
austere grotto
#

Yeah

plush stone
#

THank you

austere grotto
#

See if that helps

sharp geode
#

are there pre-existing input system actions configured for mobile gestures?

#

for example pinch to zoom with touch -> a float / delta y value?

trim hollow
sharp geode
#

it just seems so... obvious

trim hollow
#

Yeah ik… it’s not too hard to do but it’s a pain to manage concurrency between zoom,pan,rotate,finger release double click :p

sly marsh
#

Hello, what I am trying to do should be very simple but I cannot understand the documentation so I need help. I am trying to get my horizontal_movement action to invoke a move function. However, I have 2 issues, first issue is that the function does not show up as selectable, and 2nd issue is that I do not know what parameters are being passed when it invokes the function. Any advice is welcomed.

sly marsh
glass yacht
sly marsh
#

Nothing happens when I press A or D, not even a debug log, any ideas why?

austere grotto
#

(Also your binding is a 1D float and your code is asking for a Vector2)

austere grotto
sly marsh
#

is it not?

austere grotto
#

it should be
Action Type: Value
Control Type: Vector2

#

And then you can do a 2D vector composite or 4 button composite (up left down right) or whatever it's called with WASD as the binding

sly marsh
#

I'm just trying to do horizontal movement with this action, I'm leaving up and down separate

austere grotto
#

Then it should be
Action Type: Value
Control Type: Axis

#

And your code should be doing ReadValue<float>() not Vector2

sly marsh
#

It still isn't showing the debug log when I press the buttons even after changing the types to what you said

#

It isn't invoking the events at all for some reason

austere grotto
#

Looks like you have a control scheme named "Keyboard"?

#

(i recommend not messing with control schemes until you have the basic stuff working btw)

sly marsh
#

yep, that was it...

#

this list was empty

#

thank you for the help I would've never remembered to check that

lost swift
#

Hello! I get this error when trying to rebind button. I dispose it on complete, but still error appear

#
Unity.Collections.NativeArray`1:.ctor(Int32, Allocator, NativeArrayOptions)
UnityEngine.InputSystem.Utilities.ArrayHelpers:GrowBy(NativeArray`1&, Int32, Allocator) (at Library\PackageCache\com.unity.inputsystem@1.2.0\InputSystem\Utilities\ArrayHelpers.cs:433)
UnityEngine.InputSystem.Utilities.ArrayHelpers:AppendWithCapacity(NativeArray`1&, Int32&, UInt64, Int32, Allocator) (at Library\PackageCache\com.unity.inputsystem@1.2.0\InputSystem\Utilities\ArrayHelpers.cs:360)
UnityEngine.InputSystem.InputControlList`1:Add(InputControl) (at Library\PackageCache\com.unity.inputsystem@1.2.0\InputSystem\Controls\InputControlList.cs:216)
UnityEngine.InputSystem.RebindingOperation:OnEvent(InputEventPtr, InputDevice) (at Library\PackageCache\com.unity.inputsystem@1.2.0\InputSystem\Actions\InputActionRebindingExtensions.cs:2401)
UnityEngine.InputSystem.Utilities.DelegateHelpers:InvokeCallbacksSafe(CallbackArray`1&, InputEventPtr, InputDevice, String, Object) (at Library\PackageCache\com.unity.inputsystem@1.2.0\InputSystem\Utilities\DelegateHelpers.cs:71)
UnityEngine.InputSystem.InputManager:OnUpdate(InputUpdateType, InputEventBuffer&) (at Library\PackageCache\com.unity.inputsystem@1.2.0\InputSystem\InputManager.cs:3244)
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*) (at Library\PackageCache\com.unity.inputsystem@1.2.0\InputSystem\NativeInputRuntime.cs:65)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)

jade acorn
#

why is Right Stick [Gamepad] and Delta [Mouse] greyed out for me in my bindings? I can't select it

austere grotto
#

Does it have Control Type: Vector2?

blissful comet
#

I have a reference to an InputDevice from an event, and I want to know whether it is a Gamepad, Keyboard, or Mouse and I'm not sure if there's an easier way than doing something like Gamepad.all.Contains or something along those lines

austere grotto
blissful comet
candid brook
#

for my 3D game, using built in engine, I am using the "Player Input" script for my game and inside, I have a custom "Actions" (Input Action Asset). UI Input Module (None). etc... This controls my player and its working fine currently. I then have a 2D Canvas for the UI and inside that I have "Input System UI Module" which has Default - for the Input Action Asset (the stock one unity creates).

I try to use my custom input action asset from the player, and it just doesn't work with the mouse or click or anything, but using the built in stock one it works great.

Can I 'mix and match' 2 different input schemes? 1 on PlayerInput.cs and 1 on InputSystemUIInputModule.cs ? Its working right now with the 2 different input action assets but didn't know if I should be using 1 and if i am... why using 1 (the first one thats custom) doesn't work but the default does, i've even opened the default and copied the UI over 1:1 so still not sure on that.

gleaming oar
#

I leave the InputSystemUIInputModule alone since I think it just interfaces with the EventSystem

#

Then for like button UI input I just use the built in Button class and either drag in a script for the onclick event or subscribe one in script

#

I use a single input action with touch and mouse click location setup

#

this works well since they're both a Vector2

sharp geode
#

is there a way to disable the editor default input devices in play mode

sharp geode
#

or is there a way to get the editor devices to be assigned to a user right away?

split bear
#

Can anyone help with making a composite binding? I'm trying to make a single InputAction where the player can press one key from a row to return an int. E.g. for a FPS selector where you press keys 0-9 to select one of 10 weapons from an array, or a MOBA style selector with Q, W, E and R. But I've been fiddling around trying to make my own composite binding and it's not getting anywhere

vague sparrow
#

How can I use images as labels in a dropdown menu?

#

@here

viscid sky
#

Hi. I'm looking at the new input system, and I decided I need a custom composite for my logic (switching gears). The idea is to have space enable the clutch, and shift-ctrl change the gears up and down respectively. The problem is that my composite is stateful, as in it will have to depend on its previous state. Is it stored somewhere, you do I have to just store it in a private field? Also, is InputBindingComposite.ReadValue going to be called every time the input is provided, or every time the input is queried, or just a single time when it's queried and then cached?

#

Here's a sketch to give you a bit more context

public class GearComposite : InputBindingComposite<GearInteractionType>
{
    [InputControl(layout = "Button")]
    public int clutchPart;

    [InputControl(layout = "Button")]
    public int gearUpPart;

    [InputControl(layout = "Button")]
    public int gearDownPart;
    public float timeBeforeCanChangeGearsAfterClutchGetsEnabled;

    private GearInteractionType _previousEvaluatedType;

    public override GearInteractionType ReadValue(ref InputBindingCompositeContext context)
    {
        // TODO: take into account the parameter.
        bool clutch = context.ReadValueAsButton(clutchPart);
        if (!clutch)
        {
            _previousEvaluatedType = GearInteractionType.None;
            return GearInteractionType.None;
        }

        float up = context.ReadValue<float>(gearUpPart);
        float down = context.ReadValue<float>(gearDownPart);
        float sum = up - down;

        if (Mathf.Approximately(sum, 0))
        {
            _previousEvaluatedType = GearInteractionType.Clutch;
            return GearInteractionType.Clutch;
        }

        if (_previousEvaluatedType != GearInteractionType.Clutch)
            return GearInteractionType.Clutch;

        if (sum > 0)
        {
            _previousEvaluatedType = GearInteractionType.Up;
            return GearInteractionType.Up;
        }

        _previousEvaluatedType = GearInteractionType.Down;
        return GearInteractionType.Down;
    }
}
viscid sky
#

I realize that this is trash, because if I have multiple such bindings, they will all refer to separate states of the previous input

rapid kelp
#

If I am using Unity's old input system, how would I go about fully disabling any input from the mouse? I am trying to make the game only have keyboard inputs but if the mouse is clicked on screen, all of my buttons deselect

austere grotto
#

er wait not submit

#

🤔

#

replace your standalone input module with a custom one

#

it's a lot easier in the new input system as there's a simple checkbox to disable deselect on click

rapid kelp
#

I am half wondering if it just makes more sense to just upgrade but I also have no idea how much I need to rebuild to implement that

austere grotto
#

oh you could also probably just remove your GraphicRaycaster from your Canvas

#

that'd probably do it 🤔 maybe

#

er wait maybe not

#

because it's a deselect

#

idk

rapid kelp
#

I tried that and it still has the issue

#

The thing that annoys me is I know I found a fix for another project but cannot remember what it is at all

maiden matrix
#

brand new to new input system can someone help me out? I want to control in code which controller scheme is in use but dont know how. The goal is to switch between gamepad and keyboard, disabling the one not in use based on a setting in the game

maiden matrix
#

thx

cursive oxide
#

Hey guys, was wondering if i could get some help with my implementation of the input system for a touch mobile device. I have a couple problems with my current implementation.

What i wish to achieve: Have 2 joysticks in left and right bottom half of screen that are floating and can create a new anchor point wherever the player taps. And to have the top half of the screen be a "swipe region" that can detect swipes.

Current problems: 1. The joysticks aren't floating. They're fixed in place. Im using the input system On-screen stick component script, which is uneditable so im not sure how to go about it. I actually tried just importing the script from the floating joystick in that free asset on the asset store (called joystick pack), and its very promising but the handle jitters back to the center of the background every couple seconds. I think this is because the on-screen stick and floating joystick scripts are in conflict, but i would need the on-screen stick component still in order to read the input as movement.

  1. secondly, my swipe region works but not if im currently using the joysticks because im currently touching the screen so it just exits the script basically. Not sure how to fix this while staying in the input system, because id like for users to easily switch to a bluetooth controller if they want.

Thanks, sorry i know thats a mouthful. Just really stuck on this core issue of the game and its hard to test my builds until this is all working smoothly

summer sky
#

hi i created a project using the fps core template, how do i go about adding more controls? I can add to the action map, but im not sure how to create them in the existing files for use in other scripts

slate fiber
#

what is the recommended way to use new input system
unity events or c# generated class?

#

i watched a tutorial that says use unity events but i dont want my methods to be public

#

it doesnt feel right to make them public

indigo patrol
#

Depends, if you want to do it manually, you can do so

InputSystem.onEvent
        .ForDevice<Keyboard>()
        .Call(ctrl =>
        {  
            foreach (var button in ctrl.GetAllButtonPresses())
            Debug.Log($"{button} was pressed");
        });

Judging by how you worded your question, I don't think you want this method. So yeah just stick with what Unity told you or most tutorials you can find out there

#

if you for some reason want to go with the snippet above, just make sure to dispose it (onscenechange/disable etc) with IDisposable

spiral galleon
#

The events is more of a designer way of assigning controls to things

indigo patrol
#

the good thing with new inputSystem, if you chose to ditch out the generated class and prefer to handcraft it yourself, you can do so and make your own reusable template in form of c# classes, sorta like a compact library which you can use for other projects.

I personally don't like the generated-class thingy it's not that straight forward and too many steps just for an inputsystem

visual tapir
#

Hello there, newcome here, having a spot of trouble getting the settings working right.

I'm on the new InputSystem v1.3.0 - I'm getting the left stick (Gamepad) and Mouse delta to work fine for movement and camera change respectively, however for some reason the keyboard is not doing anything. A debug logger is showing that it's simply not activating the sendMessage OnMove() or OnLook() method through these systems.

Any ideas what I may have done wrong. I copied the composite vector layout of the InputSystem default structure but even the default fails to provide any inputs.

    private void OnMove(InputValue movementValue) {
        movementVector = movementValue.Get<Vector2>();
        Debug.Log("Movement Vector: " + movementVector);
    }

    void Update()
    {
        ...
        // Surface Movement
        Vector3 move = transform.right * movementVector.x + transform.forward * movementVector.y;
        controller.Move(move * moveSpeed * Time.deltaTime);
        ...
    }

So the above works with Gamepad left stick, but the keyboard is not recognized. Then the mouse works fine to look around, but the right stick does nothing!

I set the Input System component on both the Player and the Camera objects and I have mapped all the necessary controls using the same Actions (Move and Look) creating a Composite Vector2 for the keyboard.

edit: auto-switch is enabled for both player and cam, not that it matters given that the joystick has one stick working and the other not.
My working theories atm are that using the same Input System on two separate objects might be bad for whatever reason, or there's some quirk with the InputSystem that's escaping me.

Appreciate any help

#

And I setup the numpad on keyboard for view and both mouse delta and numpad gives me a valid vector2 to look around. Right stick still not doing anything tho. Left stick lets me move but neither WASD nor Arrow Keys do anything. The method is simply not triggering for them. I'm very confused.

cursive oxide
#

Does anybody know how to extend the OnScreenStick component from the input system to make my joystick a floating joystick?

austere grotto
#

define "floating joystick"?

cursive oxide
#

A floating joystick is where the center point spawns in where your finger touches and then locks in place until u lift up ur finger. Then it returns the transform back to starting vector

#

Should be fairly simple code but i don't know how to either edit the onscreenstick script, or make an extension of it in some way

cursive oxide
thorny carbon
#

Hey I'm a super noob so I was just wondering if there was a way for me to add both k&m and controller input to my game and if there is would someone be able to link me to a way to do that TYIA

gleaming oar
#

Yes, you can create an input action asset with both m/k and controller inputs and handle them in the .performed events. Check out the samyam videos on youtube

thick yacht
#

does anyone know where is the 2D Composite Axis? Is it removed or my editor is bugged?

summer sky
#

hi i created a project using the fps core template, how do i go about adding more controls? I can add to the action map, but im not sure how to create them in the existing files for use in other scripts

#

i've added the control in the templates action map but im struggling to see how on earth to use it in a script

languid current
#

Do u have an answer yet

languid current
visual tapir
# visual tapir Hello there, newcome here, having a spot of trouble getting the settings working...

From the above problem that I had, I ended up redoing everything step by step and successfully got both keyboard (WASD) and Mouse (Delta) as well as Joystick (LStick and RStick) to control movement and camera respectively. What I don't understand is why the moment that I introduce Control Schemes, everything goes wonky. Is there some known bugs related to Control Schemes? It's making little sense to me how half the controls stop working and then other things start working.

thick yacht
visual tapir
languid current
visual tapir
languid current
#

how..

#

how tf

languid current
visual tapir
#

Action "Move" should be Value type, not Button

languid current
#

value type tf!?

#

I don't understand i need dumber code english please xD

visual tapir
#

Not sure why they call it that, It seems to span a range of inputs.

languid current
#

so how do i make it a value type

visual tapir
#

Go on the action, up top above the binding

#

And change Type to Value

#

It will accept a 2D vector as is shown in that screenshot where I setup WASD to be mapped as a composite 2D Vector

#

Currently everything breaks for me when using Control Schemes, so maybe best avoid those too unless you know what you're doing. I'm not in that regards.

visual tapir
# languid current

Not sure how those are your options when it's set as Value, try the Save Asset option?

austere grotto
thick yacht
#

ah, so that's where it goes, and it's now named 'Up/Down/Left/Right/ Composite'

#

thx guys! UnityChanCelebrate

raven onyx
#

clicking the button unity gives when you have old input system enabled with the input system package will not save the new changes if you didnt save?

sharp cloud
#

Greetings,
I hope this is the correct channel, as it could fit in some others too.
We are currently developing a webgl racing game.
Currently we are having troubles with the mobile controlls (When you play the game in an mobile browser)

Problem is, that we have multiple buttons for the controlls (see image)
and each of those is using the Event Triggers PointerUp Down and Exit.

The called Method(s) just toggle different bools depending on which button is pressed.

public void OnPressGas() { Debug.Log("OnPressGas"); isGasBtnDown = true; }

While this works so far, there are issues with pressing and releasing multiple buttons in different orders.
For example if you press the "gas" button you drive forward. Now while stil pressing the gas button and then pressing the left button for example
the car drives forward and left. But now if you release the gas button while stil pressing on the left button, the car stil drives forward left.
I added some console logs and the PointerUp and PointerExit buttons only trigger for the last pressed button.

I hope I explained it right. I searched for a few days now how to fix this and couldn't find an working answer.
I tried removing not needed Raycasts from hud elements and also the solutions discussed in this forum topic: https://forum.unity.com/threads/onpointerup-occasionally-doesnt-fire.435230/
I hope someone here can help. Thanks in advance 🙂

raven onyx
austere grotto
austere grotto
#

but it may still be an issue with your code too

raven onyx
pulsar lion
#

So I'm trying to make your standard "right-stick-controls-camera" type thing, and with what I have; input just appears to not be working at all lol

#

this is what I have in my code:
actions.Gameplay.Camera.performed += ctx => targetOffset = ctx.ReadValue<Vector3>();

#

and TargetOffset doesn't change at all

austere grotto
#

that's going to report the current mouse position constantly

#

and probably screw with the stick input

#

When you want to get to mouse input, mouse delta makes a lot more sense there than mouse position

pulsar lion
#

oh gotcha

#

ok so I dropped the for now I'll work on the mouse later

#

however it still doesn't appear to work

#

lemme show my entire code

#

oh nevermind just realized I can't read Vector3 from the right stick

austere grotto
pulsar lion
#

nah I know what I need to do (just use Vector2 instead lol, I don't need the player to be incontrol of all 3 axises for the cam lol)

pulsar lion
#

oh actually I was wrong lol

#

so the basics of this are working

#

however its very... drastic

#

I'll upload a gif in a sec but here's the code

#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class CameraFollow : MonoBehaviour
{
    public Transform Target;
    public Vector3 targetOffset = new Vector3(0, 5, -10);
    // Start is called before the first frame
    // 
    public PlayerActions actions;
    Vector2 inputOffset;    
    private void Awake()
    {
        actions = new PlayerActions();
        actions.Gameplay.Camera.performed += ctx => inputOffset = ctx.ReadValue<Vector2>();
        actions.Gameplay.Camera.canceled += ctx => inputOffset = new Vector2(0, 0);
    }

    // Update is called once per frame
    void Update()
    {
        FollowTarget();
    }

    public void FollowTarget()
    {
        if(inputOffset.x != 0)
        {
            targetOffset.x = inputOffset.x * 20;
            targetOffset.z = inputOffset.y * 20;
        }

        Vector3 targetPosition = Target.TransformPoint(targetOffset);
        //targetPosition.y += 5;
        
        //targetPosition.z -= 10;

        //transform.position = targetPosition;
        transform.position = Vector3.Lerp(transform.position, targetPosition, Time.deltaTime);

        transform.LookAt(Target);

    }

    private void OnEnable()
    {
        actions.Gameplay.Enable();
    }

    private void OnDisable()
    {
        actions.Gameplay.Disable();
    }
}
#

I'm also trying to impliment it so when I lay off the input it stops moving

#

doesn't really work

cursive oxide
#

Still haven't found the answer: How do you read swipe detection with the new input system when you're already touching the screen? Users will be using a joystick with one hand and can use the other thumb to swipe. My implementation works right now but only if im not touching the joystick already because im only accepting swipes on the top half of the screen and accepting joystick movement on the bottom half. The swipe detection script returns because its reading my touch on the lower half already

gleaming oar
#

Kinda depends on what you want the swipe to do, but typically first you'd differentiate a swipe from a touch by checking for a drastic change in position of the finger while held down. Then just keep track of the change in distance between the original touch position and the position when the finger is lifted

cursive oxide
#

Well that is what im doing. My swipe detection works just like that

gleaming oar
#

So once your touch[0] is using the joystick swipes dont work

#

so you could listen for swipes on other finger touches

cursive oxide
#

not sure how to post code in here its getting auto deleted

gleaming oar
#

just pastebin it

cursive oxide
#

Never did that before i think that worked

radiant shard
#

hi how can get input of keyboard while i am in editor mode

austere grotto
#

are you just trying to make a hotkey to do something?

radiant shard
#

        if (Input.GetKeyDown(KeyCode.W))
        {
            direction = Vector3.forward;

        }
        if (Input.GetKeyDown(KeyCode.S))
        {
            direction = -Vector3.forward;
        }
        if (Input.GetKeyDown(KeyCode.A))
        {
            direction = Vector3.left;
        }
        if (Input.GetKeyDown(KeyCode.d))
        {
            direction = Vector3.right;
        }
``` i want to perform this in editor scripting
austere grotto
#

what are you doing with direction?

radiant shard
#

direction of movement

austere grotto
#

movement of what?

radiant shard
#

capsule

austere grotto
#

You know Update doesn't run in edit mode

radiant shard
#

onSceneGui

austere grotto
#

why are you trying to make gameplay work in edit mode 🤔

radiant shard
#

going to play mode for everystep is time consuming

austere grotto
#

i don't see how this is generally useful though - it'd be completely different code than your actual gameplay movement code

radiant shard
#

i just trying to learn

austere grotto
#

As someone much more experienced in Unity - I think this is counterproductive. Stick to writing actual game code and entering play mode to test it

#

only write editor code if you're making tools for the editor

radiant shard
#

ok

bitter geode
#

how do i replace the old input node with the new input system one?

languid current
radiant shard
#

how can i check number of input key is pressed , like i pressed W and D , then it should show 2 event

molten nest
#

if I'm using sendmessages and I have a button event called PlatformJump I should just be able to have a function somewhere in my movement script called OnPlatformJump(InputAction.CallbackContext context) right?

#

because for whatever reason it's not outputting anything at all, and more confusingly it's logging errors that then aren't showing up in the console

cursive oxide
#

I finally got debugging up and running on my android and its not even recognizing my swipe as an input if another finger is touching. Is it something to do with the setup of my actionmap?

languid current
#

how do i generate a c# class with the new input system i'm using lts for 2020

molten nest
#

When a new player instance is created via the input system duplicating a prefab (in the case of local multiplayer) is there any way to fetch that new instance? I need to write data into it and I have no idea how to get it consistantly

visual tapir
#

I'm planning to shift to the Unity Event

frigid ridge
umbral plover
#

Why does the player input component show up as an icon and how can I stop it from doing that?

umbral plover
#

thanks, that had been bugging me for a while

radiant shard
#

someone ping me ?

ocean hawk
#

anyone encounter this and know of a workaround, or if it's fixed in later versions? I'm on 2020 lts

cursive oxide
#

Can someone please help me understand how to read a swipe action on a touch screen with multiple fingers on the screen?

reef frigate
#

Does anyone know how to fix this problem I'm having at the moment
I'm trying to create input rebinding that works from a scriptable object everything seems to go good until i actually do the rebinding operation where I get this error:
InvalidOperationException: Cannot rebind action 'Gameplay/Jump[/Keyboard/c]' while it is enabled (There is more but it doesn't seem important to this issue)
so the problem I having is I want to be able to disable my current input map but I dont want to have a reference to PlayerInput as then it defeats the purpose of having this be a scriptable object

near raven
#

Is anyone working with their notification behavior to Invoke C# Events? I'm trying that approach and it interesting but i am unsure if i am going about it correctly. I am able to use the generated c# class from my Input Actions asset and just get rid of the PlayerInput Component. Then I just work with the Input events directly in code using the interface provided by the generated c# class. ill post an example

languid current
near raven
cursive oxide
#

none of those pictures show you clicking on the asset

languid current
#

oh im dumb

languid current
near raven
#

I figured showing the asset open next to the inspector would be a more clear to show what I was talking about

cursive oxide
languid current
cursive oxide
languid current
#

I was meaning the PlayerInput.inputactions thing xD

#

sorry its a bit weird as i am still quite new but ah well xD

cursive oxide
#

All good

near raven
#

Well technically it could be anywhere. It depends on where you created the input actions asset

cursive oxide
#

How could it be anywhere other than assets folder or a sub of it

languid current
#

either way im that good i fucked up following a tutorial xD

near raven
#

Idk it gives you the option to choose where it is created when you make a new input actions asset. I'm not an expert just trying to help

languid current
#

https://pastebin.com/H16t8q7h - PlayerMotor script
https://pastebin.com/4z5E4m7x - InputManager script

#

Just won't move not sure why

#

sorry if its a basic thing i've screwed up, i was following a tutorial idk tho

cursive oxide
near raven
cursive oxide
near raven
# cursive oxide I was able to accomplish using the generated script following a tutorial and eve...

Yeah the documentation from unity doesn't dive very deep on it either. Just curious but were you able to use the interface that the generated script makes? It's how unity recommends using it but I haven't found any tutorials that actually use it. But I was able to get it working and using the interface seems to make the rest a lot more simple (as in getting access to all the actions and their callbacks)

cursive oxide
languid current
#

sounds about right lol

near raven
#

If you open the generated c# script then go all the way towards the bottom you should see an interface for each action map

#

It simplifies setting up callbacks

#

But I haven't found any tutorial or anything that uses it. It's crazy

cursive oxide
#

I'm so fed up with this i thought its such a simple problem but i cant find anything about it online. How to set up multiple touches so swiping can be detected on the second finger to touch the screen. Im about to give up

near raven
#

Hmm yeah I wish I could help you there

cursive oxide
#

I just had an idea and its probably dumb and might not work but im gonna try this in a last ditch effort

#

What if instead of reading swiping, I make a 3rd joystick that has no image but takes up the whole part of the screen i want to detect swiping. This should work but im not sure if having a 3rd joystick is doable, at least for me to do lol

near raven
#

Ayyy if it works it works lol

near raven
languid current
#

nani?

#

My code brain is stupidly small xD

near raven
#

You have
motor.ProcessMove(onGround.Movement.ReadValue<Vector2>())

Maybe try

Vector 2 moveDirection = onGround.Movement.ReadValue<Vector2>();
motor.ProcessMove(moveDirection);

#

Something like that

#

Sometimes caching the value before using helps me

languid current
#

alrighty

cursive oxide
#

Why did no one tell me

#

that you can use your right click as a second touch point. This makes testing so much easier

nova temple
#

How would I code a 2d roll animation for a player?

bitter anvil
# nova temple How would I code a 2d roll animation for a player?

I think you need to use the animator. I learned that from this part of a unity course: https://youtu.be/b8YUfee_pzc?list=FL4PXCnzqwGEscOwR6aE3Gbg&t=15212

This is a full release of an Top Down RPG course made in Unity 2017

0:00:00 - Intro
0:01:31 - Setting up
0:16:03 - Moving and Manual Collision Detection
1:03:06 - Tilemap and Designing Dungeon
1:40:31 - Interactive Objects and Inheritance
2:15:37 - Saving Game's State
2:41:31 - Floating Text System
3:11:11 - Top Down Combat System
4:13:32 - Ani...

▶ Play video
#

Do you guys have an answer for my question? I've spent about 6 hours in the past 3 days and I can't figure it out.

I'm trying to stop the character (Polygon Collider 2D) from moving through a wall (Tilemap Collider 2D).

1 var hitResults = new RaycastHit2D[10];
2 var hitX = collider.Cast(new Vector2(desiredX, 0), bodyFilter, hitResults);
3 //var test = new Collider2D[10];
4 //hitX = collider.OverlapCollider(bodyFilter, test);
5 if (hitX == 0)
6 {
7     transform.Translate(desiredX, 0, 0);
8 }

Why does the character not stop moving horizontally when I run the code like this? I proved the character can collide with the wall because it does stop moving horizontally when I uncomment the two lines (3&4).

mortal ridge
toxic folio
#

so... I have a tenny tiny problem...

#

in the player events, only the monoscript is showing up

toxic folio
#

nvm... I figured out

toxic folio
#

how do I fix this?

mortal ridge
mossy roost
#

Hey there, I have a bit of a problem. For some reason Unity Input System doesn't detect me pressing any keys on my keyboard.

#

Any advice on this?

toxic folio
#

The new input system handle input actions differently (I'm still learning it, so I can't be of much help)

timber bronze
#

I'm making a game with a Health bar and a Stamina bar but when i want to assign the stamina bar to the playing it will only let me select the health bar, can anyone help me?

#

the second one needs to be stamina bar but when i put it there nothing happens

cursive oxide
#

How do you use a gamepad to navigate to different elements in the UI? My controller can navigate to through the pause menu because i set up the resume button to be the starting button. But what if the pause menu is inactive and i want to navigate from a second panel?

austere grotto
near raven
#

Anyone familiar with working with the generated c# script in the new input system?

#

And using invoke c# events notification behavior

austere grotto
#

Which would be a different approach from using the generated script

near raven
#

Oh hmmm I've been a bit confused with it. I actually was able to just get rid of the PlayerInput component and just write an input script that inherits from the generated c# script, so I have access to an interface that lets me easily access the callbacks for each of my actions. But I haven't found anything that goes about using it the way I have.

#

Anyone I've seen use the generated script manually registers the action maps and everything but not use the interface that it provides to do it.

#

I thought that using the generated script was considered invoking c# everts since it was all dealt with in code

austere grotto
near raven
#

A little bit yeah, what I'm focused on is using the interface from the generated c# script. That's all I really want to get figured. How come nobody uses the interface?

austere grotto
#

Some people use it

#

You have to use the SetCallbacks(myListener) method on an instance of the generated class

near raven
#

Oh yeah I've got it working for the most part. I'm just unsure of how to properly work with the callbacks I guess. Here is a chunk of my code to show how I've got it set up.

austere grotto
#

The interface will force you to implement some functions

#

Those are the functions that will be called

near raven
#

Yes, the functions are all the actions that were created in the actions asset. Like, my "Player" action map has an action called "Move" so it has a corresponding "OnMove" function from the interface.

#

My confusion is how to properly write code inside the functions using the callbacks

austere grotto
#

Wdym? What's confusing you?

near raven
#

I've just been figuring it all out through trial and error. I can't find any documentation or tutorials on the way im doing things with the generated script. Weird stuff happens when I refactor like I move a lot slower for no reason. Also, figuring out how all the callbacks get called when you trigger a function and how to correctly work with them

austere grotto
#

It works the same way as the others

#

You get a call to your function when the actuation of the input changes

#

(it's also dependent on which interactions if any you've used on the action)

near raven
#

Ok I guess I'll go through how the other ways work and figure out the callbacks. Do you have any recommendations for a tutorial that demonstrates working with the callbacks and possibly linking the input to other scripts. (i.e. input script working with a weapon script or something? ) or maybe getting like a charge up action to work? (Like charging a gun to shoot a stronger bullet)

#

I bought some courses and books to try and learn this but they seem to like these old input system and use it instead but I'm determined to just use the new system

candid brook
#

trying to revert to Old input system in my game, and it seems like Unity just "HATES" my xbox controller and has a hard time in windows / unity as making it the primary controller. is there a way to check or see on OLD?

#

like in windows i have 2 or 3 controllers showing becuse i have a keypad gamepad that it thinks is a joystick as well, so i remember back in the day when i started old input system was a PITA to get it to be primary

#

i dunno if i had to run sTEAM and make my xbox controller the stock or what i had to do, but its not fun. any thoughts?

#

i can't expect people playing my game to pull keypads and joysticks out and plug in wireless or a certain port

candid brook
#

its showing up as "Xinput Gamepad 2"

left estuary
#

Hello! has anyone used the input system for counting steps (pedometer) yet?

candid brook
#

solved partially my issue by going into device manager, and removing all gamepads and drivers and rebooting, somehow i had a xbox 360 gamepad driver in there (from razer) which is even more odd, not sure if that was from razer or from xbox 360 years ago, etc. but now my gamepad is player 1 so were good for now

thick yacht
#

is it possible to get which key pressed from CallbackContext?
ex: ctx.aKey.WasPressed

candid brook
#

How do i switch back to the old input system? I set the player setting to old, uninstalled the new, but when i try to do anything my Event SYstem is telling me that I am using the new input system and the old system is disabled

mortal hedge
#

Hi, I've been having an input rebind problem for several hours now. Basically I want to be able to change the bind of the New Input System, so I use the scripts provided by Unity in their "Rebinding UI" sample but unfortunately when I press a key nothing changes, after investigation it seems to be the action.PerformInteractiveRebinding function that doesn't work properly. Has anyone encountered a similar problem?

austere grotto
austere grotto
candid brook
#

i think it was because I had an addon that was using new input as a dependancy

#

so when i removed all the addons that need new, now it works, or at least the error is gone

#

thanks

lavish schooner
#

Hey, quick question: is Input System 1.3 verified for Unity 2020.3? In the Documentation it says it is, but in the package manager the last verified version appears to be 1.0.2

verbal remnant
lavish schooner
#

Like, do I NEED to update to the latest patch for it to be verified? Or is this just a aesthetic thing (the "verified" tag not showing up in the package manager)?

stable coral
#

ok so im still having some issues with the fact that my kb and controllers are vector2 but my joystick is an axis (float). should i just add them together like

float inputval = controllerAction.ReadValue<Vector2>().y + joystickAction.ReadValue<float>();

or is there a fancier way in doing this?

#

because having overload functions look nasty

#

or should i go with overload functions either way? i cant decide

verbal remnant
austere grotto
brave burrow
#

do you need to use the input system window or can you just do everything through c# alone?

brave burrow
#

nvmd, found what i needed

#

i think

brave burrow
#

nope still stumped. I personally don't want to use the input system and define all the buttons in the input manager, I'd instead like to use the raw code versions of the input code and just check those instead. however, I can't find a clear answer as to how you use the raw code versions of the inputs. is there any documentation on how to get the raw values?

stable coral
#

Idk my joystick is really weird since i’m using a specific variant which most of the times doesn’t even show up on the list

#

And according to the input debugger, it spits out a float value and not a vector2 value afaik

high crystal
#

I'm using the old InputSystem and Unity 2019.4 . Currently trying to get multi-display input working. From what I have heard and read, the second display is expected to be in fullscreen all the time. I have hacked my way out of this using windows specific commands (user32 stuff). The problem is, this completely messes up the mouse coordinates (I seem to get them relative to the main display). I think I could fix this, but I would have to be able to manipulate the mouse coordinates before they are sent to the UI/Canvas. Or send my own mouse-events. Is there any way to achieve this?

rare summit
#

simple question: is there a tutorial on how the controller axis are managed? i don't know how to access the right joystick.

indigo patrol
rare summit
#

none of the tutorials found helped, all were off, so i stumbled into a solution.

#

guessing blindly how stuff works is faster than good tutorials.

austere grotto
stable coral
#

@austere grotto this is what is displayed when value is set to vector2 (first image with only 2 options) vs then value is set to axis (second image with a whole lotta more options) slider is the one i need (third image with it highlighted)

candid brook
#

I see you can run new and old input modules at the same time. Would a valid use case for this to be running a character controller in the old input (like rewired or built in) and then running the UI in the new input system?

austere grotto
#

Or when you have a third party asset/plugin that uses the old system that you cannot modify

#

that said you can do whatever you want

candid brook
#

I was using 100% new, but i was having some issues with the xbox triggers as buttons and etc etc, so as a temporary fix the old input works on it no problems, so i switched to that, but my UI uses a 3rd party library that only runs on new, so i needed both.. took a bit of fiddling to get them to work but they do now after a bit of trial and error. I can check back on the new input in the future when i have some time to get a workaround etc

#

one quick question, is there a github or a bug tracker / changelog / etc for new input that i can go see outstanding issues and things planned ?

bitter geode
#

how do i replace the old input node with the new input system one? there's no in-flow on the new node

final geode
#

Hey I am having an issue that Im not quite sure even how to debug....

When I restart my game, in game via script by loading a temporary scene, then unloading all scenes, then loading into my title screen.... my PlayerInput module, which is supposed to be sending out C# events, no longer does so. its functioning fine otherwise, nothing looks wrong in the Input Debug window... but scripts that have subscribed to the events its supposed to send out just aren't doing anything... I'm not sure if the PlayerInput component has stopped sending out the events, or if the problem is on the subscribers end... I've been trying solutions to this for hours and I'm stumped

#

I made a test that that just subscribes and debug logs, on the same GameObject as the PlayerInput component, and even that stops working after the reset

#
public class PlayerInputEventTest : MonoBehaviour
{
    [SerializeField] PlayerInput testInput;
    private void Awake()
    {
        testInput.onControlsChanged += TestInput_onControlsChanged;
    }
    private void TestInput_onControlsChanged(PlayerInput obj)
    {
        Debug.Log("Test Input event log");
    }
    private void OnDisable()
    {
        Debug.Log("test input Obj disabled");
        testInput.onControlsChanged -= TestInput_onControlsChanged;
    }
}```
mortal ridge
bitter geode
#

Like “if pressed/active” then do thing

mortal ridge
#

should literally be just like that. if input then do..... you just don't need the if anymore

bitter geode
#

Actually let me try using the button node instead, I assumed they were for button events only

#

Oh true

brave burrow
#

what would be the code way to handle inputs? no input manager, just using UnityEngine.InputSystem & the classes inside of it.

#

ik there'd be a bit of set up involved but I'm personally trying to use just code for now since that's the environment I'm most comfortable in

tame oracle
#

question what is

ArgumentOutOfRangeException during event processing of Dynamic update; resetting event buffer
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)

#

what does it mean

mortal ridge
mortal ridge
tame oracle
brave burrow
mortal ridge
#

you always need an input action. either that being an asset or a self constructed one from json

brave burrow
#

There's no code in Unity's InputSystem namespace that I can use to directly refer to a keyboard key?

mortal ridge
#

no. that's exactly the point of the new system

#

also that would be the worst thing to use the new input system for. if you want that behaviour, use the legacy input manager

brave burrow
#

got it, will they eventually phase out the old one entirely or will you always have direct access to the devices?

tame oracle
#

can anyone give me a clue as to why when i use a keybinding on keyboard it works but if i use the same binding of the gamepad it wont?

mortal ridge
mortal ridge
tame oracle
#

didn't work these are the 3 errors i am getting

#

is the picture showing?

#

can anyone help me with this?

lost swift
#

Hello! Is there a way to cancel binding from method?

#

Is there a way to press button through script?

tame oracle
#

you'll see what you're looking for

#

also people... I found the cause to my problem, i need someone to help me if they have an idea :
the cause of the problem is that i made my button turn off its parent game object... so when I press it I get those errors... any idea on how I deny that from happening... or am I obliged to change the hierarchy so the button wont turn off its parent

brave burrow
#
    type[] keyboard = new type[2];
    
    //Readonly Keyboard Array
    void KeyboardReadonly()
    {
        keyboard[0] = true;
        keyboard[1] = "Keyboard";

        if (keyboard[0])
        {
            Debug.Log(keyboard[1]);
        }
    }

    void Update()
    {
      KeyboardReadonly();
    }

is there an array type that would work for the following?

chrome walrus
#

Not sure why you want a bool in the string array

cursive imp
brave burrow
austere grotto
#
public struct MyStruct {
  public bool someBool;
  public string someString;
  public int someInt;
}

MyStruct myData;

void InitData() {
  myData.someBool = true;
  myData.someString = "Keyboard";
  
  if (myData.someBool) {
    Debug.log(myData.someString);
  }
}```
brave burrow
#

gotchu ty

chrome walrus
rare summit
#

Does anyone have a solution for emulating a second controller?
I wanna make a 2 controller game, but only have one

dusky wharf
#

@rare summit you can use the On-Screen Button / On-Screen Stick components, assign them gamepad inputs

#

not all of them work right, but some do, 2 that worked ok for me were PlayStation Controller and WebGL Gamepad

lucid crystal
#

Heyy! Im not sure if this is the correct channel to ask this, but where exactly can i find the "capabilities" section for android in player settings? I need to make a prototype with microphone input and i need to enable it but i cant find it.

rare summit
#

the input system is very confused. it made 3 players

#

i tried to make a multiplayer game, with a player on controller, one on keyboard and mouse, but it seems keyboard and mouse both generate a new player, is there a way to stop that?

#

did i set this up wrong?

dusky wharf
#

@rare summit yeah, just dont use one of those 2 fake controllers you just created with On-Screen buttons

rare summit
#

no, this is me trying with keyboard and my controller.

#

the first screenshot is my player.(3 of them)

#

now im having troubles with unity not running lines of code, im so confused.

dusky wharf
#

check you Control Schemes in the Input Action Asset, add both mouse and keyboard into a single scheme if you want them to be treated as one

rare summit
#

should this all be considered one controller

#

so the way this runs is..

#

it detects a click: spawns a player
it detects a keyboard input: it spawns another player
it detects any button (not joystick) from a controller: it spawns another player

dusky wharf
#

that's your actions, top left you have a drop down for control schemes, check what you have there

lavish bluff
#

Character with Player Input is set to DontDestroyOnLoad

#

But when another scene is loaded, the input is disabled

#

What to do?

lavish bluff
#

NVM, I just had to remove the preexisting player character in the other scene

lost swift
safe wedge
#

Hey guys for some reason when I use if(inputaction.triggered) it doesn't work if i press the button too quickly or too slow

safe wedge
#

it's in the fixedUpdate

austere grotto
#

you shouldn't be reading input in FixedUpdate

safe wedge
#

Thank you

lavish bluff
#

OK, now I'm getting an issue where the player character doesn't receive input if it's instantiated rather than in the scene from the start

gleaming oar
#

how are you assigning input

mighty spire
#

I have setup the new input system to use the main camera to raycast where the player has touched on the screen, are there better ways of doing this without needing the camera?

turbid saffron
#

1: Why does my package manager only see Input System version 1.0.2 despite the documentation stating that the latest version is 1.3.0?
2: Why is "Background Behavior" missing from my Input System Package settings?
I am using Unity 2021.1.25f1

austere grotto
#

You might need to be on 2022 to use the latest version of input system

turbid saffron
#

If I change versions it also shows 1.3.0 as being supported by 2019.4+

austere grotto
#

seems convincing, not sure why then

indigo patrol
#

You can add package by name manually, it would probably work, I did this for 2021 to get version 1.3

#

backup 1st!

#

the doc a bit outdated, but still similar

olive mortar
#

im using the rebinding tool made by unity with the new input system... Does anyone know what this field does?

visual tapir
#

I have a question regarding the new input system in general and what's the "ideal approach" to using this. For example inputting a Jump action by varying height based on how long it's held.

  1. Should we be using the Invoke Unity Events option or is there nothing worse with the default Send Messages?
  2. Is there something internal to the Input System that allows to track a "held" action as opposed to constantly checking frame by frame that it's still pressed?
  3. Any examples that demonstrate a recent implementation of this behavior for the new system? The example I found doesn't appear to handle a logical hold.
chrome walrus
visual tapir
chrome walrus
#

You can hook into all of those Disabled The Action is disabled and can't receive input. Waiting The Action is enabled and is actively waiting for input. Started The Input System has received input that started an Interaction with the Action. Performed An Interaction with the Action has been completed. Canceled An Interaction with the Action has been canceled.

visual tapir
#

Am I right in thinking this video by Samyam is up to date: https://www.youtube.com/watch?v=m5WsmlEOFiA ?

How to use the new input system in Unity! I go over installing the package, the different ways to use the input system, and the recommended way!

📥 Get the Source Code 📥
https://www.patreon.com/posts/55295489

►🤝 Support Me 🤝
Patreon: https://www.patreon.com/samyg
Donate: https://ko-fi.com/samyam

🔗 Relevant Video Links 🔗
ᐅALL of my Input System...

▶ Play video
#

On Input System v1.3.0

#

It demonstrates v1.0.2, not sure how far off it is

chrome walrus
#

Neither do I, sorry. But basic stuff should work properly I guess

visual tapir
#

Thanks, I understand

somber dirge
#

Hello there 👋
I'm trying to achive a pretty complex input system (with the New Input)
the player controller is a TP and with AWSD I can control the character as usual, what I would like to achive is to play "dodge" animation on double-tap on AWSD too
dodge/roll ... you know what I mean.

mortal ridge
#

add an interaction

somber dirge
#

I guess I could count how many ms pass from the first tap to the second, to know if the user wand to move or dodge

mortal ridge
somber dirge
#

umm ... ok but then what?

#

when I double press the S the character turn to the camera direction

#

and then roll

mortal ridge
#

check which interaction was activated

somber dirge
#

I need to avoid that

#

is the Input Order relevant in the editor?

#

I could place the double-tap for first

mortal ridge
#

i think it's relevant

hot gale
#

Hello. I written a code for simple character moving. My character is for some reason going backwards even i am not holding "s". I think it is something with input cause i tryed following tutorial from brackeys too and everything was good but chaacter was automaticly going backwards. Can someone help please?

somber dirge
#

Anyway, debug is always the best solution to figure out what is going on.

hot gale
#

Hmmmm

hot gale
chrome walrus
hot gale
#

Okay

#

Jus a sec

chrome walrus
hot gale
#

here is the script

chrome walrus
hot gale
#

no

#

I will try

#

wait

#

how

#

i am new at this

chrome walrus
#

I advise you to get into unity learn platform and put some time in there to learn what is doing what. Will make you rlife easier 🙂

hot gale
#

bro i tryed script trough tutorial and it is still moving backwards please help @chrome walrus

#

literally it is fifth script

#

like i even tryed to download free movement asset from asset store and it is not working

chrome walrus
#

My point stands, I can't handguide you through that tutorial or any other basic stuff. You should learn super simple stuff first before going into youtube and do a tutorial about a fullgame. Learn how to debug to see, what your code is doing.

hot gale
#

D :

somber dirge
#

each one respond based on the input event.

#

xD

#
        {
            return phase == UnityEngine.InputSystem.InputActionPhase.Started;
        }```
#

for example, here you the InputActionPhase is used when the user Start Pushing the button

#

but you have also .Performed which means during, and so if you use it, it will works like a toggle, so once you push a button it will trigger your event without canceling.

hot gale
#

where do i change this?

somber dirge
#

and then there is .Canceled which means you move out your finger from the button

hot gale
#

I should do it in the movement script?

somber dirge
#

did you write your own code? 🤔

hot gale
#

yea

somber dirge
#

You should know where it is xD

hot gale
#

i dont use it

somber dirge
#

keys.Player.Movement.performed += i => moveDirection = i.ReadValue<Vector2>();

this is a typical Input System subscripton

#

in that case it read a value, but it could be also like...

hot gale
#

but i dont have this in my script

somber dirge
#

keys.Player.Lock.started += i => lockInput = true;

To toggle a bool

somber dirge
hot gale
#

ok

somber dirge
# hot gale ok

CodeMokey does a pretty nice tutorial about the New Input System, also Brackeys didn't make any tutorial so his stuff is pretty old rightnow

hot gale
#

okay ill try that

blissful comet
#

How would you go about detecting a "Smash", that is, moving a joystick very quickly in a direction very hard? Is there a processor or anything you could do to determine a stick smash, or some sort of code you could do? I need a way to detect a smash separately from normal joystick so I'd need something that wouldn't read when:

  • moving the joystick slowly to maximum over several frames
  • Moving the joystick quickly but only halfway
  • Starting from a halfway position, then moving quickly to the edges

How might I go about programming something like this?

mortal ridge
#

I think a custom interaction would be a good fit

trim oxide
#

Question:

I made this method for eventsystem of the tmp pro in unity. But, When I tried to add this method on the inspector on the image, it doesn't exist

chrome walrus
trim oxide
#

but, nevermind, I found the cause

#

it can't use more the two parameters

#

and I used two parameters for my method

chrome walrus
visual tapir
#

private void OnJump(InputAction.CallbackContext value) { } Can I have a CallbackContext when I'm using SendMessages option?

#

Having a hard time navigating the Documentation to get a good understand of how it works

blissful comet
# mortal ridge I think a custom interaction would be a good fit

I didn't know that was a thing that could be done. It seems like that's what I want, but there is not much in terms of actual documentation for that feature, just a single blurb at the bottom of the Interactions page of the input system documentation. It mentions something about how custom interactions can store state, which I think I'd need to do for this, but it doesn't really mention when it gets reset ("he system might invoke the Reset() method to ask Interactions to reset to the local state at certain points." doesn't really give much information on that...)

Still, what would be a good way to go about this? Maybe starting a timer once the Vector2 is outside some deadzone, and if it reaches a value greater than some threshold within a frame, do the action? I'm not sure how I'd access time during this interval, I don't think Input Actions occur during the update loop...

mortal ridge
#

yeah, maybe try how far you can get with that approach

thick condor
#

hi, i wanna ask. how can i check my device type without build? i want to check the platform for different input system

surreal moth
#

Im trying to do "Right click + Drag" to orbit my camera, but im getting a boatload of errors in the console

#

how should this be set up to enable rightclick+drag?

austere grotto
#

first off the modifier would be the right click here, and second mosue position is not a "button"

#

"Button with one modifier" is not appropriate

surreal moth
austere grotto
#

like shift or ctrl

#

the actual input information you're interested in is the mouse position

#

so that would be the "button"

#

but it's not even a button really

#

it's more like an axis

#

so overall "button with one modifier" is just not appropriate for this

surreal moth
#

I see

#

Right click as a button, mouse movement as a pass-through delta?

#

Since delta will be the difference from the previous frame, I can track how much it moved and rotate accordingly, if I understand delta correctly, rather than its screen position

surreal moth
#

which is why I had it as button+mod before

austere grotto
#

why are you making it pass through?

#

just make it value

surreal moth
#

When I googled how to do this, the net said to make it pass through.

austere grotto
#

¯_(ツ)_/¯

surreal moth
#

Either way, neither value nor pass through show up as events

austere grotto
#

did you save the asset

surreal moth
#

Ah Autosave got unchecked, I didnt save it

#

watching this now to understand the difference between value and passthrough

surreal moth
#

For some reason, the FIRST time and only the FIRST time that I press a direction key, the player moves 4x faster than it should

#

then on all subsequent key presses, it moves exactly the speed it should

#

and I cant seem to debug why

#

ive logged all the values, nothing is wrong, yet it still moves too fast

#

cameraOrbit.transform.position += movementDir;

#

thats the move function

#

why would the move vbelocity be so much higher ONLY on the first time the key is pressed?

tame oracle
#

Hi… I’m using the new input system, wondering how to handle key releases with it?

#

I’m using functions like

#

OnMove(InputValue val)

#

Wondering how I would handle something like… OnMoveRelease?

#

Does such thing exist? Or something similar

#

I just want to track when a Move action has ended

cursive oxide
plush stone
#

Assigning press only/release only etc. doesn't work

#

Input gets called on all events regardless of specification

#

Anyone has a fix?

tame oracle
#

InputAction has a bool called IsPressed, I tried using that but it just brings up errors

plush stone
blissful comet
#

According to the documentation for custom input interactions:
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Interactions.html#writing-custom-interactions

Now, you need to tell the Input System about your Interaction. Call this method in your initialization code:

InputSystem.RegisterInteraction<MyWiggleInteraction>();

...what Initialization Code? Does this mean when I'm subscribing to events? It's supposed to be available in the asset editor I believe, so where would I put this code?

#

I made an Editor script with [InitializeOnLoad] and now it seems to be working. I guess this is what it was supposed to be?

tame oracle
#

If i want to setup a split keyboard input system are control schemes the right thing to use ?

pine oar
#

the properties to the actions are not appearing

#

does anyone know what is happening?

austere grotto
#

Restart Unity?

gleaming oar
#

can you expand it?

pine oar
pine oar
blissful comet
#

Okay, I have a custom interaction that mostly works for detecting a stick smash:
http://pastie.org/p/2Wv2l5tsWW9L9uyInbRoVi

I have two issues with it:

  1. Once a Smash starts, it keeps going until you let go of the stick and it gets canceled. I want this to behave like a button, where the performed action happens once and then not until you do the interaction again. How would I make an interaction like this? Do I just need to cancel it right after I perform it?
  2. I am using my own sort of timer system for detecting how fast you move the joystick because no matter what I try, the timeout functions don't seem to do what I expect. If anyone knows how I could convert that into the SetTimeout properly I'd like to know.
regal sinew
#

How to make a dialogue tree trigger via a button press when you are close enough in radius to a certain npc.

#

Also maybe have a button prompt appear over their head and have it ps2 style where horizontal black bars appear on the screen and it switches a camera angle

indigo patrol
#

If you want to go this route, I suggest to ditch out the generated-class and implement it your own via InputSystem.onEvent

blissful comet
#

I will probably be having a frame-based input buffer separately from the interactions, to be used for both buffering and recording, I just want this event to fire when you smash the joystick very quickly to max, rather than slowly moving it forward

indigo patrol
#

I made a typing-game library for Unity so the detecting must be super fast for each button presses and noticed that there's too much overhead with the generated-class, but Inputystem.onEvent provides me with almost raw input performance

indigo patrol
#

just saying, must be a bit overkill for your use case

indigo patrol
#

Just an extra, if your game is an online multiplayer that implements a rollback mechanic, input-buffer is a must... which I rarely seen this used in indie games made with Unity

valid wharf
#

I'm trying to do mouse-look or gamepad look based on input device in a kinda twinstick shooter setting.
I have a solution that works, but i'm not really happy with the string comparison.

private void Look_performed(UnityEngine.InputSystem.InputAction.CallbackContext obj)
{
    var value = obj.ReadValue<Vector2>();

    if (obj.control.device.name == "Mouse")
    {
        var worldPoint = Camera.main.ScreenToWorldPoint(value);
        var dir = worldPoint - transform.position;
        dir.Normalize();
        lookInput = dir;
    }
    else
    {
        lookInput = value;
    }
}

The input binding is set up to either read the right stick or the mouse position.
Anyone know of a better solution to this that doesn't add unreasonable amounts of complexity?

sleek pasture
#

I can use simulated touch, but the unity remote 5 does not work. I'm debugging through prints. Input device: Touchscreen

austere grotto
valid wharf
glacial pumice
#

Trying to think theoretically at how to reduce input lag to the minimum. The use case is a bit unique (fighting game, game tick locked to 60fps, no frame interpolation). The best I've been able to come up with is:

  • maxQueuedFrames should be 1
  • Snag the inputs right before you need them.
  • Make sure everything runs fast, prioritizing latency over graphics and removing post-processing.

Things I'm not sure how to do on Unity on Windows:

  • Delay the Update()+rendering to complete closer to the vsync so the frames being swapped to the front are fresher.
lost swift
#

Hello! Is there a way to cancel binding from method or is there a way to press button through script?

indigo patrol
#

...is there a way to press button through script? why you want this tho

#

you can just call the function that supposed to be triggered by the button press

chrome walrus
blissful comet
#

https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/api/UnityEngine.InputSystem.InputRecorder.html

So, apparently this is a class that exists. It says it has an inspector so I assume it's a component you can add, but I can't find it in the add component menu. I'm on InputSystem 1.1.1 and no updates are available. How can I add an InputRecorder component? I tried to add it in script but it seems like it can't be found in the InputSystem namespace either. Do I need to install something else to get this class?

glass yacht
#

It doesn't inherit from component, so no, it's just a normal class. No idea why you can't find it though

blissful comet
#

But it extends mono behaviour, it should be a component, right?

glass yacht
#

Bizarre, it does... and yet there's this wonderfully useless inheritance hierarchy

#

@blissful comet it appears to be in the samples

blissful comet
#

That'd make sense, I didn't install the samples. I'll go get those and see if I can move it somewhere more sensible

blissful comet
lost swift
#

I can't press "Escape" to cancel rebinding onclick and can't cancel rebinding from another method

main idol
#

Hi Im currently trying to write a script that will export my inputs to a JSON file and Import them from the same JSON file if one exists (I plan to write a small program that will let you edit the keybindings from outside the game)

This is the script I currently have

using System.IO;
using UnityEngine;
using UnityEngine.InputSystem;

public class InputToJSON : MonoBehaviour
{
    public InputActionAsset inputAction;
 
    void Awake()
    {
        if (!File.Exists(Application.dataPath + "/Test/Rebinds.txt"))
        {
            inputAction.RemoveAllBindingOverrides();

            var rebinds = inputAction.ToJson();
            File.WriteAllText(Application.dataPath + "/Test/Rebinds.txt", rebinds);

            Debug.Log("Binds Reset");

        } else
        {
            inputAction.Disable();
            string rebinds = File.ReadAllText(Application.dataPath + "/Test/Rebinds.txt");

            // inputAction.LoadFromJson(rebinds);

            inputAction.LoadBindingOverridesFromJson(rebinds);

            inputAction.Enable();

            Debug.Log("Binds Loaded");
        }
    }
}

The saving works as expected however when I try to load the bindings nothing changes, Unless I uncomment the LoadFromJson, However when that is uncommented no inputs work but after I recomment it and run again it works and updates the bindings

#

Im not sure what to do from there

granite quest
#

So I have an extremely basic movement set up on a kinematic rb2D. But the input randomly goes to 0,0 for different lengths of time (anywhere from a few frames to a few seconds) and is causing movement stutter. Any known causes for this?

austere grotto
granite quest
#

Pretty much everything is its default settings. I've tried the code a number of other ways (fixedupdate, update, removing the time; reading the value on only started or performed) but it all has the same issue.

tropic sage
#

Would it be best to make a separate script that returns inputs? like making a InputManager.cs script and if I was doing a dialogue system, adding it to the player script and dialogue system script?

austere grotto
#

maybe maybe not. Depends on how your game is structured and if it makes sense in your particular case. ¯_(ツ)_/¯

chrome walrus
granite quest
chrome walrus
granite quest
chrome walrus
#

Oh okay, if it was happening, then did you debuglog only your input raw?

granite quest
#

I debuglogged the variable that was storing the input, I didn't check to see if there was any other weird input other than the joystick/wasd happening though. If that's your recommendation, what's the easiest was to capture that?

chrome walrus
granite quest
#

Yeah, it would work as expected for a few seconds then change to 0,0 for a few frames before changing back.

remote yacht
#

I have a problem i can move the camera on the gamepad but it isn't working on the mouse does anyone know the problem?

cerulean bough
#

Hi fellas o/

#

When we're navigating between UI elements both horizontal and vertical axes are used to change to the next/past slider, but it behaves different for sliders by using the horizontal axis(when on horizontal slider) for changing its value. Is there a way to make it changes to the next/past slider instead of editing the current slider? only editing the currently selected slider when the submit button is pushed?

chrome walrus
#

Oh wait, you are using fixed udpate @granite quest right? Can you try to readvalue in update

chrome walrus
# remote yacht

What does your readvalue output when debug.logging it and using mouse

granite quest
#

Oh. My editor wasn't up to date. 🤦 It works now.

#

Thanks for the help, though!

chrome walrus
granite quest
#

Yeah lmao apparently when I updated it yesterday I downloaded the wrong version. Whoops.

remote yacht
cursive oxide
#

Anyone have experience with navigation? How can you explicitly choose what to select when u click something? Like this is a very common occurence. If you're on the main menu and click settings, it should change new navigation point to be the first in list of settings but I dont see a way to change what is selected when u click something. How is that not a thing given how import it is for functionality? Am i missing something?

tropic sage
austere grotto
#

Yep - Action Maps

silk epoch
#

whats currently the best way to have a button combinations?

earnest vector
#

with the "new"(idk how new it is now) input system im having a weird issue with how when I use the key path such as <Keyboard>/escape it not only triggers with pressing escape but also when pressing e. same thing happens when I switch it to <Keyboard>/space, it triggers with space and with s, whats going on here is there a setting or something thats causing this?

limpid cradle
#

I'm having trouble with a few scripts. Two different scripts have input system objects that need to be active at the same time. Does this cause issues? or can two different maps be active at the same time? If not, I might just have an external script handle all input and just send the data to the scripts I need them at.

#

The reason I have two separate ones is because I want to do different things to the aim input depending on the device, but I wouldn't be surprised if that had a simpler solution

#

Here are my error messages:

#

and the code in question:

private void Awake()
{
    // Update script on what direction and magnitude to change aim angle
    // mouse
    controls.FirstPersonCamera.MouseLook.performed += ctx => lookInputMouse = ctx.ReadValue<Vector2>();
    controls.FirstPersonCamera.MouseLook.canceled += ctx => lookInputMouse = Vector2.zero;

    // gamepad
    controls.FirstPersonCamera.GamepadLook.performed += ctx => lookInputGamepad = ctx.ReadValue<Vector2>();
    controls.FirstPersonCamera.GamepadLook.canceled += ctx => lookInputGamepad = Vector2.zero;
}

private void OnEnable()
{
    controls.FirstPersonCamera.Enable();
}

private void OnDisable()
{
    controls.FirstPersonCamera.Disable();
}
#

forgot this lol:

controls = new PlayerControls();