#🖱️┃input-system

1 messages · Page 56 of 1

mortal ridge
#

you most certainly didn't

thin blade
#

not here, but in DM

mortal ridge
#

it's probably not even related to touchapi or the input system. more likely something to do with the UI

buoyant raft
#

any1 got some time, dont know why I cant choose a dropdownbutton in my Script

buoyant raft
#

"yes"

mortal ridge
#

post your questions in here

austere grotto
#

What does this have to do with the Input System?

proven dove
#

it is working not praetor thx 🙂

mental musk
#

I'm pretty sure Sony keeps the cool Gamepad controls unavailable right? For example, we couldn't use the controller shake sensor?

leaden egret
#

In the old system the value received by my HOTAS slider was between -1 and 1.
In the new input system the values are between 0.98 and 1.02, how can I normalize them so that they are between -1 and 1?

foggy notch
#
        Vector2 input = playerInput.Player.Movement.ReadValue<Vector2>();
        playerController.PlayerMovement(input);
#

Is there an alternative to ReadValue that doesn't create GC? Not that big of a deal, 80B per frame, just curious

fickle agate
#

is there something new with the input system that so new the tutorials doesnt work with it?
Im getting errors with this OnEnable/OnDisbale now:

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

public class ForkliftController : MonoBehaviour
{

    private ForkliftController forkliftController;


    private void Awake()
    {
        forkliftController = new ForkliftController();
    }

    private void OnEnable()
    {
        forkliftController.Enabled;
    }

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

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        //Vector2 move = forkliftController.forkliftInputs.Move.ReadValue<Vector2>();
    }
}
austere grotto
#
forkliftController.Enabled;``` ???
#

Please go back to your tutorial and copy it correctly

fickle agate
austere grotto
#

Doesn't work how? What error are you getting?

#

And show your actual code

fickle agate
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class ForkliftController : MonoBehaviour
{

    public ForkliftController forkliftController;


    private void Awake()
    {
        forkliftController = new ForkliftController();
    }

    private void OnEnable()
    {
        forkliftController.Enabled();
    }

    private void OnDisable()
    {
        
    }

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        //Vector2 move = forkliftController.forkliftInputs.Move.ReadValue<Vector2>();
    }
}
austere grotto
#

Still wrong

#

copy the tutorial exactly

fickle agate
#

i did.

austere grotto
#

Show their code next to yours

#

Every tiny bit of spelling, capitalization, and punctuation matters in C#

#

It has to be exact

fickle agate
#

once again 🙂

#

what happen was that i was referencing the wrong script.

#

its ok now. thanx for the help.

ripe edge
lost valley
#

hey guys, i have a input action that can be used both on keyboard and on gamepad, but when i press the gamepad stick just a little bit the player moves pretty slow, i don't remember how to remove this, i wan't basically to change to something like "getaxisraw" of the old input system (-1f, 0f, 1f only)

#

i know i can set a processor to scale the value like 10000x and clamp it, but there is a option that does that automatically, and i cant find it

foggy notch
#

Value types don’t create garbage, reference types do

austere grotto
#

It just got rid of the "acceleration" on the joystick - but it would still report values between 0 and 1

#

Maybe what you want is to set the value type to something like Digital/DigitalNormalized/Normalized

#

If not, you can always just normalize the value in your code

lost valley
hot drum
#

So question about input and movement, do I have to manually check that a collision hasn't occurred before moving the transform of the character? or does the colliders handle that for me, I know they handle that with regards to gravity, but what about walls?

hot drum
#

Actually.... I don't know that this is even the right place to ask

timber robin
tame oracle
#

Hi! Can i have help i didn't mean to switch to the new input system and I did and i need help adjusting my code .

mortal ridge
foggy notch
#

It would solve the problem

#

Unless he wants to be on the new input system which he hasn’t said yet

mortal ridge
#

nvm

crisp star
#

Is there any way to reuse code for such approach with new input system?

rn I have to create all these for each action:

    public static MainActionComponent MainAction => mainAction;
    private static MainActionComponent mainAction;
    private bool _mainAction;
    private void RegisterMainAction()
    {
        Game.MainAction.performed += _ =>
        {
            mainAction.pressed = true;
            mainAction.active = true;
        };
        Game.MainAction.canceled += _ =>
        {
            mainAction.pressed = false;
        };
    }

And do this in update

        // Main action
        if (mainAction.active)
        {
            if (_mainAction)
            {
                _mainAction = false;
                mainAction.active = false;
            }
            else
            {
                _mainAction = true;
            }
        }
#

I can't figure out if there's a better option

#

or a way to reuse such code for other actions

#

all info for each action is stored in it's structs

jagged wyvern
#

you're using the new input system like the old system

#

just use the old system

crude flower
#

How do i make my player shoot with arrow keys with the new input system cuz i can't find any tutorial

jagged wyvern
#

make a method that takes in a vector 3 as a parameter and have it subscirbe to a 2D input action

crude flower
#

I know how to make it with the old system can i somehow translate it to the new system?

jagged wyvern
#

yes

crude flower
#

so how can i translate it?

jagged wyvern
#

make a composite binding based on a 2d digital vector

#

subscribe the shooting method to the input action event

crude flower
#

thx

crisp star
#

I'm not sure if old system will see Input.MouseClick same way on gamepads and etc

jagged wyvern
#

doesn't input manager handle that in old system?

tame oracle
foggy notch
steep burrow
#

Hi, I want to make bind settings, and I have problem with unbinding
I have two binds, main and alternative, and I want to remove bind when backspace is pressed
But ChangeBinding(index).Erase(); is removing it, not setting to null or <no bind>
How can I replace bind with null/<no bind>?

Forward [W] [↑] > when pressed backspace on alternative > [W] [ ]
Back    [S] [↓]
Left    [A] [←]
Right   [D] [→]
half prairie
#

Do you guys know why it's giving me an error in line 22?? It says Null Reference Exception !!

austere grotto
#

So probably Touchscreen.current is returning null

half prairie
austere grotto
#

¯_(ツ)_/¯

#

Standard debugging strategies apply

#

use Debug.log

#

figure out what's null and why

half prairie
#

well I guess there is no other way then 😅

hot drum
#

Hey, I have a question about how the input system works. I have movement assigned to keys and controller input, I've set up the event system on the character's "Player Input" and I have code in my "move" function that should move the character, but when I press arrow or wasd keys, nothing happens. The event doesn't seem to fire.

#

Is there an article that describes the input pipeline, from the button press or keyboard key to the fired event?

#

I think I'm using the new input system

lavish bluff
#

Why does it always return duration as being 0?

sly marsh
sly marsh
lavish bluff
#

Because this is if ctx canceled

#

You start holding down the button earlier

#

Is there a built-in way to get how long the button has been held when you release it?

lavish bluff
#

Isn't that what I'm doing?

sly marsh
#

Put the debug.log(duration), inside of the function instead of in the if statement for canceled, and see what it returns then?

#

and if you really need the duration there, I would just store the value of the duration in a variable and then use that variable when you need it inside the canceled if statement.

lavish bluff
sly marsh
lavish bluff
lavish bluff
#

OK, after adding a press interaction instead, it does return the proper duration

sly marsh
#

Hmm..

lavish bluff
#

So it's fixed now, I think. Thanks dude

sly marsh
lavish bluff
#

Yeah, which is weird since it's more flexible than the old input in many ways

#

There should also be an option to make inputs run in fixedupdate time if they don't already

#

Because that's how you want to use input most of the time

#

But I don't have time for robustness right now

lavish bluff
#

Oh?

#

Where

sly marsh
#

Once i get back on my PC I’ll screenshot where for you, give me a min

hot drum
sly marsh
lavish bluff
#

Awesome

#

Thanks again

sly marsh
#

Np.

sly marsh
hot drum
sly marsh
#

Or does it not play at all?

austere grotto
hot drum
#

The Debug console shows nothing which is the problem. Let me try running it with the input debugger

hot drum
# sly marsh What is that debug returning?

It does play, as in if I hit the play button, it does the right thing to start up the game, but then I get nothing from the debug console when I press any keys, despite having a move action that's attached that Debug.Log's to the console

tame oracle
#

should this work with the old input system because it doesn't and I have no errors

austere grotto
#

Not "update"

#

You should also get your IDE configured

tame oracle
#

did all of it and it worked thank you!

jagged wyvern
#

oh wait nvm that's for send messages

spring parcel
jagged wyvern
#

not input system?

spring parcel
#

well i used input system

#

not sure if it is correct

near steppe
#

I am trying to add a 2D Vector composite on the new input system. But the option is not showing up.

austere grotto
near steppe
#

Ok

hallow solstice
#
public void OnAttackDown(InputAction.CallbackContext ctx)
    {
        if (ctx.performed)
        {
            attackDown = true;
        }
        else if (ctx.canceled)
        {
            attackDown = false;
        }
    }```
I tried this for my if attack is held boolean but it's not working
austere grotto
#

Not a callback context

buoyant cargo
#

Probably silly but how would I listen for 2d vector up press?

#

If my InputActions group is named Standing and the Actions category is named Movement & set to Vector2, just trying to figure out the magic combination to reference up in my standing.Movement.?Up? or however best to reference it

foggy notch
buoyant cargo
#

Trying things out right now but figured I might as well ask incase someone knew off the top of their head

foggy notch
# buoyant cargo

In update do Vector2 movement = playerInput.NeutralStanding.Movement.ReadValue<Vector2>();

#

From there do whatever you want with it

buoyant cargo
#

JmBless thank you

fallen charm
#

Where are some good tutorials on this new system?

#

How am I gonna do 3rd person movement from bracks tutorial?

timber robin
#

Unity has one on their youtube channel.

fallen charm
#

but but how do I do it with this?

timber robin
#

Learn how the new system works, for starters.

fallen charm
timber robin
#

Posting a bunch of screenshots isn't showing that you understand it. You asked what are some good tutorials, use the one on the Unity's youtube channel.

fallen charm
#

watching rn

#

theres no 2d vector composite option just up down left right, binding with one modifier, or binding with two

#

wait nvm its there

#

up down left right

#

sorry its been a while since i used unity

compact wigeon
#

hello!, is using the Player Input Component a good way to use the new input manager? :D

fallen charm
#

Ive almost got movement to work right

#

Only problem I have is that i need to rapidly press the movement keys to move (im not sure if its player input's fault)

unreal smelt
#

i use cs Input.GetKeyDown(KeyCode.Space) is this still recommended?

indigo patrol
foggy notch
fallen charm
#

input manager

#

I was following both the tutorial on unitys youtube and brackeys third person controlleer

feral latch
#

Hello, I use the new input system and I have a "button" input with the F key. I am trying to ensure that when I enter a trigger and press the F key, then something happens. But I have to press several times consecutively for the rest of the code to work. We would say that it responds once in 20!
My code for that :

#

(InputManager.Input.GetPlayerInteract() = F key)

austere grotto
#

They don't run every frame. It's the same as FixedUpdate

#

Input should be processed in Update or with events.

Mark the entry/exit of the trigger in OnTriggerEnter/Exit with a variable

feral latch
#

🤔 Ok ok

austere grotto
#

OnTriggerStay is not useful here

feral latch
#

Ok it's good it works ! Thank you

fallen charm
#

So I kinda figured out how input works, However my movement has this issue where i cant hold down wasd

#

I have to rapidly mash the keys to move

#

Was there something I missed?

#

And with a controller I need to wiggle the stick to move

#

So basically it only works on pressing it once

#

how do I make it so I can hold down a movement key?

hot drum
#

Ok. so after doing some more debugging, I noticed that the keyboard doesn't work but the gamepad sort of does. I get the logging in the console when I use the analog sticks.

#

But the player character doesn't move

shy glade
fallen charm
#

and it needs to be in there so that it can detect input

#

And I cant put the stuff that moves the player in update either cause then it wont detect the direction variable

#

so how the hell do i fix this?

sly marsh
#

instead of using events, since events are updated dynamically by default and can only be changed to fixed update or manual, neither of which fix the issue without drastic work arounds

fallen charm
#

So that tutorial on unity's own yt channel is a lie?

#

Who the hell do I trust

wraith bloom
#

How can I get the x,y coords from this click's context?

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

public class InputSystem : MonoBehaviour
{
    private PlayerInputActions playerInputActions;
    private void OnEnable()
    {
        playerInputActions.Enable();
    }
    public void Awake()
    {
        playerInputActions = new PlayerInputActions();
        playerInputActions.Player.Click.performed += Click;
    }
    // Start is called before the first frame update
    public void Click(InputAction.CallbackContext context)
    {
        if(context.performed)
        {
            Debug.Log("Clicked");
        }
        
    }

}
#

the action is a Button type > and binding is "left mouse button"

fallen charm
#

So was unity's own YouTube tutorial just bullshit?

indigo patrol
#

That saidn. many tutorials you found weren't just some bogus tutorials

true fiber
#

Hi, I want to make a local multiplayer with the new input system. Movement is working normal if one player is on the screen. But if i join with a second input, one input (for example the controller) moves both player. What can I do? I already have a player input manager in the scene. I move the player by changing rigidbody velocity. (2d game) (Version 2020.3.21)

verbal remnant
true fiber
verbal remnant
#

you can put an input-to-character-controller component inbetween... but there is no way around routing the input in some way or other

true fiber
verbal remnant
#

i'm talking about the concept of a character controller

steep burrow
#

Hi, I want to make bind settings, and I have problem with unbinding
I have two binds, main and alternative, and I want to remove bind when backspace is pressed
But ChangeBinding(index).Erase(); is removing it, not setting to null or <no bind>
How can I replace bind with null/<no bind>?

Forward [W] [↑] > when pressed backspace on alternative > [W] [ ]
Back    [S] [↓]
Left    [A] [←]
Right   [D] [→]
hot drum
#

Ok. So it's not that the input system doesn't work anymore, I got it working, but the problem is that left and right don't move the player but jump does.

#

Jump causes the player to jump, but left and right/A and D doesn't cause the player to move left or right

#

And I'm getting the right vector values from the input system

#

So it must be the physics system

mighty mason
#

Can someone shed some light on what this warning is telling me? Is there a different way I should be using Eventsystem.IsPointerOverGameObject() when using the new InputSystem?

#

"Calling IsPointerOverGameObject() from within event processing (such as from InputAction callbacks) will not work as expected; it will query UI state from the last frame"

#

Currently it's being used as a UI check in an InputSystem click callback to prevent clickthrough.

#
 void OnSelect()
    {
       // Ignore if over UI
       if (!EventSystem.current.IsPointerOverGameObject()) //function returns true if over panel. That's why it's inverted.
       {
austere grotto
#

e.g. using EventTrigger components or implementing IPointerClickHandler etc.

mighty mason
#

Gotcha. I'll have to read up on EventTrigger components and the EventSystem in general.

hot drum
#

How do I set up continuous input where if I hold the left or right keys on the keyboard, the character keeps moving, instead of just moving once?

austere grotto
#

What do you have now?

hot drum
#

Well, right now I have a character that at first moves around sort of correctly, (I sort of figured out that problem but I'm not sure if I did so correctly, but it seems to sort of work) except it catches on something in the environment and now it sort of rolls around when it loses its orientation.

hot drum
#

So... yeah. That's how it's working so far

#

LOL

#

at least it doesn't fall out of the room

#

lol

austere grotto
# hot drum

Why are you setting the velocity on the x axis to zero whenever it's not started?

#

And why are you calling AddForce in Update

#

That's a classic faux pas

#

Physics should be done in FixedUpdate

drifting patrol
#

Ran into an issue with touch where 2 touchpoints seems to be valid when checking for 3 touchpoints. Testing it on an Android tablet running 5.0.1

if(Input.touchSupported && Input.touchCount == 3) {
   // This runs with only 2 fingers
   Debug.Log("Handling touch rotation");
   x = Input.GetTouch(2).deltaPosition.x;
   y = Input.GetTouch(2).deltaPosition.y;
}

Anyone knows why this is?

hushed coral
#

Having some word finding difficulties right now so i can't really google my issue and find any results, so I apologise if this might be an easy google search normaly,

So i have two scripts: an inventory script that does specific stuff and an UIWindowManager with a singleton that does things like toggle cursor on and off. When I now add the functions that should be called on button press, I want to add the cursor toggle from inside the inventory script, like this:

#

instance is the singleton.

#

i was hoping it would work but i get this Error:

#

usually i get an error code which i can look up and try to understand, but "Value does not fall within the expected range" sounds like I should not add functions of foreign scripts in the awake?

#

I really tried to google it but can't give google something that gives me a solution in return

#

As a workaround, I could copy paste the ToggleUICursor function into the Inventory script but that feels... not good, since I would also have to do that for every other UI script that toggles the cursor on and off

hushed coral
#

I guess I have to call it inside the UIWindowManager awake, or copy the ToggleUICursor code. I don't see another method

hushed coral
#

it seems like the problem is that i try to use the singleton. if I instead set up a normal variable. it works

#

Problem solved. I guess?

hot drum
# austere grotto Why are you setting the velocity on the x axis to zero whenever it's not `starte...

Because as best as I can tell this method is called when the action begins and ends. Rather than seperate messages. So when you start holding the direction buttons, the speed vector increases and add force on update keeps adding force to move the player. When you stop holding it, it gets called again and the player stops moving because the vector is set to zero and velocity is set to 0. So update keeps adding a zero force.

austere grotto
#

If so - OnMove will get called whenever the actuation of the bindings for Move change

hot drum
#

Yes. Unity events mode is what I'm using.

austere grotto
#

that means if you go from holding right to holding up, it will be called again, and the phase will not be started

#

started will only happen when going from zero actuation to non-zero actuation

#

(I'm making the assumption that you're using the default interaction aka "no interaction" in your input Action)

hushed coral
#

How do I turn off an actionmap? (and is it even recommended?)

I currently have the problem that my character attacks and can move when the UI is open. which is annoying, so i thought "i just disable the PlayerControl actionmap while opening the UI"

#

But when i try that i get the error:

austere grotto
#

which you didn;'t even show in your screenshot

hushed coral
#

ah fuck wrong screenshot >.<

#

1 moment

#

thats the correct one

#

the problem is the line
playerInput.actions.FindActionMap("PlayerControl").Disable()

austere grotto
#

either playerInput is null or it doesn't have an actionmap named PlayerControl

#

your if statement on line 22 is very weird - seems inverted

#

and why are you mixing and matching a PlayerInput with using the generated C# class

#

typically you'd only use one or another

hushed coral
austere grotto
#

And what's the point of playerInput at all, since you're using the playerInputActions that you're creating on line 24?

#

you seem to be mixing up two different styles of using the input system

hushed coral
#

that might be possible

#

I am using it for the first time in a project and am completely overwhelmed

tame oracle
#

hi uh i have a TMP input field built to android but when i put something in "Text" doesnt update and also "Placeholder" doesnt show

austere grotto
tame oracle
#

oh sorry ima migrate there

hushed coral
#

but hey. now i have new funky problems to solve .-.

#

the StarterAssetInputs go crazy and I have no idea why

hot drum
hushed coral
#

yeah fuck the new system. i give up

#

its not worth the stress and the damage it does

#

have fun fixing

hot drum
# austere grotto why

I think the press was leftover from a tutorial, the press and release was to react to holding the direction buttons down.

austere grotto
#

I will tell you that you don't need/want any interactions for a simple movement axis input, unless you want a custom deadzone or something

digital narwhal
#

I have keyboard/mouse and game pad and joystick support. I have no issues filtering device id to route actions to specific players. But I’m having trouble doing this with the UI input module. How can I say, prevent certain devices from triggering UI input actions?

So when app loads I have 5 inputs (1 keyboard, 4 game pads) and all interact with UI, but I only want Player 1 to have that ability.

#

I can’t disable the other devices because I need input to listen to them in case a “player wants to join” the session.

hot drum
austere grotto
#

you save the current input value in a variable

#

and you use it in Update

hot drum
#

But then don't you have to keep getting the input to check when the user releases the button?

#

If you're not going to have an "interaction"?

austere grotto
#

basically your whole callback function just needs to be currentSpeed.x = context.ReadValue<Vector2>().x;

hot drum
#

Ok, but where is the proper place then to "AddForce()"?

austere grotto
#

AddForce should be done in FixedUpdate

hot drum
#

Ok. That works a little better.

#

I need to expand my arena to experiment more.

#

I also need to make sure that jumps can only happen on the floor

#

Thanks

#

Oh.... and I need to make sure my character stays upright.

austere grotto
hot drum
#

Even if the rotation is frozen, can I manually rotate it?

austere grotto
#

yes

#

but do you need to?

hot drum
#

Well, I'm thinking if the player turns around when going the other direction. He's not gonna walk backwards

austere grotto
#

We're not freezing rotation on the y axis

hot drum
#

Oh duh

#

Actually. I also forgot spin jumping

#

But you already answered that

analog siren
#

Is using inputs like GetKey() the old system?

trail skiff
#

Yes

#

From what i know the new input system is GUI-based

analog siren
#

Wack

#

Thanks

austere grotto
devout depot
#

Hello! I'm following along with a tutorial using the new input system and I've hit an unusual snag. Right now I'm just trying to get the camera to move up and down, and while the inspector shows the values are changing with mouse movement, the camera holder (which the camera is a child of) isn't responding to the changes in said values and not moving. Have I missed something? ```cs
public class scr_CharacterController : MonoBehaviour
{
private DefaultInput defaultInput;
public Vector2 input_Movement;
public Vector2 input_View;

private Vector3 newCameraRotation;

[Header("References")]
public Transform cameraHolder;

[Header("Settings")]
public PlayerSettingsModel playerSettings;
public float viewClampYMin = -70;
public float viewClampYMax = 80;


private void Awake() 
{
    defaultInput = new DefaultInput();

    defaultInput.Character.Movement.performed += e => input_Movement = e.ReadValue<Vector2>();
    defaultInput.Character.View.performed += e => input_View = e.ReadValue<Vector2>();

    newCameraRotation = cameraHolder.localRotation.eulerAngles;

    defaultInput.Enable();

}
private void CalculateView()
{
    
    newCameraRotation.x += playerSettings.ViewYSensitivity * input_View.y * Time.deltaTime;
    newCameraRotation.x = Mathf.Clamp(newCameraRotation.x, viewClampYMin, viewClampYMax);
    
    
    cameraHolder.localRotation = Quaternion.Euler(newCameraRotation);
}
austere grotto
devout depot
austere grotto
#

that's where you're doing cameraHolder.localRotation = Quaternion.Euler(newCameraRotation); which is what would actually rotate the camera holder object

devout depot
austere grotto
#

You've definitely overlooked something

#

Or it's a bad tutorial

devout depot
#

AH

#

I did miss a line in the Update function.

#

Thank you!

fallen charm
#

any good tutorials on the new input system

#

cant find any

#

Ive looked

#

and they never work

lofty gull
#

you mean like

#

Input.GetKey("whatever")?

fallen charm
#

i mean input manager

#

I tried this one

#

In this video, we are showing you how to create a cross-platform character controller using Unity's Input System!

Download this project here:
https://on.unity.com/39WT0iv

For more information about the Input System - click here!
https://on.unity.com/2MJnzj2

Chapters:
00:00 Intro
00:29 Input Manager
01:10 Installing the package
01:34 Using th...

▶ Play video
#

but the movement wouldnt work right

#

Cause here i had to mash wasd to actually move

#

the brackeys vid is outdated

#

All i want is to use the 3rd person movement brackys made

#

but with this system

#

so how do I do it?

foggy notch
#

Youre using an event for movement

#

Events only get called once per button click not every frame while it's held down

fallen charm
#

So what do I use?

#

Events seem to actually detect input

foggy notch
#

Show me your script

#

Events do detect input

#

But there good for buttons not vectors

fallen charm
foggy notch
#

Are you using the Input whatever component?

fallen charm
#

PlayerInput Component

foggy notch
#

Yeah dont

#

It sucks

#

Write a script for input

fallen charm
#

So make a seperate input script

#

then do a movement script?

foggy notch
#

That's usually best practice

fallen charm
#

So how would I make an input script?

#

do you mean the same script that the manager makes?

foggy notch
#

No you use the script the manager makes

fallen charm
foggy notch
#

Yes

fallen charm
#

So do I attach it to the player?

foggy notch
#

No

#

You create a script and reference that one

fallen charm
#

Ah

#

So how do I make it so the movement script can detect movement?

arctic rapids
#

Is there any prerequisite for a method to be detected by the Player Input component in Invoke Unity Event mode? In the image there's my current config and this is my C# script (MonoBehaviour is declared in one of the parent classes)

However no method appear when I try to select the event

using UnityEngine;
using UnityEngine.InputSystem;

class PlayerPlane: Plane
{
  public void Axis(InputAction.CallbackContext context)
  {
    Vector2 value = context.ReadValue<Vector2>();
    Debug.Log(value);
  }
}
arctic rapids
#

None

glass yacht
#

Can you screenshot

arctic rapids
#

The literal one thing that appears is MonoBehaviour -> string name

fallen charm
#

Also ive heard not to use player input

glass yacht
#

I'm unsure what exactly you're looking at, if this is not the answer please do screenshot it, it'd make it less vague

fallen charm
arctic rapids
#

I was really confused as to why it was working before and wasn't any more

fallen charm
#

nvm got it to work

foggy notch
fallen charm
#

Yep

foggy notch
#

Can I see it?

fallen charm
#

Now i gotta figure out the camera

#

(the camera is similar to luigis mansion)

foggy notch
#

That's fine, you don't really have to make a variable for movement InputAction but itll work the same

fallen charm
#

yeah but also switching to first person

#

And yes i got cinemachine

foggy notch
#

Cinemachine can switch to first person

plush finch
#

Hello, I need some help with mobile input system

#

I really can't understand it like keyboard input

ocean palm
#

guys how do unity devs handle double key press?

#

cuz I'm new and all input methods I'm looking at are continuous

sudden lagoon
#

Short way how to know if the object that was triggered event UI or Not. Or know the tag or layer of that object. Key element that camera have physics ray caster.

#
 private void Update() {
            if (EventSystem.current.IsPointerOverGameObject()) {
                if (Camera.main is null) return;
                var ray = Camera.main.ScreenPointToRay(point);
                if (!Physics.Raycast(ray, out var hit, maxDistance, layer_mask)) { //if it hit no game objects, that means it is UI. as it shoots only after it is over UI.
                    isOverUI = true;
                    return;
                }
                if (Physics.Raycast(ray, out hit, maxDistance, layer_mask)) {
                    if (hit.collider != null) {
                        isOverUI = false;
//if there is an object that triggered this event, that means it is not UI.
                    } else isOverUI = true; //this one just in case I guess
                }
            }
        }

this is my current solution. it works.... But ..... It is not pretty solution and I want to make code that makes sense. Teach me senpais

tall cipher
#

A thing you could do, instead of the last
if (hit.collider != null)
IsOverUi = false;

You could just use
isOverUi = !(hit.collider != null)
Or
isOverUi = Hit.collider == true

devout depot
#

So, I found a script that I think might work well for my purposes, but it used the old input system and I'm struggling to convert it to the new system. It's changing a bool based on it's press state, setting it to true when pressed then false when released. Is there a way to do something similar with the new system?

austere grotto
versed solstice
#

I'm looking for some advice on dealing with a local multiplayer game which uses split screen where players need to be able to navigate their own menus on their own screens (at the same time). Using the new input system, the Input System UI Input Module and the Event System doesn't seem to result in the desired behaviour, as either only one player can control the UI or they can control each other's UI. Any ideas on how this should be done in the new input system?

versed solstice
#

Brilliant. I knew there had to be something I'd missed. I'll give it a go now.

devout depot
austere grotto
#

Are you using events?

#

Polling things in Update?

#

Using a PlayerInput component?

devout depot
#

I'm not using events or polling in update, I'm using DefaultInput

austere grotto
#

I assume "DefaultInput" is the name of your input actions asset?

devout depot
#

yep

austere grotto
#

You must use either events or polling in update to do anything with that

versed solstice
austere grotto
#

Sounds like you are using the generated C# class.

devout depot
#

Yep; I'm looking at the documentation for events now and it's like its bouncing right off my eyeballs

austere grotto
#

there's not really any other options

devout depot
#

I think I'm going to have to use polling unfortunately, this doc is so obtuse I'm not sure I'm capable of processing it

austere grotto
#

I'm just asking what you're using currently

#

we can work with that

devout depot
#

I don't even know bro, I am so lost. Here, let me post the script as is on GistHub then I'll link to the original script I'm trying to convert from

#

Well after diddling around a bit I've found the Player Input component and it's ability to broadcast messages

#

How to make use of those messages, I'm still working on that

versed solstice
#

Any advice on ensuring a button stays **visually **selected (colour tint) even after the canvas has been disabled and then enabled again? The EventSystem clearly remembers which was selected as you can submit and it executes the right one, but visually it doesn't have the colour tint.

devout depot
#

I have been trying to figure out this bloody input system for 4 hours and I still cannot find anything that tells me plainly how to toggle a bool. Sure ReadValue<> is a thing but whatever value it reads cannot be converted to bool

#

this is genuinely upsetting

versed solstice
devout depot
#

yep, I want LMB to toggle 'shooting' to true while down and 'false' when up

#

I keep seeing promo material from Unity claiming this is easy but this is the hardest thing I've had to do in Unity

#

literally nothing that has been suggested seems to work and I cannot find a straight answer as to why

versed solstice
#

Ok, one way to do this is to change the Player Input Behavior option to use Invoke Unity Events. That way you can use callback contexts. If you open the Events section at the bottom you can then define what function on what script to execute when the button is held. In your code you can then use InputAction.CallbackContext.

devout depot
#

I just tried that actually. 'InputAction' doesn't exist it says

#

Like I said dude I'm done. Thank you sincerely for trying to help but this just isn't going to work.

versed solstice
#

Add "using UnityEngine.InputSystem;" to the top

devout depot
#

I tried that too! It didn't do anything.

#

I thought I was really starting to get somewhere with making a game. But apparently, unless someone is holding my hand through the entire process like a goddamned toddler I am mentally incapable of going it alone.

#

As much as I want to blame Unity the fact of the matter is I'm just disabled or something

versed solstice
#

To be fair the new input system, whilst being very flexible, isn't the easiest to get going with.

devout depot
#

Plenty of people seem to get along just fine with it, and those that don't usually seem to find answers somehow.

#

No, with my experiences with Unity thus far it's pretty clear I'm the problem

#

I'm not quite ready to give up the dream just yet but christ this is demoralizing.

#

Again, seriously, thank you for trying to help me.

#

i'm going to bed, peace

tidal zodiac
#

how should i remove all bindings from an InputAction (including composites etc.) - doing

        foreach (InputBinding b in bs) playerInput.actions["Player/NavigateUI"].ChangeBinding (b).Erase ();``` 
doesn't work and it's the best i could come up with
#

that gets a "InvalidOperationException: Instance not valid" error, the action is a Value Vector2 type with Delta [Mouse] bound to it by default for testing

devout depot
#

Instead of sleeping, I just kept thinking about the damn script and where I was screwing it up. So I took some extra adderall and have attempted to figure it out on my own without a tutorial or external script.

#

Naturally, it's borked. However the errors this time feel much less intimidating, so I'm not too bummed about it. I've tried to use function calls to set the bools this time around. I was trying to use Update() to check one of the functions but all it did was set every variable to true and flooded the debug log. If I comment those calls out, the mouse button input doesn't seem to work either. Would someone be willing to look things over and see where I've gone wrong?

#

While I wait for someone to (hopefully) lend a hand, I'll be watching Brackey's video on the input system to try and better understand this eldritch abomination

gleaming oar
#

watch samyams videos

devout depot
gleaming oar
#

I think what is causing some confusion for me at least is the use of the Update() loop with the new Input System

#

so you're setting a bool to true in the subscribed function for the performed action, and then letting the Update() use that bool

#

What might be better is to instead call the function directly inside the subscribed function

devout depot
gleaming oar
#

the .performed callback

#

defaultInput.Character.PrimaryFire.performed += e => PullingTrigger();

devout depot
#

Oh? Could you show me an example?

earnest trench
# devout depot Sorry, but what do you mean by "subscribed" function?

Learn to develop games using the Unity game engine in this complete course for beginners. This course will get you up and running with Unity. Free game assets included!

✏️ Course developed by Fahir from Awesome Tuts. Check out his channel: https://www.youtube.com/channel/UC5c-DuzPdH9iaWYdI0v0uzw

⭐️ Resources ⭐️
(To download assets you may have...

▶ Play video
devout depot
#

Thank you very much for helping by the way!

gleaming oar
#

Right now the update loop is dealing with animations a lot of stuff, I'm suggesting getting rid of the Update() loop entirely

#

So instead of checking for a bool every single frame, make it all event based. When you press the fire button, set the animations to go into the fire animation

devout depot
gleaming oar
#

well you'll have to re-code it differently

#

it's a different approach than what you have now

devout depot
#

I'll have to learn it eventually

#

Might as well buckle down and try now

jagged wyvern
#

not that hard if you use player input

#

the component

gleaming oar
#

yeah the old way of doing input was to have a huge if then block in an Update() loop, and it absolutely sucked to work with

devout depot
#

Well I'm all for more efficient scripts

gleaming oar
#

the new way you just subscribe a function to fire off whenever a certain Input occurs (the performed callbacks) and just let the input system tell you when to execute it

#

I've got some examples from a little project

devout depot
#

I'll just have to study diligently and try to see it in action so I can better wrap my head around it

gleaming oar
#
// Unity functions
    private void Awake()
    {
        controls = new PinchTouchControls();
        controls.Touch.TestTouch.performed += context => Shoot(context);
        controls.Touch.TestTouchMouse.performed += context => ShootMouse(context);

        EnhancedTouchSupport.Enable();

        // Start listening for disable shooting events
        EventManager.StartListening(Events.RoundStart, OnRoundStart);
        EventManager.StartListening(Events.RoundEnd, OnRoundEnd);

        mainCam = Camera.main;
    }```
jagged wyvern
#

you also need to unsubscribe

earnest trench
#

what is subscribing used for anyways? Never have needed to use it before

gleaming oar
#

don't need to handle memory leaks if you alt f4 lol

devout depot
jagged wyvern
earnest trench
gleaming oar
#
    // Shooter functions
    private void Shoot(InputAction.CallbackContext context)
    {
       
        bool isTap = context.action.ReadValue<UnityEngine.InputSystem.LowLevel.TouchState>().isTap;
        if (isTap)
        {
            Vector2 screenPos = context.action.ReadValue<UnityEngine.InputSystem.LowLevel.TouchState>().startPosition;

            var ray = mainCam.ScreenPointToRay(screenPos);

            RaycastHit hit;

            if(Physics.Raycast(ray, out hit))
            {
                var target = hit.point;
                ShootAtTarget(target);
                if (hit.collider.tag == "Enemy")
                {
                    //debugtext.text += $" hit enemy";
                }
            }
        }

    }```
jagged wyvern
#

there's like 10 different ways to get input

#

in this new system

#

none are better than another

#

it's just a ton of options

earnest trench
#

lol ive just been writing references to different scripts and testing a var

#

which the var holds input

jagged wyvern
#

damn

#

the worst part of this new system is that every tutorial does it differently

earnest trench
#

I mean I could rewrite everything to subscribed events, but I don't want to fuck up my code lol

jagged wyvern
#

so it makes learning the system 10x harder

gleaming oar
#

it will fuck everything up

earnest trench
#

or choose one

gleaming oar
#

but it is more efficient

earnest trench
#

like me

#

and stick to it

earnest trench
jagged wyvern
#

and then when you ask for help someone tells you that's the wrong way

devout depot
#

I should be able to figure this out if I really put some time and effort into it, right? Writing my code more efficiently and less clumsily should be worth it

devout depot
earnest trench
#

so yeah

devout depot
#

Hell even the official documentation is about as beginner friendly as a crash course in bomb defusal

gleaming oar
#

That's why I like the samyam videos. After watching them like 5 times over I got the hang of it, and it is way easier for me to handle input now. Like before it'd take me hours to deal with user input, and now I can get really responsive input in 10 minutes

earnest trench
#

I just watch tuts, and recreate them, and usually by then I understand how they work

devout depot
#

The docs for just about every other part of Unity manages to provide some clarity, but the input system doc is agony

earnest trench
#

I don't really like the unity docs

#

too confusing

#

especially for beginners

jagged wyvern
#

they assume you know everything

#

and it doesn't help when there's confusing shit like inputsystem.inputsystem

gleaming oar
#
https://www.youtube.com/watch?v=ERAN5KBy2Gs ```
#

I watched both of those videos over and over until I finally understood

devout depot
#

This experience actually made me briefly consider switching to UE4/5 until I remembered C++ is my sleep paralysis demon

jagged wyvern
#

i heard ureal is more user friendly

gleaming oar
#

it has to be to make up for C++

devout depot
jagged wyvern
#

less fighting the engine more making games

devout depot
#

Unity's strength definitely lies in its community

#

Case in point: y'all! ❤️

#

At least we're not using Godot

jagged wyvern
#

true

#

competition isn't bad tho

devout depot
#

It's necessary for progress in these industries. In tech, you snooze you go bankrupt

#

It still baffles me though that Unity considers itself the 'accessible' engine when its documentation and new user experience are basically hate crimes

jagged wyvern
#

yeah they need to hire someone that speaks human

gleaming oar
#

They could do things differently/better, but overall it's good enough (don't ban me mods)

#

Especially they could maybe offer a multiplayer solution that isn't client/host combo package

devout depot
#

I mean yeah, if it was shit we wouldn't be using it. Unity has some pretty great features that keep it afloat, such as the relative ease with which you can deploy software on virtually any platform

#

Hell, their WebGL stuff continues to impress me

gleaming oar
#

I was about to say excluding webgl lol

#

that entire platform is just up in the air atm

#

are they going to switch to WebGPU? Will they ever support multithreading? Will I die of old age before I know the answer to these questions?

devout depot
#

Well from what I've read, you actually can include multithreading with their jobs system

#

What i'd really like is for the bloody editor to use more than one thread

gleaming oar
#

does it not?

#

I can use system.threading in the editor and it works

devout depot
#

I've got a 3900x overclocked on all cores to 4.3Ghz at safe voltages and it uses one or two of my 24 threads

#

I specifically bought it because it was my understanding that compilers, terrain generators and the like thrived on parallelization

gleaming oar
#

I think default it uses one thread for rendering (with batched jobs helping) and one for audio?

#

Terrain generation you'd do in like maya or blender no?

devout depot
#

Which I dread potentially having to use again because apparently a 200x200m block of land requires half a terabyte of storage

gleaming oar
#

WorldMachine looks cool

devout depot
tame oracle
#

I just need to know, if I have keyboard or mouse controls for my game, that absolutely NEEDS a mouse and cant be ported otherwise, do I need to do anything extra for the mouse to work on the android device if someone plugs it in

devout depot
#

Trying out that samyam video that was recommended to me, might be cool

devout depot
#

It seems like it should since android uses the same USB protocols everyone else does

tame oracle
#

okay, I might see if I can find a usb-c to usb adapter just to test it

devout depot
tame oracle
#

that fact NO ONE online had the same question on me that I can find leads me to believe that it just works

gleaming oar
#

Hmmm well I did have to create separate input actions for mouse input and touch input

devout depot
#

To my surprise, Unity can connect to Bluetooth devices in much the same way according to that document

gleaming oar
#

Shoot and ShootMouse have the same functionality, just connected to different input types

devout depot
#

@tame oracle if you're on Windows, maybe take a look at the android subsystem for windows to help you along

#

Holy cow this samyam is blowing other tutorials and guides out of the water with how clearly she's explaining things.

gleaming oar
#

Another thing the new input system solves is the previous conflict of reading input and the physics system. Before you'd have issues where you would try to move the player in Update() and it would give jittery movement/clipping glitches because the FixedUpdate is where all the physics processing happens. You could try to process everything in FixedUpdate, but it isn't guaranteed that your input will be received on a FixedUpdate frame. So you'd sometimes click and nothing would happen. The new system you don't have to worry about any of that

devout depot
#

You know, now that I'm watching this it's all beginning to make sense. With a bunch of crap thoroughly demystified I can suddenly see the advantages of the system

#

I don't know if that makes me more or less angry because this 30m youtube video is utterly humiliating Unity's official resources on the matter. It's criminal how poorly they explain it!

west beacon
patent gazelle
#

Pretty new to using the new input system, but I'm trying to have my game recognize when a player clicks on a game object (2D). Been doing some research on ways to do this and saw things like OnMouseDown() and Raycasts but wasn't sure if there was a better way to do it with the new system. Any recommendations on ways to go about recognizing mouse clicks in 2D?

#

From what it sounds like, OnMouseDown() no longer works with the new input system so I'm looking for some direction. 😅

jagged wyvern
#

make a detection method subscribe to an input action bounded to mb1

patent gazelle
#

Could you explain a little more what the detection method could look like? I understand how to create input actions with the system but I'm struggling with checking if the object has been clicked on.

jagged wyvern
#

raycast is your best bet

patent gazelle
devout depot
#

Okay, so I do feel like I've actually learned a bit about the Input System, but I've hit a weird snag. I'm trying to use unity events to trigger the Fire() function in the weapon controller script. No matter what I do it seems I can't get any functions to appear in the PrimaryFire event in PlayerInput

jagged wyvern
#

show a screenshot

devout depot
#

I tried simply plugging the weapon controller script into it, nothing. Wrote a bunch of stuff into the character controller, still can't see nothing

#

Of the player input component?

jagged wyvern
#

yes

devout depot
#

I'll go ahead and put the scripts up on Gist too

jagged wyvern
#

does the fire() method have an inputcontext parameter

devout depot
#

You mean like cs Fire(InputAction.CallbackContext context) ?

jagged wyvern
#

yea

devout depot
#

No, but I'll give that a whirl.

#

Nope, that didn't seem to do it

#
    public void Fire(InputAction.CallbackContext context) //pow pow pow
    {
        
    }
#

that's what I tried

jagged wyvern
#

is it a monobehaviour

devout depot
#

Pardon?

jagged wyvern
#

the weapon controller script

devout depot
#

Here's the weapon controller script, lemme do the char controller too

#

I mean there's scr_WeaponController : MonoBehaviour in the class declaration

#

Man though it feels like I'm getting close to a breakthrough at least

jagged wyvern
#

instead of adding a script to the bottom left input, add the gameobject

#

instead of scr_weaponcontroller

#

whatever the parent is

devout depot
#

oh my god

#

you know what the empty field even asks for a gameobject

jagged wyvern
#

unity's fault for even letting you put a script in

devout depot
#

hey what do you know, it showed up when I actually did it correctly

#

unga bunga I'm maximum smoothbrain right now

#

Anyway, lemme plug a Debug.Log into the Fire function and we'll see how the inputs are behaving

#

Yep, it reads it. Now I just gotta stop it from calling Fire() three times with each press

jagged wyvern
#

I could tell you but it would be better if you learn how yourself

devout depot
#

I'm going to set an interaction on the bind for press and release and see what that gets me

devout depot
#

lmao that literally made it worse and called it 4 times instead of 3

jagged wyvern
#

read through that if you really want to learn how everything works

devout depot
#

had that open on my other monitor actually

#

welp lets see what I can find

#

Hmm...no changes yet. I do notice I'm getting two calls of Fire() when I press, and a third when I release the button.

jagged wyvern
#

is it a button action

#

or value

devout depot
#

button

jagged wyvern
#

i think you have to check for performed inside the method

#

if

#

(context.perfomed)

#

i don't use unity events so im not entirely sure

#

or it might be
if(context.phase == inputactionphase.perfomed)

devout depot
#

Lemme see

#

This look right? ```cs
public void Fire(InputAction.CallbackContext context) //pow pow pow
{
if(context.performed)
{
Debug.Log("Fired!");
}
}

jagged wyvern
#

if not that then try the second one

devout depot
#

YES

#

IT WORKED

echo crown
#

the mouse delta action becomes far more sensitive when I'm performing the move action, how can I solve this? I'm using the default generated input actions for player input

devout depot
#

Well now, I just have to figure out how to enable fully automatic fire

#

at last

#

finally

#

FINALLY

#

It's a little hit-or-miss, it doesn't always register quick taps and sometimes just stops responding altogether, but thats a hell of a lot better than it was earlier today

devout depot
#

I'm trying this out now to try and improve how quickly the bool changes ```cs
public void FireTap(InputAction.CallbackContext context)
{
if(context.started)
{
pullTrigger = true;
}
else if(context.performed)
{
pullTrigger = false;
}

}
#

Hard to tell if it's really having an effect though

jagged wyvern
#

started and performed start at the same time unless you use an interaction

devout depot
#

FireTap is a separate function that uses the Tap interaction; in this case, started marks the moment the pressPoint is passed and performed is when it goes back below pressPoint before the tap duration

#

For once, the documentation was actually very helpful

#

god I'll tell you man that was an exhausting experience, but it definitely feels worth it. I think I might have gained XP lmao

thorn vale
#

anyone know why it gives me error that type movement already contains a definition for sprint? i tried to add sprint with new input system

sudden lagoon
#

InputField.isFocused what is replacements to this in new input system?

verbal remnant
#

Is there a known issue in the new Input System where touch events on windows are not reliably reported, particularly touch-ended/-lost events?

austere grotto
mighty mason
#

Moving over from #archived-code-general:

@austere grotto
These are all super helpful, thank you! Say I wanted to grab that InputActionReference from the code alone, I would need to somehow grab the whole input schema first, right?

Like Say I have:

InputActionReference mousepos;
Vector2 foo = mouspos.action.ReadValue<Vector2>();

If I chose not to assign mouspos through a serialization in the editor, how would I go about assigning it in the code?

austere grotto
#

where now you're referencing the whole asset

#

and you can get a particular action from a map/action name string

#

(this is assuming your action map is called "Actions")

mighty mason
#

Gotcha, so what I'm getting is that really at some point it'll require that I wire in either the whole InputActionAsset, or wire in individual actions, but either way I need to use the editor to do so, if I'm creating said mapping in the editor.

austere grotto
#

Again you can also use the generated C# class (there's a checkbox to generate this in the inspector for your actions asset), and then you'll get something like this:

// this class name is based on the asset name
MyInputActions myInput = new MyInputActions();
myInput.Enable();
InputAction mousePosAction = myInput.Actions.MousePosition;```
mighty mason
#

oh, I must've missed that part. Awesome!

#

Thank you this is super super helpful

austere grotto
#

The new system is very flexible, but it can be confusing since there's so many options

mighty mason
#

I'm getting that. Once I have it down though it seems way more robust and easy to change on the fly

gleaming oar
#

One slight change I might add is subscribing to the timing of the input action

#

At the start I would subscribe to the .started event with cs FireTapStarted(InputAction.CallbackContext context) { pullTrigger = true; } and the .performed with another function cs FireTapPerformed(InputAction.CallbackContext context) { pullTrigger = false; }

#

which would required adding them to the top cs controls.InputTest.started+= context => FireTapStarted(context); controls.InputTest.performed += context => FireTapPerformed(context);

waxen raven
#

can | get some help

#

p l z

#

any one

gleaming oar
#

just ask your question

waxen raven
#

but i just can seem to get it to work

gleaming oar
#

Well I would start by watching this video a few times and copying what she does 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
waxen raven
#

I have

#

they never did anything with analog sticks

#

ill watch it again and check back if it worked

gleaming oar
#

Do you have an input action map for an analog stick setup?

#

your action type should be value, and control type should be stick

#

the binding will list all the sticks unity supports

waxen raven
#

let me check

#

the mode is set to "Digital normalized"

gleaming oar
#

let's see it

waxen raven
#

ok

#

hold up my start menu just broke

#

i need to reset my pc

#

back

#

@gleaming oar here you go

gleaming oar
#

excellent, and how are you reading the value in code

waxen raven
#

invoke unity

#

don't question the value's

#

there for testing peruses

gleaming oar
#

I'm not super familiar with using the Player Input component as I've instead just created a new object from the generated controls class

waxen raven
#

im making a multiplayer game

#

"local"

gleaming oar
#

Is it a requirement for you to use the PlayerInput component?

waxen raven
#

I believe so

gleaming oar
#

Ok, I think you'll have to access that component in your Player Move script then

#

and it should be similar to doing it the other way

waxen raven
#

you need to use the player input manger to make 2 players

#

and when ever you use the player prefab it doesnt let you

#

im so sorry but i gtg

gleaming oar
#

controls.Player.AnalogStick.performed += context => ListeningFunction(context);

waxen raven
#

in awake? or update

#

ive already done this

#
        MoveAction.ReadValue<Vector2>();
        MoveAction.performed += ctx => Move(ctx);
        MoveAction.performed += ctx => analogValue = ctx.ReadValue<Vector2>();```
molten wharf
#

Hello! Can the input system be used the specify which direction your character moves on the map?

waxen raven
#

idk

molten wharf
#

Or is that a coding thing?

waxen raven
#

yeah probley

#

theres a really good website on the input system if you want

molten wharf
#

Sure I would love to see it

waxen raven
#

ok, is it okay if i dm it to you?

molten wharf
#

Sure

waxen raven
#

k

waxen raven
austere grotto
waxen raven
#

does any one know why i cant select my functions in the select function dropdown menue in unity

#

I only see mono script

austere grotto
#

You need to drag a GameObject that has the script attached to it into the slot

austere grotto
#

You have what?

waxen raven
#

i have script in slot and in player

austere grotto
#

Right - like I said dragging a script into the slot is not correct

waxen raven
#

ok

austere grotto
#

If you have the script attached to your player GameObject, what you want to drag into the slot is most likely your player GameObject

waxen raven
#

mhm

#

thank you so much

#

but my functions arnt showing up now

#
    {
        rb.AddForce(analogValue.x, 0, 0 * speed * Time.deltaTime);
    }    

    //Jump Function
     void Jump(InputAction.CallbackContext ctx)
     {
        rb.AddForce(0, jumpPower, 0);
     }```
austere grotto
waxen raven
#

ok

#

it worked thanks again

molten wharf
austere grotto
#

Anything is possible with the right code.

molten wharf
#

Okay. I'll need some help figuring out the right code when I get to that point.

olive loom
#

how do you use the chat system with the new input system for detecting when the player pressed enter while text box is active?

molten wharf
#

Would this work to move a player diagonally?

molten wharf
#

Answer: It works!

austere grotto
austere grotto
#

You can use the on submit thing for the InputField

olive loom
#

oh yeah

#

thanks

waxen raven
#

my controller shows up in input debugger but not in console, w h y ?

#

when I unplug my controller it says "XinputControllrWindows"

void sphinx
#

How would I go about setting up " Quadrupedal controller" for the player? Would this be using Unity's new input system? Any tutorials for this?

austere grotto
void sphinx
#

I don't see video's for Quadrupedal controller

austere grotto
#

It seems to me that "quadrupedal" would be primarily an Animation concern

#

I've seen people make procedurally animated walking creatures with 8+ legs

#

But the way the character controls generally has little to do with that

void sphinx
#

I'm googling more. So Quadrupedal controller, you think this is a separate collider for each leg? Why not just use 1 collider?

austere grotto
#

I never said that

lost mirage
#

Heyo folks, I have a question~ Is it possible to set up W|A|S|D 2D vector composite along with a held button?

Like shift+W|A|S|D?

foggy notch
cerulean shoal
#

Hey guys, so I am using Brackey's player movement script for 2d but it runs on the old input system. Can someone help guide me through how to switch it from a code perspective. I watched a bunch of videos, but all of them weren't super helpful because many are outdated

cerulean shoal
#

Thank you so much @austere grotto. This looks like what I was looking for. I'll let you know if I have any questions

austere grotto
#

I always forget that it's possible to just declare InputAction(s) directly on a component and use them directly

foggy notch
#

Does anyone know if mobile touch on Unity Remote is supported on the new Input System?

#

I can't get it to work and I'm seeing old threads that say it doesn't work, but I mean come on the new input system has been out for over 2 years and getting it to work with Unity Remote is vital to get people to switch, it should be integrated by now

celest spire
#

hi, someone can help me? I'm getting this error: "The type or namespace name 'InputTestFixture' could not be found (are you missing a using directive or an assembly reference?)"

#

I don't understand why it don't find InputTestFixture class

dark viper
#

guys help

i cant add license on unity hub
btw im in macbook and i logged in and im connected to the net

#

whts the problem

austere grotto
celest spire
#

no, I needed to change the manifest

red coyote
#

hey

oak quest
#

Which one should I use "Send Messages" or "Invoke Unity Events" on behavior

jagged wyvern
#

unity events if you want more customization

#

messages if you just want it to work

buoyant ibex
#

I am making simple driving simulator to play with my steering but the issue is input is not detected until some threshold amount of wheel is rotated. Is there any way to solve please

#

it works fine after threshold is crossed

austere grotto
#

It'll be in the configuration of your Axis (old input system) or Input Action (new input system)

buoyant ibex
#

I am using new input system

austere grotto
buoyant ibex
#

i tried that too though

austere grotto
#

yep, add a processor for the deadzone

buoyant ibex
#

brb let me try again

austere grotto
#

oh also - another thing to try is temprorarily remove the other bindings, sometimes they interfere

buoyant ibex
#

you mean other actions ??

austere grotto
#

no

#

other bindings

#

on the Steer action

buoyant ibex
#

okay thanks will try

austere grotto
# buoyant ibex

I think uncheck Default there and set the deadzone Min to 0

#

or something quite small

buoyant ibex
#

cant assign lesser than that

austere grotto
#

really? 🤔

buoyant ibex
#

i'll recheck

#

ya it resets to default

#

but thought deadzone means end points of sticks

#

like range of value from controller

austere grotto
#

deadzone is how far you can move the joystick before it detects any movement

#

all movement inside that zone is "dead"

buoyant ibex
#

what is difference on axis deadzone and stick ?

#

stick defines both axis dead zone ??

austere grotto
#

not sure

#

I've never used them

buoyant ibex
#

I changed default value from input settings to 0 now it might work i guess

cerulean shoal
#

Hey guys, so I am using Brackey's player movement script for 2d but it runs on the old input system. Can someone help guide me through how to switch it from a code perspective. I watched a bunch of videos, but all of them weren't super helpful because many are outdated

foggy notch
buoyant ibex
#

solved issue

#

thanks

#

but it was quite opposite to what you said

#

i set min dead zone to 0 and max to 1

#

deadzone is sth like [min,max] where value less than min is dead and greater than max is dead

cerulean shoal
foggy notch
cerulean shoal
#

so, I set it all up in unity, but idk how to do it in code.

#

I added the stuff

#

private void Awake() { controls = new PlayerControls(); controls.Enable(); }

#

But idk how to convert this

#

horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;

#

into the new system

#

@foggy notch

wooden furnace
#

I'm doing the roll a ball tutorial and I can't get the ball to move under my player input property in the inspector I see this error. Could this be why?

#

I am really stupid. I figured it out and fixed it though.

torn finch
#

what is the best way to get mobile input ?

torn night
unborn drum
#

is there a better way to do this? ```cs
input.Player.Sprint.performed += () => isSprinting = true;
input.Player.Sprint.canceled += (
) => isSprinting = false;

jagged wyvern
#

No

foggy notch
#

I was gonna ask a question about how to figure this out but I figured it out on my own

#
public class CinemachineManualInputProvider : MonoBehaviour, AxisState.IInputAxisProvider
{
    public Joystick rotateVCamJoystick;
    public virtual float GetAxisValue(int axis)
    {
        switch(axis)
        {
            case 0:
                return rotateVCamJoystick.Horizontal;
            case 1:
                return rotateVCamJoystick.Vertical;
            case 2:
                return 0;
            default:
                return 0;
        }
    }
}
#

If you ever need to provide your own input to a cinemachine, you can do it like this

mortal ridge
timid dagger
#

basic question: how can i receive multiple inputs at the same time?

mental musk
#

What would be the preferred way to recognise "Combo" inputs like: Down, down, up, up, left, right, a, for example

mortal ridge
#

track them in script

timid dagger
austere grotto
ornate spindle
#

I'm using the new input system and I'm trying to do just up,down,left,right,forward,backward for movement, but the vector3 has other dimensions that cause my player to do wacky things unless it's on the zero y axis, how do I change the Vector3 to just vector3.left etc like the old

foggy notch
#

Theres no such thing as a three dimensions stick, you only need your input in 2d vectors

mental musk
ornate spindle
foggy notch
ancient axle
#

So, this is weird. I get this error:
NullReferenceException: Object reference not set to an instance of an object InputTemplate+CameraLookActions.get_CameraPan () (at Assets/InputActions/InputTemplate.cs:1399) CameraTargetManager.Awake () (at Assets/Scripts/CoreSystem/Camera/CameraTargetManager.cs:21)

In a call to auto-generated code. What gives? What do I need to be passing in here? I don't think I'm doing anything special, so it's a little frustrating to be blocked on this.

ornate spindle
#

Fixed my issue, lol had the rigid body on the inner object of my player so it was going wild...

jagged wyvern
ancient axle
jagged wyvern
#

do some debugging

ancient axle
#

I'm staring at the debugger. Any time I try to reference any of the actions they're null. It's some kind of setup issue; do I need to instantiate the generated code for the ActionMap before I reference it within an object?

jagged wyvern
#

yes

ancient axle
#

Can you point me to sample code for this? I downloaded some viking warrior sample thing and have watched three YouTube clips but I'd love to have some reliable reference code to work with.

#

'clips' - they were each 20 minutes long.

ancient axle
#

Thank you.

#

You are a gentleman and a scholar.

#

Nice. It works. Instantiating and setting up the callbacks rather than attempting to access the properties fixed the issue.

#

Uh. Follow up question. Will this thing manage its own Singleton state? Do I need to worry about instantiating the class in two separate places, and build a manager class around it to avoid that?

remote mantle
#

uh how do you switch input settings from the old to new input system

remote mantle
#

im getting this error

#

but I don't how to change it

foggy notch
remote mantle
#

I didn't write a script yet

#

at least for the new input system

#

I commented out the old code

foggy notch
#

It's referring to an old script you wrote

#

You have a script that does Input.whatever

#

Which is why your getting that error

violet niche
#

He hi, i wonder if someone could point me out how to use Unity UI button highlighting with the new input system and a gamepad.

#

I am currently using the Handler interface calbacks to refresh the highlight state of the buttons, but i guess it should support it natively (?
Is there any issue with that?

#

I get the UI elements highlighted and can navigate with the mouse, but when using the gamepad i can only navigate and select, no highlight change.

foggy notch
violet niche
#

Im just asking if there is any known issue about the input system not doing the highlight transition

#

lol

remote mantle
foggy notch
remote mantle
#

all the inputs nI have are commented out

#

lemme send code

foggy notch
remote mantle
foggy notch
remote mantle
#

text and stuff

foggy notch
#

Disable the UI and see if the error goes away

remote mantle
#

im sorry stupi8d nquestion how do you disable ui

foggy notch
#

The canvas...

remote mantle
#

that didn't work

foggy notch
#

The error is still there?

remote mantle
#

yep

late shuttle
#

Ehi guys, I created 2 gameobject and they have the same new input system I would use them simultaneously in the same scene. Inside Unity, they work both, when I press D, they move right in the same time. When I build the game, only one works. What can I do? 😢

small saffron
ancient axle
#

Is there an easy way to make key-presses act the same way as controller presses? It seems like the Logitech F310 I have continuously sends right thumbpad data, where the keyboard processes a keypress once and leaves it there.

ancient axle
# foggy notch The new input system

I'm working with the new input system. As I said, the thumbpad sends continuous events where the keyboard does not. I guess I can simply operate off of the 'triggered' property, but the autogenerated, "OnCameraForwardBackward" event ends up with two different types of input.

#

Actually, I'm wrong, nevermind. The thumbpad just changes more.

lost mirage
lost mirage
#

found it! I needed to click all for the search, it was hidden

exotic mesa
#

Using the Input Actions, how would one go about performing a "tap and hold" type of action?

jagged wyvern
#

hold interaction

final geode
#

Hey, how I check what the last controlScheme my player used is?

#

I want on screen prompts to change based on what input the player is using, and I have controlSchemes for keyboard and gamepad

exotic mesa
#

Specifically I'm trying to create a dash movement on a 2d platformer. Currently when I double tap the button, the player performs a dash. I have the interaction double-tap set to 2. This results in the player needing to tap and release the button twice, then push the button down a 3rd time to continue running. Does that make sense?

jagged wyvern
#

there will be a callback when you switch controls

final geode
#

mhm, I have a reference to my inputActionMap already set up

#

though I'm not sure if thats the correct component?

jagged wyvern
#

do you have a playerinput component

final geode
#

no, I dont think so

jagged wyvern
#

use it

final geode
#

I cant

jagged wyvern
#

you can

final geode
#

not without dramatically changing my code base

jagged wyvern
#

you don't have to?

final geode
#

I'm using a third party input system, sort of

jagged wyvern
#

ok and?

final geode
#

but it still uses InputActionMap and inputActions

jagged wyvern
#

so?

final geode
#

oh hm.... player input component.... I've never used this before

jagged wyvern
#

ok

final geode
#

ok, I added it, selected my controls, set default scheme...

final geode
#

oh man I have no idea how to use events

#

alright, got my gamepad inputs working.... I just... I have no idea how to make use of these events and actions

jagged wyvern
#

you don't see it?

final geode
#

I see it, I dont understand how to implement it

jagged wyvern
#

make a method that changes screen prompts when that event is triggered

final geode
#

it says the action tahts being done when onControlsChanged.... but what do I get out of that? how do I use that to define other things or change things in if statements?

#

how do I check if that event is triggered

jagged wyvern
#

playerinput.oncontrolschange += methodyoumake

#

just make a method that changes the UI textures

final geode
#

thats the easy part

#

assume I have that already

#

changeInputPrompts()

#

so like... Im still nto clear on how to implement this

jagged wyvern
#

you make methods subscribe to the event

final geode
#

I dont know how to do that

#

I've never worked with events

jagged wyvern
final geode
#

still having trouble subscribind to the event....

#

I dont know how to write the method in this case

#

what is its return type?

jagged wyvern
#

void

final geode
#

cant do void, it errors

#

Cannot implicitly convert type 'void' to 'System.Action<UnityEngine.InputSystem.PlayerInput>'

#

inputComponent.onControlsChanged += Testing_onControlsChanged(); error caused by this line

#

I learn best by seeing a working example and reverse engineering it...

#

atm, i have no idea what a working example looks like

#

and its not going to be shown in this video

undone imp
#

Hello! Does someone know how can I make Delta X behave like the old input system function Input.GetAxis("Mouse X"). I tested and Input.GetAxis("Mouse X") gave small values(1; 0; -1; 1,5) but Delta X gives values like 30, 50, -20 and so on.

final geode
#

not for my specific thing

austere grotto
undone imp
final geode
#
void Start()
    {
        player = GameMaster.i.player;
        inputComponent.onControlsChanged += InputComponent_onControlsChanged;
    }

    private void InputComponent_onControlsChanged(PlayerInput obj)
    {
        throw new NotImplementedException();
    }``` 
this is what I got when I auto completed after the +=
jagged wyvern
final geode
#

ok, I made some progress... I debug.log`D everytime input changes, and thats working

#

now I need to figure out which input it was changed to

#

got it

austere grotto
undone imp
#

NewInput.GetAxis is reading the input action value

austere grotto
undone imp
#
        {
            var inputAction = PlayerInput.actions[actionName];
            return inputAction.ReadValue<float>(); 
        }```
gleaming oar
#

if it was a normal action and you wanted a void type you would leave the function name without the ();

final geode
gleaming oar
#

void type on InputAction require the little discard underscore thingy controls.Touch.TestTouchMouse.performed += _ => TestFun();

final geode
#

gotcha

#

thanks

gleaming oar
#

haha that was mostly for me so I could remember

dusk portal
#

Hello, im' using the old input system. I have a problem with the touch phases. It seems that I correctly receive the touchphase.began, but sometime I don't receive the touchphase.Ended or Canceled. Is it a known bug ? Or did I missed something ?

quaint geode
#

new here, how do I add a new method to an input listening on a key I've already set ?

#

I added Interact to listen to F press and hold... but not sure how to register a method to that listener

gleaming oar
gleaming oar
quaint geode
#

do you even have to do that, or can you just add the method handlers in the StartAssetInputs.cs .... it seems to be getting called without being verbose and registering it in Start();

lost mirage
#

Wait... can you not add an already created InputAction to an InputActionMap?

final geode
#

if I do

private void OnEnable()
    {
        inputComponent = GameMaster.i.player.GetComponent<PlayerInput>();
        if (inputComponent.currentControlScheme != "Keyboard")
            return;
        SR.sprite = KeyboardButton;
    }```

then it only errors when controlScheme is Keyboard.... this makes absolutely no sense to me
#

ah I fixed it.... appearantly OnEnable happens before Start

lost mirage
#

Is there any way to map a keycode to a controlpath?

austere grotto
#

Oh you figured that out already ☺️