#🖱️┃input-system

1 messages · Page 28 of 1

burnt atlas
#

i think its fine

austere grotto
#

Is this code in Update?

burnt atlas
#

I know with Input.GetAxis you shouldnt be multiplying with time delta

burnt atlas
austere grotto
#

then it's fine

#

make sure there's no processors or interactions on these actions either

burnt atlas
#

ok it was just so much more sensitive it threw me off

#

thanks

analog junco
#

Hello
I follow a tutorials to implement the input system but I don't understand the difference to use .start and .canceled in OnEnable and OnDIsable and WasCompletedThisFrame() in the Update() for activate a button. What is the difference between theses 2 methods ?

private void OnEnable()
{
    Input = new InputMap();

    Input.PlayerInput.Enable(); //Enable the player input actions

    Input.PlayerInput.MovementInput.performed += SetMovement;
    //if the input is canceled, set the movement to zero
    Input.PlayerInput.MovementInput.canceled += SetMovement;

    Input.PlayerInput.ActionInput.started += SetAction;
    Input.PlayerInput.ActionInput.canceled += SetAction;

}

//Subscribe to the input system
private void OnDisable()
{
    Input.PlayerInput.MovementInput.performed -= SetMovement;
    Input.PlayerInput.MovementInput.canceled -= SetMovement;

    Input.PlayerInput.ActionInput.started -= SetAction;
    Input.PlayerInput.ActionInput.canceled -= SetAction;

    Input.PlayerInput.Disable(); //Enable the player input actions
}

private void Update()
{
    MenuInput = Input.PlayerInput.MenuInput.WasCompletedThisFrame();
}

rugged pasture
#

Huh. Yeah, not seeing it there either. I could have sworn I had this working with a previous project...

supple crow
#

Well there's your problem!

supple crow
#

In short:

  • Started means that something is happening, but the action hasn't been performed yet. For example, the action could have a "Hold" interaction on it
  • Performed means that the action has..been performed!
  • Canceled means that we've stopping trying to perform the action -- e.g. we let go of a button or let a joystick return to the neutral position
#

You generally want to use performed, not started

#

But you might want to, say, start playing a sound during a one-second hold interaction

#

that would be an appropriate place to use the "started" phase

rugged pasture
supple crow
#

oh

#

your bindings are for a gamepad, not a joystick

rugged pasture
#

Oh, there's a difference? 😅

supple crow
#

a gamepad is like an xbox controller

#

a joystick is a flight stick

#

oh, but the "dual action" is a gamepad, isn't it?

analog junco
supple crow
#

This sounds much more like a flight stick, though

#

I wonder if the input system is incorrectly interpreting it as a joystick

rugged pasture
#

Hmm... I did wonder why it maps it so oddly.

#

The "Hat" seems to correspond to the DPad. The right-stick is rz and z.

supple crow
#

Most flight sticks have a little "hat" -- it's basically a digital joystick

#

it's definitely being interpreted as a joystick

#

the input system doesn't recognize this device

#

check out that unitypackage linked in the thread -- maybe that'll help you here

rugged pasture
#

Oh, wow. It sounds like this is a fairly long-standing issue. Maybe why I got the gamepad for so cheap.

#

Ah, and reading further down, it's due to a lack of standards on gamepads. Fascinating. Well, I had fodder for a new article!

supple crow
analog junco
#

I want to add this method of my PlayerMovement class ```c#
public void OnJump(InputAction.CallbackContext context)
{
Debug.Log("Jump");
}

when I push my button Jump. So, in my InputManager I add this line : ```Input.PlayerInput.JumpInput.performed += PlayerMovement.instance.OnJump;```
But, when I started my game, I have this error on this line on my InputManager : ```ArgumentException: Value does not fall within the expected range.``` 
Why ?
austere grotto
#

Also where is this:

Input.PlayerInput.JumpInput.performed += PlayerMovement.instance.OnJump;```
And how do we know `PlayerMovement.instance` is ready to go at this time?
late plume
#

i dont see the jump event here (works with sendmessages using OnJump)

#

and i dont see move for that matter either when using invoke unity events

austere grotto
#

By pressing the little triangle

late plume
#

ah

#

thanks!

versed stone
#

How do I make an action that execute a specific thing when tapping, and another thing when holding for enough time. I was searching on the unity docs but the page had a massive storm of information and I got lost and couldnt find what I'm looking for

austere grotto
#

and listen for the performed

versed stone
#

I think yes, but what I want to do could be simply done with only one. It's a dash system that when you hold for enough time it triggers a super dash instead, and I need to count the time the dash button was hold. But idk the keywords to detect that

austere grotto
#

you would need to write a special interaction/processor or just use the basic interaction and handle the logic yourself in code.

versed stone
austere grotto
#

i mean a regular action without any interactions defined. That gets you the default interaction

#

and then handling the logic either in Update or with events

versed stone
#

so it would go like this?

  if(input.IsPressed()){
    timer += Time.deltaTime;
    if(timer >= superDashTime){
      superDashTrigger = true;
    }
  }
}
austere grotto
#

superDashTrigger = true;
Wouldn';t you just do the super dash there?

versed stone
#

well the button should be released to do that

austere grotto
#

but no you need essentially a small state machine

#

when you first press - start the timer

  • when the timer reaches super dash time - do the super dash
  • if the button is released before super dash time - do a regular dash
austere grotto
versed stone
austere grotto
#

yes

versed stone
#

ok, got it

austere grotto
#

but you will want to use WasPressedThisFrame and WasReleasedThisFrame to detect when it first starts being pressed (to reset the timer) and when it's released (to dash)

versed stone
#

interesting, ty

austere grotto
#

you could also use events rather than Update, but I don't hate Update for this

warm wadi
#

Hey y'all. I'm trying to make this bus move by touching the back of it. I've got an invisible button set up as a child object, and I'm trying to make it add force to the rigidbody 2d when it registers a touch on the button. Can anyone help? What am I doing wrong?

fierce compass
#

oh wait you're assigning the velocity directly

#

make sure the bus rb is set as dynamic if you want it to process velocity

#

also make sure you don't have something like camera following the bus, if you did the camera would just move along with the bus so it would look like the bus wasn't moving
if you do want the camera to follow the bus, put something else in the scene as a point of reference

austere grotto
#

Use the event trigger component

#

And make sure your camera has a physics Raycaster 2d

#

You'll also need an event system in the scene

supple crow
austere grotto
#

It's just awkward

warm wadi
#

I just need to detect when a game object is touched, and I can't find a proper tutorial for how to do that. Does anyone know a tutorial for that?

warm wadi
#

Or is there someone I can pay to show mw how? Because I have no idea

austere grotto
#

With your finger?

warm wadi
warm wadi
#

I was able to get the event system done based on this tutorial https://www.youtube.com/watch?v=mRkFj8J7y_I
But it's using mouse clicks, and I don't know how to code the script for touch

Welcome to a new video about detecting clicks in Unity 2D. This is a really simple way to detect clicks, and you can easily expand the code to allow for dragging and other actions.

Let me know if you need help with anything!

The script: https://github.com/chonkgames/Detect-Clicks-in-Unity-2D/blob/main/InputHandler.cs

► Subscribe: https://www....

▶ Play video
#

Like I know I need to do input.gettouch and find the touch phase as begun, but I don't know the command for getting the x y of the touch or how to connect it to the collider

austere grotto
#

the tutorial's approach is not great either

#

what I explained above is all you need

#

Then you just set up a listener for the touch in the inspector for the Event Trigger

#

just like you would with a Button

#

none of it is code except writing the part where you move the object

warm wadi
#

Oh cool

#

I'll try that

warm wadi
#

So I've created an object with the event system and trigger, and in "First selected" I put the object I want to detect the presses from, and in the event trigger, I added the object I want moved, with the function "Begin drag" because I guess that sounds most like what I need

#

I also put this physics 2D raycaster on the camera

#

But I'm unsure what I need in the function box

austere grotto
austere grotto
warm wadi
warm wadi
#

I got a lot of errors in the console from doing that so probably not

austere grotto
#

Second you need to make a function to call from your button

#

Third you need to configure your IDE

#

Because right now it's not set up to work with Unity

warm wadi
austere grotto
#

Make a public function and set it up as the listener in the inspector for the event trigger

#

Ypur code right now is, to be honest, complete nonsense

warm wadi
fierce compass
sonic sageBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

primal atlas
#

you over here nav

turbid rock
primal atlas
#

thank you so much

#

for helping me out with this

turbid rock
primal atlas
#

fixed that to InputActions

#

didnt know that was what i was referencing there

turbid rock
#

this you probably don't need

primal atlas
#

yeah i just deleted that since i dont need to throw an exception now

#

since it found it fine

#

but another question then

#

so like... how am i supposed to have my position change then with WASD?

#

cause some tutorials show i need vector2 change

#

with OnMove()

#

but some dont

turbid rock
#

OnMove assumes you're using the SendMessages mode for example, or maybe linked action in inspector directly

#

You don't need that , not even the Player input component actually.

#

you already have everything linked from that Asset that has the mapping to your C# script auto generated InputActions

#

so its all subscribed I see here

#

This will auto call OnMove when you press Wasd

primal atlas
#

and exactly how i have that is fine?

#

except _playercontrols

#

i switched it to _playercontrols = new InputAction();

turbid rock
#

why

primal atlas
#

so its enabled the inputaction map within OnEnable i thought?

turbid rock
#

that should be InputActions

primal atlas
#

yeah my bad

turbid rock
primal atlas
#

thats what i meant

#

my bad

#

so wha ti have there (besides interact not being made yet)

#

that is fine 100%?

#

and i can attach my input action script to my player gameobject?

#

and its... good?

turbid rock
#

inputAction doesnt attach to anything

#

its not a component

#

its just a plain c# class, thats why it needs instantiation with new()

#

Monobehaviours (Components) instance get created when you put it on a gameobject.. thats another topic though

primal atlas
#

i guess im confused why its not a component if ive attached it... to my player

austere grotto
#

You haven't

primal atlas
austere grotto
#

That's PlayerInput

primal atlas
#

is this not a component ?

turbid rock
#

you dont need that anymore

austere grotto
#

Totally unrelated

primal atlas
#

i can remove that?

turbid rock
#

yes

primal atlas
#

my god this is so all over the place

#

maybe its just me

#

but i cannot find a SINGLE up to date tutorial on the new input system

turbid rock
#

nah its just Unity made it like 3 different ways to use this thing

#

this is usually the most type-safe way

#

anything you add from now on goes in the Input Actions asset you shown earlier, the one with generate c# checkbox. Everytime you save a new change there, the class PlayerInputs gets automatically generated with the new items/actions

turbid rock
primal atlas
#

okay, im trying this out and fixing all my compiler errors i was making when trying to figure this out

#

give me two seconds please

#

to like

#

make sure this works

austere grotto
#

But yeah there are many ways to use it, that's probably why you're confused

primal atlas
#

no joke ive been trying to be insanely self sufficient but ive been blocked on this controller input for like over a week

turbid rock
#

no worries took me literally 3-4 years to attempt the new Input System

#

the older one was a lot easier, but also yeah its pretty limited with newer inputs and rebind

primal atlas
#

yeah and im sorry - i just feel so weird downloading pre-built packages for everything

#

theres some things i feel like i need to understand, and i just feel like id need to understand the controller

turbid rock
#

I mean it would be insanity having to code your own inputs, this package is a good thing lol

primal atlas
#

wow it works

#

jesus

#

now i need to rotate char look position based on mouse and then do some sprint / jump / crouch

#

but thats another day

turbid rock
#

one block at a time

primal atlas
#

can you give me a very quick like.. what im probably going to look at doing

#

is it just within controller and just adjusting playerheight on keypressdown?

turbid rock
#

what kind of game exactly, don't think i caught that

primal atlas
#

lovecraftian horror basebuilding

#

hehehe

turbid rock
#

so like 3d ?

primal atlas
#

yes

#

similar to like duskwood

#

is my goal

#

duskwood and project zomboid

turbid rock
#

ohh zomboid is dope

primal atlas
#

zomboid controls but duskwood art

#

zomboid has such incredible controls and depth and me being a programmer by nature makes me want to attempt something with depth like that

#

its inspired me

#

i walk around in debug mode and see all their variables they use on everything

#

its insanity how much they look at

#

but im trying to figure out their FOV, follow mouse, and the crouching stuff

turbid rock
#

yeah those games have a lot going on

primal atlas
#

every game jam i want to add just a TINY bit more

brisk hollow
#

Wanted to create a composite bind with CTRL + a number key, but it seems like some shortcuts used by the unity editor are blocking my bind. Is there some way to make it so that while playing, I can use whatever binds I want in game without the editor overriding them?

#

looking online for a solution right now, but it's just people complaining about the same thing

supple crow
#

That appears to block the cmd+X shortcuts for me (on macOS)

#

which the equivalent to ctrl+X on Windows

brisk hollow
#

ah, I had the window set to half width on my screen so I didn't see that option there. Thanks! Surprised no posts I found mentioned it

#

they were all like 'why is there no way to do this' even from only a year ago

clever pilot
#

Im using the new input system on a project, and Im trying to set the spawn point of each player (local multiplayer). I have split screen enabled, so the prefab im instantiating have their own camera child. Im kind of getting it to work but because the origin of the prefab isnt exactly at 0 where the model of the prefab is (it's like in the middle of all the components), getting the transform to work is not only inconsistant but I have to set the Y value to like 5000 or else they fall through the terrain.

There's gotta be a better way

austere grotto
clever pilot
#

Second time running it back to back (no changes made), they finally dropped into their spots but it took a minute

austere grotto
#

You can toggle it with the Z key

#

Yeah you have it set to center

#

that's why it looks like the average of all the child objects instead of where the actual pivot/object position is

clever pilot
#

is that editor change gonna affect the script ?

#
public void SetSpawnPoint(Vector3 spawnpoint)
{
    transform.position = spawnpoint;
    Debug.Log(transform.position);
}

#

this is being called from my gamemanager

austere grotto
#

It doesn't affect the script. It will simply show you where the actual transform.position is in the editor

#

The gizmo is at transform.position only when it's set to Pivot

clever pilot
#

right im setting the position of the prefab to the spawn point, but I think its a similar scenerio where its taking into account the camera as well and that center is being spawned outside the model

austere grotto
#

your problem is you have mispositioned objects because you haven't been able to see where the actual position of your objects are because of that setting

#

switch it to pivot then go through all your objects/prefabs and ensure the positions are as you expect

clever pilot
#

what object am i mispositioning ?

#

the prefabs get instantiated when the player input manager calls the player join event

#

they're not in the scene at start

#
public void SetSpawnPoint(Vector3 spawnpoint)
{
    transform.position = spawnpoint;
    Debug.Log(transform.position);
}

this is in my player script, which is tied to the prefab's empty GO parent

Empty GO > camera, CanvasUI, Model

#

does that function's transform.position set take into account the center of all the children ?

austere grotto
#

the object doesn't care about its children

#

just its own pivot

austere grotto
#

your spawn points

#

I don't know for sure because I can't see your project

#

but you're spawning things under the ground

clever pilot
#
public void SetSpawnPoint(Vector3 spawnpoint)
{
    startingPOS = transform.Find("HorseModel");
    Debug.Log("Default start Pos: " + startingPOS.position);
    startingPOS.position = spawnpoint;
    Debug.Log("Set start Pos: " + startingPOS.position);

}

Alright I found a way to get the child and the debugs confirm the set position is set above the terrain

austere grotto
#

are the actual things that matter, such as the renderers, colliders, etc positioned properly in the prefab?

#

If the root of the prefab spawns above the ground but the renderers and colliders etc on the prefab are 100 units below the root, they will still spawn under the ground

clever pilot
#

look properly positioned to me

austere grotto
#

What are we loloking here though

#

the spawned object in the scene?

clever pilot
#

the collider

austere grotto
#

If it's above the ground then what's the problem?

clever pilot
#

the rendered object ?

austere grotto
clever pilot
#

thats when I dragged it to the scene. U keep mentioning the positioning of the prefab but theyre not in the scene at start

#

pivot mode

austere grotto
#

And which object is selected

austere grotto
#

I mean open the prefab itself

#

you can double click a prefab to open it in prefab mode

#

Then you can:

  • make sure the prefab root is at 0,0,0
  • Make sure the children of the root are not offset from the root
#

And when I say double click the prefab I mean the original in the project window

clever pilot
#

root wasnt at 0 !

#

ty

#

i still dont understand why if I was manually changing the transform.position at 10 for the y-axis in the script, it kept falling through tho but its fixed

#

the prefab y was originally -3.something but even the difference between 10 and -3 wouldve been 7, above the 0,0,0 terrain

dusty urchin
#
private InputSystem input;

public string GetSelectedItem()
 {
     if(input.Player.ItemSelecting.IsPressed())
         return input.Player.ItemSelecting.;
     
     return "none";
 }

Guys, how can i get id of pressed binding?

austere grotto
#

I think you will find it's actually simpler in the long run to simply use 4 separate actions

#

This will also greatly simplify for example the rebinding process

dusty urchin
austere grotto
#

It doesn't take very long to make the actions

#

and it makes everything else much simpler

dusty urchin
unkempt plover
#

Does anyone know why my movement buttons work in the editor but not in the build version on android? Im using the on-screen button component

austere grotto
unkempt plover
austere grotto
#

By... looking at it?

#

In the inspector

#

share it here if you don't know what you're looking at

unkempt plover
#

so this thing or no

austere grotto
#

the Input Module

#

it's a component on your Event System in your scene

unkempt plover
austere grotto
#

ok that looks fine

#

I would check your logs in android

#

(using the Android Logcat package)

#

make sure there's no errors in there

#

(needs to be a dev build)

unkempt plover
#

this is also one of the buttons

unkempt plover
unkempt plover
#

its showing no errors

unkempt plover
austere grotto
#

Or not at all?

unkempt plover
#

yes

austere grotto
#

Add some logging in your input handling and movement code then and check it in logcat

unkempt plover
#

you can clealy see them turn grey when pressed

austere grotto
#

if it's responding to the touch then things should be working normally

unkempt plover
austere grotto
#

the fact that the button is reacting to your touch leads me to believe it's a code issue.

#

Or maybe it's a control scheme issue

#

Are you using control schemes?

unkempt plover
austere grotto
#

Is that a question or a statement

unkempt plover
austere grotto
unkempt plover
austere grotto
#

How else is your player moving

unkempt plover
austere grotto
#

I know that it's working on keyboard

unkempt plover
#

so should it work like that too

austere grotto
#

that depends on how you linked everything to the code and whether you're using control schemes for example

#

the gamepad device might not exist on android, for example

#

what happens if you bind the on screen buttons to the keyboard keys instead of gamepad?

unkempt plover
#

im trying it rn

#

still nothing

#

"the up motion event handeled by client, just returned" is the thing that shows up on the logcat but no error

austere grotto
#

So isn't it your movement code that's at fault?

unkempt plover
#

i guess

#

well heres the whole code but not sure why it shouldnt work

austere grotto
# unkempt plover

put a log inside OnMove and see if it's reading the input properly

unkempt plover
austere grotto
#

how would you do what? Put a log in your code?

#

You type in Debug.Log(...)

#

you'll want to log the actual input value to make sure it's as you expect

unkempt plover
#

but what do i put inside therte

#

and to what spot so i works

unkempt plover
austere grotto
#

Like I said, log the input you're receiving

#

like

Debug.Log($"Move input received, value is {moveInput}.");```
unkempt plover
#

thank you

#

Move input received, value is (1.00, 0.00).
this is what i get in editor but i should probaly test it on android

#

"requestedHideFillUi(null anchor = null " is a new debug

#

but im not realy seeing anything else

#

new

#

@austere grotto

austere grotto
unkempt plover
#

that could be

unkempt plover
#

@austere grotto so any ideas im kinda lost?

tame oracle
#

does anyone have advice for how to set this up? i have a layout configured and stuff but there are no tutorials on how to actually check when an action is called that work for me

#

it just seems like a really unnecessarily complicated system

#

the tutorials for it all seem completely different

#

i'm so lost

fierce compass
burnt mist
#

Hey there! I have a bit of a weird isue. I'm implementing my Input System for my game using the new input system, C# class generation and ECS.

My Unity project has been originally generated on Windows, but I'm also developing my game on Mac. Back on Windows, all inputs were working perfectly fine and my character could move around and look around.

But now, I'm on Mac and no input is detected AT ALL!

I'm instantiating my input system doing _playerInputSystem = new PlayerInputSystem(); (PlayerInputSystem being my generated class)

And then, in the OnUpdate I'm getting the moveInput doing:
var currentMoveInput = _playerInputSystem.Player.Move.ReadValue<Vector2>();

But it won't change from 0,0

Any idea why it would do that? Is there a difference between windows and mac for keyboard/mouse that I don't know about?

fierce compass
#

have you tried debugging the raw inputs?

#

go to your playerinput component and open the debugger at the bottom of the component

#

also make sure you've pushed all your changes (on windows) and pulled all your changes (on mac)

burnt mist
#

Hmm by the look of it, there are no device. But I do have a mouse/keyboard (and even though, it's a laptop, so they are hard wired to it lol)

fierce compass
#

uh, check if you have the inputsystem set in your project, i guess?

#

im really not sure where to go from there lmao

burnt mist
#

It looks all good to me lol

#

Maybe I should try and restart unity, who knows lol

#

Ahhh here they are! I had to restart the bloody thing lol

fierce compass
#

ah yes, the classic solution lmao

burnt mist
#

Yes it works now 😂

#

I'm literally watching the IT Crowd as we speak and I haven't even tried to turn it off and on again

#

Ironic

#

Thanks for the support :p

tame oracle
#

all the tutorials i can find all say completely different things and none of them tell you how to actually use it

#

i'm convinced it's broken

fierce compass
#

ok well without any specifics i have no idea what issues you're encountering

tame oracle
#

i've been trying stuff for the past 5 hours straight

frozen musk
#

Can you post a screenshot/bit of code with what you want to happen? Are you using the Input Master as posted above or just checking key strokes?

lofty mist
#

We're just attempting to check key strokes, I don't think we have an "Input Master" setup

frozen musk
#

Something like the following?

if (Input.GetKeyDown(KeyCode.T)) { do something? }

My first step when I'm doing these is just to use Debug.Log("hello") to ensure my input is being read - so that's a good start.

lofty mist
#

We're trying to get an xBox 360 controller to work with the NEW Unity Input System

#

But we can't get anything to read and we can't even tell if it's detecting our controller

frozen musk
#

So I would say double check if your controller scheme includes the 360 controller. If it doesn't add that in. Then you'll want to check your Actions Bindings are picking up that new scheme.

https://www.youtube.com/watch?v=p-3S73MaDP8 - Brackeys also has a good vid on this with controllers specifically.

Let’s set up Gamepad controls using the new Unity Input System!

Jason no longer offers the course mentioned in the video.

❤️ Donate: https://www.paypal.com/donate/?hosted_button_id=VCMM2PLRRX8GU

····················································································

♥ Subscribe: http://bit.ly/1kMekJV

● Website: http://brackeys....

▶ Play video
#

(looks like Unity is happy with any Xbox controller ^)

lofty mist
frozen musk
#

You got this, small steps and trial and error, just get a button responding and you're good!

plush chasm
#

does anyone know if its possible to make a 2d movement input without any limits on speed (im srry if its easy im really new)

plush chasm
jagged vapor
#

Hii! For the life of me I have no idea how to get my console controller .vdf file working on my Unity game. I'm trying to implement SIAPI for it

I can detect the controller correctly and vibrate it, but the actions just aren't working

Can anyone point me to a resource that will help me implement SIAPI in Unity?

tame oracle
#

does anyone know if On___() functions called through Send Messages are executed before or after the Update() function?

#

i don't really know a good way to check

supple crow
#

Here's how to check!

#
Debug.Log($"I was called at: {Time.frameCount}");
#

I really wish all log messages included a frame number

tame oracle
#

ah i see

#

wouldn't these execute in the same frame tho?

supple crow
#

You can still see the order they appear in the console

tame oracle
#

oh! i see

#

thank you!

supple crow
#

I would expect all input to happen together, either before or after the entire Update step

#

it shouldn't get stuck in the middle

tame oracle
#

okay so the On__() function is called before update

#

thank you very much!

supple crow
#

no prob (:

wicked temple
#

i am so confused by the new input system sometimes. i'm getting an error that isn't actually affecting anything

#

I did it like this, which is maybe slightly lowsy but it is sound logic

#

for some reason when i add a second action to the action mapping i then start getting the error i posted at the top

#

the gameplay still is absolutely fine, but i don't want this error to keep appearing, or cause a problem later down the line

#

even my setup for the input system is extremely simple

#

any ideas what causes this? nothing i google brings up my exact problem or a solution.

#

Errors as text:
InvalidOperationException while executing 'started' callbacks of 'Player/Move[/Keyboard/w,/Keyboard/s,/Keyboard/a,/Keyboard/d]'
InvalidOperationException: Cannot read value of type 'Single' from composite 'UnityEngine.InputSystem.Composites.Vector2Composite' bound to action 'Player/Move[/Keyboard/w,/Keyboard/s,/Keyboard/a,/Keyboard/d]' (composite is a 'Int32' with value type 'Vector2')
InvalidOperationException while executing 'performed' callbacks of 'Player/Move[/Keyboard/w,/Keyboard/s,/Keyboard/a,/Keyboard/d]

wicked temple
austere grotto
#

It will show you where the problem is

wicked temple
austere grotto
#

you can click on the error in console and look at the bottom of the console window to see it

wicked temple
#

Sorry, i'd never heard of it called that before!

#

the logs for each error is kind of the same, it's this:

UnityEngine.InputSystem.InputActionState.ReadValue[TValue] (System.Int32 bindingIndex, System.Int32 controlIndex, System.Boolean ignoreComposites) (at ./Library/PackageCache/com.unity.inputsystem@1.7.0/InputSystem/Actions/InputActionState.cs:2808)
UnityEngine.InputSystem.InputActionState.ReadValueAsButton (System.Int32 bindingIndex, System.Int32 controlIndex) (at ./Library/PackageCache/com.unity.inputsystem@1.7.0/InputSystem/Actions/InputActionState.cs:3122)
UnityEngine.InputSystem.InputAction+CallbackContext.ReadValueAsButton () (at ./Library/PackageCache/com.unity.inputsystem@1.7.0/InputSystem/Actions/InputAction.cs:1972)
GamepadSelection.OnSelect (UnityEngine.InputSystem.InputAction+CallbackContext selectCntext) (at Assets/Prototypes/GamepadSelection/GamepadSelection.cs:159)
UnityEngine.Events.InvokableCall`1[T1].Invoke (T1 args0) (at <f7237cf7abef49bfbb552d7eb076e422>:0)
UnityEngine.Events.UnityEvent`1[T0].Invoke (T0 arg0) (at <f7237cf7abef49bfbb552d7eb076e422>:0)
UnityEngine.InputSystem.Utilities.DelegateHelpers.InvokeCallbacksSafe[TValue] (UnityEngine.InputSystem.Utilities.CallbackArray`1[System.Action`1[TValue]]& callbacks, TValue argument, System.String callbackName, System.Object context) (at ./Library/PackageCache/com.unity.inputsystem@1.7.0/InputSystem/Utilities/DelegateHelpers.cs:46)
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)```
#

eugh the lack of wrapping on markup is awful, sorry

austere grotto
#

line 159 of GamepadSelection.cs

wicked temple
#

weirdly, that line has nothing to do with the directional inputs that the Vector2 message at the top of the output is mentioning?

austere grotto
#

Yeah that line is you trying to read the value of the action as a float

#

which is invalid

#

since it's a Vector2 action

wicked temple
#
    public void OnSelect(InputAction.CallbackContext selectCntext)
    {
        if(selectCntext.ReadValueAsButton() == true)
        {
            if (selectCntext.phase is InputActionPhase.Performed)
            {
                SelectCurrentTile(currentTileValue);
                Debug.Log("pressed");
            }
        }
    }

    void SelectCurrentTile(int _currentTile)
    {
        tiles[_currentTile].GetComponent<GameboardTile>().ChangeTileState(2);
    }
    #endregion```
austere grotto
#

selectCntext.ReadValueAsButton() you can't do this

#

Select is a Vector2 action

austere grotto
#

it's the Select one

wicked temple
#

My select action is a Button, not vec2

austere grotto
#

somewhere

#

how did you hook this code up to the action? I think you made a mistake

wicked temple
#

omfg i have rounded brain i swear to god

#

You're right. Thank you!!

austere grotto
#

yep that'll do it!

#

btw you don't need this Press interaction

wicked temple
#

Thanks!

austere grotto
#

you can remove it

wicked temple
#

Oh?

#

I was thinking I could have the same input for release for ui menu options

#

Just for better UX

austere grotto
#
        if(selectCntext.ReadValueAsButton() == true)
        {
            if (selectCntext.phase is InputActionPhase.Performed)
            {``` and instead of this you can just do:
```cs
if (selectCntext.performed)```
#

for release you can do:

if (selectCntext.canceled)```
#

or use a switch statement with selectCntxt.phase

wicked temple
#

Oh I see, because it's always performed as a binary input, the ReadValue isn't necessary?

austere grotto
#

yeah

wicked temple
#

cool, thank you ☺️

#

insane that they refer to the input as 'cancelled' rather than released

#

i'm surprised there's no standard on the terminology that reflects how we refer to input actions in games

#

but oh well

austere grotto
#

it might be when, for example, a Tap interaction action is held for longer than the max tap duration

#

in which case it's still being held down

wicked temple
#

oh i see, and they just don't have a released phase too because they're fundamentally identical based on how the input system settings are setup by the devs on an individual basis? 😄

austere grotto
#

something like that

#

btw InputAction DOES have a WasReleasedThisFrame()

#

you would use that if you wanted to poll input in Update instead of using events

wicked temple
#

ooooh okay okay, thank you very much!

undone imp
#

why in the new input system, a button action now is float and not bool? cant i do something so i can action.ReadValue<bool>?

verbal remnant
undone imp
#

i need to use readvalue

verbal remnant
#

why?

undone imp
#

i want to make my input system and i cant make a case only for button

verbal remnant
austere grotto
undone imp
#

Didnt know, thanks 😄

solar pivot
#

I want to disable hand tracking in my game on Quest. It's a controller-based game, but when I double tap my controls together, hand tracking turns on and my players can't play until it turns off again. I know Gorilla Tag has this turned off, so it should be possible.

I'm using the OpenXR plugin, and have hand interaction poses turned off.

Anyone know how I can turn it off?

hasty iris
#

Hello,
I have two action maps : Player and Dialogue that share a binding to the same key E.
In Player action map, E is bound to action Interact.
In Dialogue action map, E is bound to action Continue.

My player input component has its behavior set to "Send Messages".

Is it normal that even with only the Player action map enabled, when I press E, both methods OnInteract() and OnContinue() are triggered ?

Thank you for your help.

hasty iris
topaz lion
small quest
#

Hopefully someone else can comment if activation is needed or not

topaz lion
#

still not working :/

wicked radish
#
inputActions.Player.Look.performed += ctx => 
        {
            mouseX += ctx.ReadValue<Vector2>().x * rotateSpeed * mouseSensitivity;
            Debug.Log( Time.frameCount );
        };``` How frequent does input system actually trigger? Why am I getting skipping values here?
#

it's skipping frames

clever pilot
#

Is there a way to bind a wii controller using the WiiMote API to the new input system. Similar to how the analog stick works on a game pad with a 360 degree type of input ? Or woul I just have to convert the axis' rotation in a script instead ?

#

might be niche but figured I could try to see if this approach was possible

austere grotto
#

It's not meant to happen every frame

wicked radish
#

Thank you

keen zodiac
#

We're having problems with the Input System. When adding a new device, being by code or because a real device was connected, sometimes it's assigned to a new "User", and this user "steals" the Actions from the other user. The result is that sometimes you can't move anymore on the other device. How do we solve this problem? Either by making actions "global", or assigning everything to the same user by default.

We sometimes use "fake" devices for cutscenes. And this whole user system is bugging our game out.

austere grotto
#

Is this a local multiplayer game?

keen zodiac
#

no. it's a singleplayer game. we don't need multiple users

austere grotto
#

Are you using PlayerInputManager?

#

and/or PlayerInput at all

keen zodiac
#

we use PlayerInput. that's where we put our actions

austere grotto
#

PlayerInput is intended to be 1 to 1 with physical human beings

#

you should never have more than 1 if it's a single player game

#

New devices being connected won't spawn new PlayerInputs automatically unless you're using PlayerInputManager

#

The other thing you should not do if it's single player is use control schemes

keen zodiac
#

we're not spawning another one to my knowledge. what we do is call AddDevice to add our fake cutscene device. and sometimes that's assigned to a new user that steals the actions

austere grotto
#

control schemes are there solely to differentiate users based on devices

#

double check if you have PlayerInputManager in your scene(s)

keen zodiac
#

i'm checking. i can't find a component like that

#

we have two PlayerInputs

#

one for menu controls. another for everything else

#

is that bad?

austere grotto
#

yes that's bad

austere grotto
keen zodiac
#

oh..

#

right.. so it should be on a scene that runs forever

#

a unique one

#

thank you!

rose oriole
#

Why is there such a huge disconnect between how the input system behaves in editor and how it behaves in IL2CPP builds?

verbal remnant
rose oriole
#

I can't for the life of me get the input system to dispatch any events in an IL2CPP build from an object spawned with Instantiate, whilst in editor this works.
Binding via this pattern m_MoveToAction.performed += MoveToActionPerformed; works in editor regardless of what's going on, but in IL2CPP builds only works if a PlayerInput object exists in the scene

#

I've tried also calling WasPerformedThisFrame in the Update method, which works fine in the editor, but also doesn't necessarily work in IL2CPP builds

austere grotto
#

you might just have some kind of execution order issue with how you set up your listeners or something

#

(have you checked the player log?)

distant raptor
#

moving up in the world

weak bolt
#

With compensation, if anyone would be willing to take an hour of their time to help me understand the new input system and how to implement them with pre-existing scripts in a discord call, please let me know.

blissful lotus
fierce compass
#

just !ask

sonic sageBOT
fierce compass
#

we don't really support private or vc help either; that defeats the purpose of a support server

livid silo
#
actionRef.action.PerformInteractiveRebinding(actualBindingIndex)
    .WithControlsExcluding("Mouse")
    .WithCancelingThrough("<Keyboard>/escape")
    .OnComplete(operation =>
    {
        newKeyPath = actionRef.action.bindings[actualBindingIndex].effectivePath;
        string newKey = newKeyPath.Replace("<Keyboard>/", "").ToUpper();

        // Check for conflicts
        InputAction conflictingAction = FindActionUsingKey(newKeyPath);
        if (conflictingAction != null && conflictingAction != actionRef.action)
        {
            // Store for later reassignment
            actionToRebind = actionRef;
            bindingIndexToRebind = actualBindingIndex;

            // Show popup
            conflictMessage.text = $"The key {newKey} is already assigned to '{conflictingAction.name}'. Replace it?";
            conflictPopup.SetActive(true);

            operation.Dispose();
            return;
        }

        // No conflict, apply immediately
        ApplyBinding(actionRef, actualBindingIndex, settingsField, newKey);
        operation.Dispose();
    })
    .Start();

i want to check if the button is already taken by another action to display a warning popup with buttons cancel and proceed. I did it but now i realised its not working properly, apparently when the code reaches .OnComplete then its already too late, button is assigned. I can manually revert it back but is there a better way? An built-in method for some conditions before applying the change?

verbal remnant
tawdry wind
#

Anyone gotten this problem before? It's just stuck on this forever. Is there a way to close it?

runic chasm
#

Hi, I have a little problem, I want to mix keyboard and controller inputs for a split screen game mode I would like to have the classic configuration (joystick to turn L2/R2 to move forward and brake) but I can't find what to enter in the input manager.
Thanks

exotic phoenix
#

Hello guys. I have a split-screen game with two player controlled objects (both have a player input comopent). I would like the default controls for both players to be the keyboard. One player has the left side (WSAD - IKJL) and the other player the right side (arrow keys - numpad 8246). Creating two control schemes didnt work for me. Any tips on how to achieve that?

copper urchin
#

i need help getting the inputs from each dpad input

#

i wanna make it so the 4 directions on the dpad each correspond to a different item the player has

austere grotto
#

assign one dpad button to each

copper urchin
#

i did but how do i then make it so if for example i press up on the dpad it will make the player use a healing item

austere grotto
#

that's a whole separate and potentially complex question

#

for example is this something the player can equip items to?

#

Or is up just always healing?

copper urchin
#

well i dont need help with the healing item itself, i just wanna know in code how to set it so when up is pressed something happens

austere grotto
#

it has nothing to tdo with the input system at that point htough

austere grotto
#

it would work like any other button in the input system

#

set it up the same way

copper urchin
#

it's not the same

austere grotto
#

How do you mean? It is exactly the same

copper urchin
#

I have this right now

#

if (inputAction.Player.DPadUp.triggered) { Debug.Log("Up"); }

#

but when I press up nothing happens

austere grotto
#

show the full script

#

also show how you configured the action

copper urchin
#

`` public character player;
public PlayerInputActions inputAction;
private InputAction up, down, left, right;

private void Awake()
{
    inputAction = new PlayerInputActions();
}

void Start()
{
    
}

void Update()
{
    if (player.shopOn == true)
    {
        Bag();
    }
}

private void OnEnable()
{
    up = inputAction.Player.DPadUp;
    down = inputAction.Player.DPadDown;
    left = inputAction.Player.DPadLeft;
    right = inputAction.Player.DPadRight;


}

private void OnDisable()
{
    up.Disable();
    down.Disable();
    left.Disable();
    right.Disable();
}

void Bag()
{
    if (inputAction.Player.DPadUp.triggered)
    {
        Debug.Log("Up");
    }

}``
austere grotto
#

You never enabled your input actions

#

inputAction.Enable(); is necessary

#

also !code

sonic sageBOT
copper urchin
#

of coruse it was something stupid like that

#

thanks, that worked

tame oracle
#

hi, was wondering if there is an easy way to pass values through to a prefab instantiated by playerInputManager

austere grotto
#

which gives you a reference to the newly instantiated object

#

you can do whatever you'd like with that reference.

tame oracle
#

oh! i see

#

what's the formatting for the reference out of curiousity

#

finding documentation for this has been tricky

austere grotto
#

formatting for what

tame oracle
#

to assign the instantiated object in the script

#

i'd assume its

void OnPlayerJoined(GameObject prefab)
{}

austere grotto
#

no

#

it's a C# event

#

you have to subscribe to it

tame oracle
#

oh okay

austere grotto
tame oracle
#

ah i see

#

thank you!

vestal crane
#

which one of these lets me just read the value as a float?

#

so far everything returns 0 here

#

I guess if there's a way to directly get a bool, that would be better but it seemed like you just had to convert from the float from what I saw online

austere grotto
vestal crane
#

where would I do that?

#

I've already gotten the movement vector2 to work if that helps

vestal crane
austere grotto
#

show your code

vestal crane
austere grotto
#

the full script

#

!code

sonic sageBOT
austere grotto
vestal crane
#

yes

#

so where do I do that

austere grotto
#

onenable or awake?

vestal crane
#

it has to be an event?

austere grotto
#

wdym

#

you have to enable the action before it's used

#

that's all

#

The code to enable it needs to run

#

then it will start working

vestal crane
#

is that only for buttons?

#

since my movement vector didn't need me to do anything else

austere grotto
#

It's really hard to help since you haven't shared any code

#

it's for all actions if you're using InputActionReferences

vestal crane
#

I'm porting from the old system

austere grotto
#

right so you need to enable your actions

#

confirm.action.Enable();

#

e.g

vestal crane
#

alright

austere grotto
#

if it's working for the axis, something else has enabled it

#

or possibly if it's a Pass Through it might not need enabling

vestal crane
#

this is the only script with the new input package

vestal crane
vestal crane
#

move (axis) is also just a value, not a pass through

#

looks like theyre all enabled by default

#

since this is always true

vestal crane
#

I still haven't fixed the problem, btw

austere grotto
#

I don't even see a confirm action in your list

#

and hwy are you tryin to read it as a float?

#

shouldn't it be a regular button?

austere grotto
#

I also don't see you enabling it in the code you shared.

vestal crane
#

is what I'm going off of

#

specifically

vestal crane
austere grotto
#

yes triggered or WasPerformedThisFrame is generally the right idea - but you need to set the action up as a regular button not an axis

#

just - Action Type: Button

vestal crane
#

still nothing with all of these

#

good format discord

austere grotto
#

please stop cropping your screenshots so much

#

you're cutting out all kinds of useful context

vestal crane
austere grotto
#

the action configuration would be great

vestal crane
austere grotto
#

look at your control scheme

#

only used for gamepad but bound to a keyboard key?

#

Is this a local multiplayer game?

vestal crane
#

that's proabably it

#

its literally the only keyboard input to have that

#

registers now but only for a frame

#

or wait

#

let me test something

austere grotto
#

that's intentional

vestal crane
#

yeah

austere grotto
#

you want to know if it's held down?

#

use GetValueAsButton()

vestal crane
#

that's why i wanted to go with the float method

#

ok

austere grotto
#

or IsPressed()

#

sorry yeah IsPressed()

vestal crane
#

thanks

drifting shard
#

Does anyone know if it's possible to use the split screen in the input system stacked in vertical rather than horizontal?

#

Also if it's possible to make new players use the gamepad first and if there are no gamepad available then the keyboard

Edit: I managed to do this by setting the Default Scheme to Gamepad in the player input

#

right now it's the opposite

worldly kestrel
#

hi
i need the link to documentation where i can see all methods/functions for Input System
so far i have searched but it ended in disappointing theory
i just moved to unity from godot

worldly kestrel
#

i would like to study it myself
but i cant find the list of methods, i did try the pinned links
please help

fierce compass
sonic sageBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

worldly kestrel
fierce compass
#

moveInput is a Vector2 that holds an x and a y, where you can get x via moveInput.x
here you only have an x, which you can get via horizontalMovement

#

since you can't move vertically, you don't need inputY at all

#

also if you only care about horizontal control you could use a float instead of the Vector2

gloomy vapor
#

my character can face all 4 directions and i have 4 animations assigned, it just walks horizontally

fierce compass
#

ok, they can face 4 directions, but they aren't the same 4 directions the tutorial means, most likely

#

this would be for 4-directional movement

gloomy vapor
#

i think i just need to connect inputY with up and down arrows, i just dont know how to do it

#

so its 1 when Up arrow is pressed, and -1 when Down arrow is pressed. i thought i could do it in the same way the system reads if theyre pressed for movement, just without the movement

fierce compass
#

but you aren't doing the same way

#

you're taking the x of the input right away

#

you never get the y here

gloomy vapor
#

where can i get the y from

fierce compass
#

the input

#

what would pressing up/down even do though

#

that animation doesn't really make sense if you can only move left and right

gloomy vapor
#

you can face up and down and i have animations for that

gloomy vapor
fierce compass
#

do you understand the code in the tutorial

gloomy vapor
#

i belive i wouldnt have to ask for help if i did

#

tutorial command takes input from all 4 keys. what i use only takes input from 2

fierce compass
#

but you want to take input from 4... so take input from 4

gloomy vapor
#

i need to take input from the other two separately, so it doesnt move my character

#

thats what i believe could be a solution

#

or i jut have to make a bool for each key but i really wanted to avoid that

gloomy vapor
#

so how else can i solve this

fierce compass
#

many ways

  • get the y direction by reading the input again and getting the y
  • read the full vector locally, then assign just the x to horizontalMovement
  • read the full vector like in the tutorial, then only use x to control the rigidbody
#

just for example

gloomy vapor
#

i have that in plan, for today i just want to get the controls done and never think of them again

fierce compass
#

oh, you'll have to

unkempt stump
#

Good morning, everyone. I'm hoping that someone here might be able to help me. The gamepad and keyboard inputs seem to be fighting with each other, causing the player to grind to a complete halt during gameplay, if the keyboard/mouse are moved/pressed when using the gamepad. The inverse also happens (ie. touching the gamepad, while using keyboard/mouse).

I've set up a 'ControlsManager.cs' script to handle managing the input but I'm unsure of how to force Unity (via code) to distinguish between gamepad and/or keyboard/mouse input to enforce the use of one over the other, so it doesn't swap to using the other, if the first is in use. Any advice is appreciated.

    public Vector2 getMove() { return move; }
    public Vector2 getLook() { return look; }
    private void moveCallback(InputAction.CallbackContext context) { move = context.ReadValue<Vector2>(); }
    private void lookCallback(InputAction.CallbackContext context) { look = context.ReadValue<Vector2>(); }
austere grotto
#

That seems fully expected to me tbh 🤔

#

Basically when you release the keyboard key you're going to receive an event with a value of 0. If that was the latest event you received, that's what your input value is going to be set to.

unkempt stump
#

Yes. Pressing forward on the gamepads left joystick makes the player go forward. If I wiggle the mouse while doing so, the player grinds to a halt, despite still pressing forward on the gamepads left joystick. And it's definitely not intended behavior. XD

austere grotto
unkempt stump
#

For some reason, Unity is interpreting mouse movement as joystick movement and I need to find a way to reject how Unity is handling that.

austere grotto
#

mouse movement shouldn't be involved here at all

unkempt stump
austere grotto
#

that sounds like a separate issue from the conflicting controls issue

#

if the mouse input is feeding into your action here without any mouse binding something else is going wrong

#

How are you hooking these listener functions up to the actions?

unkempt stump
#

I mean, they're all 'controls'. And by name, from the InputActions.

austere grotto
#

wdym by name

#

you have code doing that?

unkempt stump
unkempt stump
# austere grotto you have code doing that?

So, I figured it out; it's a defect with the Unity InputSystem auto-switch feature, under the player InputActions component; the defect being that Unity detects mouse input as the gamepad/controller's left-joystick input, despite not being defined in the InputActions to be so.

If left in its default configuration, the PlayerInput component can be observed (via the debugger) rapidly toggling between gamepad & keyboard/mouse inputs, if the mouse is moved during gameplay (even just bumping the table enough to jostle the mouse triggers this).

If I set the default scene to gamepad and turn off Auto-switch, the intended behavior actually occurs and moving the mouse doesn't interfere with the players controls/momentum by causing them to grind to a halt. The over-all issue being that, when Unitys default auto-switching occurs, the input value from the mouse is deemed to be zero (or so significantly less than what the current left-joystick gamepad input is being clocked at from 0 to 1) and immediately overrides the previously calculated velocity values to be zero.

I'll need to implement custom logic on my end, in order to baby-sit Unitys auto-switch feature so it works correctly and it'll probably look something like this:

if ( /*Is Gamepad Connected?*/ ) {
  if ( /*Is a menu Open?*/ ) {
    // Set 'Default Scheme' to 'Any'.
    // Set Unity 'Auto-Switch' to 'active/true'.
  } else if ( /*Is gameplay level loaded, with no menu open?*/ ) {
    // Set 'Default Scheme' to 'Gamepad'.
    // Set Unity 'Auto-Switch' to 'disabled/false'
  } else {
    // Some other, currently unknown case...
  }
} else {
  // Set 'Default Scheme' to 'Any'.
  // Set Unity 'Auto-Switch' to 'active/true'.
}

That said, thank you for being my rubber-duck here. TwT

acoustic mica
#

Hello, does anyone know how to resolve an issue with the Input Actions system where keyboard modifier keys (Shift, Control, Alt) are not being read properly on key press & key release? All other keys and mouse button bindings are being read properly, even when mapped to the same Action as the Shift/Control/Alt binding.

eg)
1st full key press & key release of the "shift" key will log:
Started
Performed

2nd full key press & key release of the "shift" key will log:
Canceled

austere grotto
acoustic mica
#

Yes!

This is how I configured the bindings in the Input Actions Editor. I only want the Dash Action to be bound the "Shift" key, but was testing it with "Ctrl" (another modifier) and with "Q" key (non modifier). The Dash Action is of Action Type - Button.

The code snippet is how I'm checking which context phase is being read on key press and key release, upon pressing any of the Dash Action bindings. The OnDash() method is in a PlayerInputReader class that inherits from both ScriptableObject and the C# class created by Input Actions Editor. I'm using this ScriptableObject to read player input and send appropriate events to the main player controller class.

austere grotto
#

This is just the binding

acoustic mica
#

Sorry, here's the action properties window

austere grotto
#

and how did you hook this action up to the code?

#

Is it via the SetCallbacks thing on the generated C# class?

acoustic mica
#

Yes ^^ by using SetCallbacks

austere grotto
#

i don't see anything inherently wrong here

#

what happens if you remove all but one binding?

acoustic mica
#

Having only "Shift" as the sole binding for the Dash Action results in this:

1st full key press & key release of the "shift" key will log:
Started
Performed

2nd full key press & key release of the "shift" key will log:
Canceled

Having "Ctrl" as the sole binding results in the same issue above. Having any other key such as "Q" as the sole binding for the Dash Action results in proper reading of all 3 context phases.

#

The issue occurs with Shift, Control, and Alt bindings, which leads me to believe it maybe be an issue with only the modifier keys

austere grotto
#

I just tested it

#

working fine for me

#

Both with Shift and Left Shift

#

Possibly it's a hardware or OS setting issue

#

Maybe you have Sticky Keys eturned on in WIndows?

#

Yeah If I turn on Sticky Keys then I get your behavior

#

Solution: turn off sticky keys

acoustic mica
#

maybe an OS setting issue? I've tested it with several different keyboards and they all show similar results. I also have Sticky Keys turned off by default, and tested it with Sticky Keys on and they both have the same results surprisingly

#

maybe i'll test in a brand new unity project

#

Update:

I double checked sticky key settings and realized I was looking at the wrong page! I have all sticky key toggling shortcuts off, but my sticky keys were actually on. Unchecking it solves the issue.

#

Thank you Praetor for the assistance! 😄

austere grotto
#

no problem!

#

Also yeah while i was investigating that I too got confused by the sticky keys settings UI

glossy summit
#

when i build with webgl it wont detect keyboard input. does the new input system just not work well with webgl or something?

devout summit
#

Hi, I'm quite new here, and I was wondering if I can assign the grip buttons on my Steam Deck as separate inputs in Input Actions? (Not mapping them to existing buttons like the D-pad or X/Y/A/B.)

verbal remnant
#

You can implement a custom device that responds to the manufacturer signature of the steam deck and reinterpret all that but if the inputs are already recognized, what would be the point?

hoary flame
#

I just updated the Input System coming from a pretty old version. So far I used it with generated C# classes and Instantiating the actions when I needed them, like
input = new PlayerInputActions();
where PlayerInputActions is the generated C# class from my inputactions map.
Now there is the global actions and it seems kinda useful.
But can I use the global action map with a strong typing? Having type safety is so useful compared to handling around magic strings

flint snow
#

hello there
quick question
when using gamepad rumble, am I supposed to call the function on every frame?
( _currentInputDevice as DualSenseGamepadPC )?.SetMotorSpeeds ( 0f, 1f );
cant really figure out how to use it properly

proud gyro
#

Hi, I have an empty parent object (Britain) which I have made a Territory object by assigning the Territory script. It contains an OnMouseDown method which moves Britain. I want the meshes of its game object children (UK & Ireland) to activate OnMouseDown method for Britain but I can't seem to find why its not doing it (after following instructions online.

Both the children have mesh colliders and work if the script is added to each individually, where they act as seperate objects. Can anyone help me?

timid dagger
livid silo
#

I'm using input system 1.13.1
Inside unity editor everything is working but when I'm trying the build, player controls aren't working, any ideas why is this happening?

haughty marsh
#

Hey im trying to get the input system to work but noting else other then manuscript is there

austere grotto
#

You need to drag a GameObject with the script attached to it into the slot, not the script itself

gloomy vapor
#

my buttons are not highlighting (and i think not working). at first i thought its event system issue because pressing arrows would do nothing, but in event system inspector they are selecting accordingly. theyre linked to dialogue manager script object, to MakeChoice method. theyre interactable, their navigation is set, their transition is set. i made a different set of buttons and they worked correctly. theres a separate set of keys binded just to make sure its not an input issue. (additionaly pressing choice1 button still triggers choice0 dialogue)

gloomy vapor
#

or maybe they are not selecting after all. issue stands

supple loom
gloomy vapor
#

okay

oblique raven
#

is there a way to get the ReadValue(Vector2) as a float instead int. In the old system it was called GetAxis rn it is GetAxisRaw

austere grotto
#

You can do ReadValue<float> but you need to set the action up as an axis.

oblique raven
#

already did that so i have that action map.
moveAction = myPlayerInput.actions["Player/Move"];

#

Debug.Log(moveAction.ReadValue<Vector2>()); gives me the raw int

austere grotto
#

That's not an int

#

It's a Vector2

oblique raven
#

i mean the single vector2 values

austere grotto
#

So... I'm not sure what you're asking for

#

Can you try to rephrase

austere grotto
oblique raven
#

yep

austere grotto
#

There's no built in smoothing

#

You can do it yourself with Vector2.MoveTowards in Update

oblique raven
#

allright, ty

fierce compass
drifting shard
#

If I have three players (in multiplayer) and I'm using an InputManager and each player has its PlayerInput and its camera, I keep getting an issue where the inputs are going to the right players (Say P1, P2 and P3) but the players always see the camera from P1. OnNetworkSpawn I locally disable the PlayerInput to the other two players so in theory there's no reason why that should happen. Does anyone have any clue?

#
    public override void OnNetworkSpawn()
    {
        base.OnNetworkSpawn();
        _playerInput.enabled = IsOwner;
        Debug.Log($"Spawning {this.name} am I owner? {IsOwner}");
    }

This is what I run in the MPPlayerScript

#

and if I also disable the camera:

    public override void OnNetworkSpawn()
    {
        base.OnNetworkSpawn();
        _playerInput.enabled = IsOwner;
        _playerInput.camera.gameObject.SetActive(IsOwner);
        Debug.Log($"Spawning {this.name} am I owner? {IsOwner}");
    }

I just don't get any camera renderer at all, although P1 camera is disabled locally but P2 camera is enabled locally

proud gyro
timid dagger
# proud gyro This didn't seem to work for me, do you know why?

I tested it, as long an object has Rigidbody, OnMouseDown registers all clicks for children recursively. I'm not sure what could bug your version. Perhaps something else is blocking your input.

Anyway, if you need an alternative solution, you can try sending a Raycast from your cursor's position, and then check if the parent of hit GameObject contains your script, then run its method if it does.

austere grotto
#

The correct approach is IPointerDownHandler

#

With a physics Raycaster in the scene and an event system

proud gyro
# timid dagger I tested it, as long an object has Rigidbody, `OnMouseDown` registers all clicks...

Stange, as I don't think anything is blocking the input, as the children register clicks on themself, just not the parent and unless the parent's rigidbody (its an empty object) is getting in the way, I can't think of what's causing the difference in our outcomes.

Should I add the Physics Raycaster to the camera object? As I had previously tried this but maybe I put it in the wrong palce or was missing something?

proud gyro
# austere grotto The correct approach is IPointerDownHandler

I didn't know about this new function, thanks for the info, tough, when I use this function, even the ones that did work with OnMouseDown don't work anymore. I'm using the newer version of unity so it should include the new input system but do I have to do anything in particular to allow that function to work?

I have an event system and am not sure what object should contain my phsyics raycatser for it to work

proud gyro
#

I just decided to make a new script and add it to the children, which calls the parent object's OnMouseDown function from the children's OnMouseDown functions but I appreciate all the help

austere grotto
meager bobcat
#

How do I use this new input system to read clicks that weren't on buttons? In my level, clicking anywhere on the screen except for a button is used to shoot, but UI buttons being clicked shouldn't result in a shot being fired.

fathom sandal
#

public static PlayerInput inputActions;

private void Awake()
{
inputActions = GetComponent<PlayerInput>();
}

public void Pause(bool pState)
{
if (pauseMenu != null)
{
if (pState)
{
pauseMenu.SetActive(true);
gameIsPaused = true;
Cursor.lockState = CursorLockMode.None;
inputActions.Player.Disable();
Time.timeScale = 0f;
}
else
{
pauseMenu.SetActive(false);
gameIsPaused = false;
Cursor.lockState = CursorLockMode.Locked;
inputActions.Player.Enable();
Time.timeScale = 1f;
}
}
}
Why isn't my inputActions being disabled on pause?

fathom sandal
# meager bobcat How do I use this new input system to read clicks that weren't on buttons? In my...

In this video I'll show you how to enable the new input system to work with the Unity UI, along with another cool input system feature!

ᐅGet the full Source Code Bundle to my Unity Tutorials 🤓
https://sam-yam.itch.io/samyam-full-source-code-to-all-videos

😎 Cool Unity Assets 😎
ᐅPeek - Editor Toolkit: https://assetstore.unity.com/packages/tools/...

▶ Play video
willow sinew
#

Hey, guys! Why would you recommend to use the new input system? I have heard about it and I saw some bad reviews in Unity Forums about it. Most of the devs are preferring to use the old one istead. Why?

timid dagger
# willow sinew Hey, guys! Why would you recommend to use the new input system? I have heard abo...

Perks of the new Input System:

  • easy toggling of action maps (e.g. when you open up pause menu, you can toggle off character controls and toggle on menu controls, then after leaving the pause menu you can do the opposite)
  • registering callbacks to inputs (it feels better than checking their value every frame)
  • input processing (you can modify global settings or modify particular inputs; input processing includes stuff like threshold, hold duration, and normalization; you can even modify those settings in runtime, for example, to let players invert camera controls)
  • input references (imo better than hardcoding values)
  • individual controller input support (for each action, you can individually set up generic inputs or use different ones depending on the controller, e.g. on Nintendo Switch Accept button is the East one)
  • tools for in-game control settings (you can override settings, write them, load them)
  • debug tools (you can easily check what kind of inputs are being processed)

The old input system is great if it was already set up and coded 5 years ago and you don't have time to refactor it from scratch. If something is working, then there is no point in touching it. But for new projects, I would recommend newer, more flexible solutions.

verbal remnant
strange sphinx
#

I am a beginner and I find the new Input System pretty difficult.

austere grotto
#

It definitely has a learning curve. Especially if you're still learning C#

strange sphinx
#

I come from Python and there are definitely differences between the two languages..

verbal remnant
#

its maybe a tad harder to get started but its considerably less hard to carry it through to a working system that has real world requirements

timid dagger
verbal remnant
heavy aurora
#

Is it a glitch on my project or the Unity team forgot to test the new input system asset configuration window? Every action you modify, and then every path you want to change, everything you do starts reloading the whole editor

#

Every time I want to change my inputs it is the most disgusting experience I have in the whole Unity Engine

#

There used to be a "Save" button so this window doesn't auto-save and compile every time, why they removed it?

austere grotto
#

Are you using the generated C# file?

timid dagger
heavy aurora
heavy aurora
timid dagger
heavy aurora
#

Just checked here, it seems they did not remove the buttons, but only if they're not used as "project-wide"

#

if you're using as the project-wide input actions, the buttons doesn't show

pure pumice
#

Unity version: 6.0
I have installed the Input System package and am trying to set up my own input actions in a custom input map. I was instructed to use the Listen button for setting up the physical keybindings, but hitting any of my keyboard, mouse or touchscreen inputs on my laptop after clicking on Listen doesn't actually binds any buttons nor does it have any visual feedback. Not even any errors pop up; just nothing at all happens. I have been googling this for a while and tried looking up solutions on YouTube, but I can't find any good resources on troubleshooting the Input System in general, let alone mouse inputs for games.

If anyone has good resources for troubleshooting the Input System please lmk 🙏

delicate swallow
#

make sure you subscribe the input event and enable it beforehand, i suppse the best source would be the input doc in pin

pure pumice
verbal remnant
pure pumice
#

Okay, so now I have a separate issue in that:

  • Press [TouchScreen] inputs for interacting with non-ui elements work fine.
  • Press [Mouse] inputs do not.

I'm just looking for a basic press at this point, so I'm not sure what's broken. There are also NO good tutorials that explain this that aren't UI based

#

here is the script that captures that action:

using UnityEngine.InputSystem;

public class ProjectileInstanceHandler : MonoBehaviour
{
    public GameObject ballPrefab;

    public static GameObject Instance { get; private set; }
    private Transform parent;

    public InputActionReference pressAction;



    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {

    }

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

    void OnEnable()
    {
        if (pressAction != null)
        {
            pressAction.action.performed += OnPress;
            pressAction.action.canceled += OnRelease;
        }
    }

    void OnDisable()
    {
        if (pressAction != null)
        {
            pressAction.action.performed -= OnPress;
            pressAction.action.canceled -= OnRelease;
        }
    }

    private void OnPress(InputAction.CallbackContext context)
    {
        SpawnBall();
    }
    
    private void OnRelease(InputAction.CallbackContext context)
    {
        Instance = null;
    }

    /// <summary>
    /// Attempts to spawn a new ball if one does not already exist in the slingshot.
    /// </summary>
    private bool SpawnBall()
    {
        if (Instance != null)
        {
            return false;
        }
        Instance = Instantiate(ballPrefab, transform);
        return true;
    }

}
pure pumice
#

so, I think an issue with this might be because this is an AR Foundation project.

delicate swallow
#

try enable it beforehand ?

#

something like pressAction.enable / disable()

pure pumice
#

I'll try that next time I get around to my desk

fair island
#

Hello, I have something that has an UP and a DOWN state, is it possible to create an input action that has both the UP binding and the DOWN binding, and also a TOGGLE binding to toggle between those two, all in the same input action?

austere grotto
fair island
upbeat drift
#

I'm confused. Are you supposed to use project-wide input actions if you only have one input action asset?

#

So the "player input" component is redundant in this case now?

austere grotto
austere grotto
#

I really only recommend PlayerInput for local multiplayer games

upbeat drift
#

Makes sense to me, ty

marble zinc
#

Is there a way to check for any gamepad input? There is a path that is any key [keyboard], but is there a similar thing for gamepad?

distant sphinx
#

Hey it has been a quick minute, but where do you check for overrides in the debugger?

#

I swear they were somewhere

#

nvm, it was in Layouts > Specific Devices > [Device] > Applied Overrides

#

I have a device that for some reason isn't getting matched by unity to the layout it has to use so I need to do it myself with the vendor and product ids

#

Actually what the json does is extending the layout, and layout != matching so..

distant sphinx
#

Oh it seems that the device isn't getting matched because somewhere the manufacturer info gets lost, and its getting matched through SDL and not HID as I thought

#

Is this a normal thing on Linux? The controller used to match just fine to its appropriate device type on Windows (Actually no, because the controller and its gyroscope works perfectly fine in applications that use SDL so this makes no sense)

distant sphinx
#

Oh actually I guess the reason for why its failing is because Unity uses SDL, not SDL2

#

Checking gamepad.cs and... yeah...

clever pilot
#

does anyone have any experience in creating their own custom device layout ? Or have a link to a tut (I cant for the life of me find one that I can understand). Basically ive been using the WiiMote API to get the gyroscope data from a Wii Remote but I recently found u can somehow create ur own input to read data, and this would make UI navigation and local multiplayer functionality (since its set up with the new Input system as opposed to manually doing each) much easier

spare bay
#

Hey all, a question about a possible issue around my Input System.

Currently when I launch my Game from the Editor it's all working fine (UI, controls with mouse and keyboard) but the controls don't work when I load into it from my Main Menu. I can still interact with the game modes etc. by my custom Unity Editor tools, so the game is 'working/running' fine. It's just the input that doesn't want to register. Does know why this could be? Thanks in advance!

spare bay
#

Oh, I just discovered that disabling and enabling the Input System UI Input Module restores UI interaction with the mouse and Player Input restores my controls. Is this a script execution order issue or is there something wrong with how I load/initialize the scene?

austere grotto
#

Possibly having a duplicate event system or something

blissful comet
#

Trying to make an "Enter submit" script for a TMP InputField (Separate from the OnEndEdit callback), but it seems like when the box is focused this no longer reads any input? If I breakpoint this after the enter check, I hit the breakpoint when I press enter and the box isn't selected, but when it is, I get no breakpoint. It looks like the input field is "eating" the input somehow?

if (Keyboard.current.enterKey.wasReleasedThisFrame)
  if (uiInput.isFocused)
    OnSubmit.Invoke();

Is there a way around this? A way to call a function when specifically enter is pressed?

austere grotto
blissful comet
#

Actually, looks like Event Trigger's Submit doesn't seem to work

austere grotto
#

using EventTrigger might be weird because there's multiple handlers then

blissful comet
#

Ah, hang on, I think I found the issue and it's my own fault - I try to disable hotkeys so you don't accidentally do things while typing in a text box, and one of the devices I disable is the keyboard...

#

But... why does typing work if the keyboard is disabled? 🤔

austere grotto
blissful comet
#

Okay, welp, I'm running into the corners of multiple half-assed solutions so now I gotta actually do it right negativeman

spare bay
barren smelt
#

I've got my game spawning PlayerInput prefabs, but how do I differentiate which player is applying input?

Currently each device is affecting all characters.

austere grotto
#

It will assign each PlayerInput to different devices

#

Actually TBH PlayerInput should do that itself so I suspect you're doing something fishy

#

How did you link up your code to the PlayerInput?

barren smelt
#

Switching the PlayerInput from C# functions to Unity Events did the trick. I'm not sure why, but it worked.

austere grotto
#

other than as a window to get to the InputActionsAsset

#

The "C# Events" mode on PlayerInput is the most misunderstood thing in all of the Input System lol

#

Most people misinterpret this and do something like myPlayerInput.actions["SomeMap/SomeAction"].performed += MyHandler; which actually bypasses the component entirely basically.

barren smelt
#

Ah, I did indeed call SetCallbacks on the InputActions class rather than the PlayerInput component.

Thanks for the insight.

austere grotto
high mauve
#

Is this the proper and best way to get the current input device type (not the scheme)? InputDeviceType is my own enum

    {
        _playerInput.onControlsChanged += OnControlsChanged;
    }

    private void OnDisable()
    {
        _playerInput.onControlsChanged -= OnControlsChanged;
    }

    private void OnControlsChanged(PlayerInput input)
    {
        if (input.GetDevice<Keyboard>() != null)
            _currentInputDeviceType = InputDeviceType.Keyboard;
        else if (input.GetDevice<XInputController>() != null)
            _currentInputDeviceType = InputDeviceType.Xbox;
        else if (input.GetDevice<DualShockGamepad>() != null)
            _currentInputDeviceType = InputDeviceType.PSX;
        else
            _currentInputDeviceType = InputDeviceType.Unknown;
    }```
high mauve
#

But the Logitech controller registers as an Xbox controller instead of as Unknown. Not sure if its supposed to or not

fierce compass
#

the logitech controllers i used to use had a switch on the back to switch between xinput and directinput

oak basin
#

Hey guys, what's up...?

#

I'm trying to make a system where the player can "dive-roll" when they press the left/right buttons in a double-tap

#

But I'm not sure if you can have multiple type of interactions or how they will work together...because when you hold the player will walk normally and when the player just double-taps quickly the player will dive-roll

#

I decided to make the dive a seperate action because for some reason there's no Multi-Tap interaction in Value or Pass Through

#

I have Pass Through set for my basic 2D movement, with Vector2 as the attribute, and I have the Dive as a Button (since that's the only way I can get MultiTap interaction to show)

austere grotto
#

that's not what you think it is

#

having two actions makes sense here

oak basin
austere grotto
oak basin
#

And if I keep dive with the multi tap interaction with the same movement buttons will it still work...?

austere grotto
#

yes

oak basin
#

Oh ok nice, nice, thank you, I'll try it out

#

Because all I wanted to do was replace my animations in Unity, and instead of using the Animation State Machine I decided to hard code everything in code, ever since then it's not working...I think it's the Input System

#

Also just to make sure, does the Player controller auto generated C# script need Monobehaviour...? Before it worked perfectly fine but now it's saying an error that it needs to drive Monobehaviour (I'm using Get Component, based on a tutorial)

austere grotto
#

and using it with GetComponent doesn't make any sense

#

it's not a component

oak basin
#

What's the right way to reference a script in Unity...?

austere grotto
#

or you were making a new instance manually

#

hard to say since we're talking about a mystical theoretical time which you don't have the code for

oak basin
#

I was referencing the auto-generatted C# script through a reference like this

austere grotto
#

What's the right way to reference a script in Unity...?
This question feels kind of loaded in the current context

#

because I don't think you even know what you're asking

#

To "reference" anything in C# you make a reference variable

oak basin
austere grotto
#

as for how to assign the variable that depends. If it's a Unity component you assign it in the inspector or by fetching it at runtime with e.g. GetComponent

oak basin
#

playerControls is the reference to the type PlayerController, which is my C# generated script

austere grotto
# oak basin

yes here you're simply creating a new instance with new

#

because this is the generated class which is basically a POCO

#

it's not a Unity object/component

#

you're making a new instance here and storing a reference to it in your variable called playerControls

#

this is the normal C# way of creating objects

oak basin
#

Oh so do I have to find that GameObject with GameObject.Find(playerControls), or can I just reference playerControls itself...?

austere grotto
#

it's not a Unity object

oak basin
#

Because when I was trying to search the internet that's one way I found of referencing a script

austere grotto
#

GameObject.Find is completely off the rails here

austere grotto
#

GameObjects are the things that appear in the hierarchy window in your Unity Editor

#

those are the only things that GameObject.Find can find

oak basin
#

Oh ok that makes sense...so like RigidBody or Tilemaps and stuff like that are GameObjects

austere grotto
#

no

#

those are all Components

#

Components are thje things that appear in the Inspector window in the Unity Editor

#

They are attached to GameObjects

oak basin
#

So components are like attributes to Game Objects...?

austere grotto
#

they are modular pieces that give GameObjects behavior and functionality

#

When you make a MonoBehaviour script you are creating your own custom type of Component

oak basin
#

Thank you for telling me about this, I didn't know, now I will keep this in mind when referencing stuff

oak basin
#

Ok then I'll have to find a proper way to reference the auto-generated C# script

austere grotto
#

your screenshot above is the way

oak basin
#

Because when I was watching a tutorial on making the Input System that's how they told me to refernce

austere grotto
#

Another thing to understand here is that the Input System is pretty complex and there are many different ways to use it and many different entry points to it in code.

#

So there is not just one way to do things

oak basin
#

Yeah true, I just came across a YouTube video a while back saying that the "new" Input System is better to use in the long run than the typical Input.GetKey

#

If I can get all the complicated stuff working like multi tap and special button presses then I can have some relief

austere grotto
#

It is better. It has a learning curve though. You seem to be at the very beginning of your journey here. I don't want to discourage you from using it, just pointing out you are going to struggle a bit as it assumes you know the basics of C# and Unity already.

rustic sentinel
#

can i get information on the callbackcontext about the object i hit? i want to check if my left click hits a ui element or just the empty screen

austere grotto
#

What you should do is implement IPointerClickHandler on the objects

rustic sentinel
#

oh okey, i thought i could get the screen position if i use a vector2 input for example. But the PointerClickHandler seems to be interesting, will take a look in that

austere grotto
#

Yes you could do it that way but it's better to use the event system

rustic sentinel
#

i think ill go with your method first and if that doesnt work ill try to get the positions from the input system

tame oracle
#

Can someone help me a create a custom device for the new input system? I basicaly want to create a dummy device that creates a bunch of dummy controls based on some collection of strings (HashMap, for example) that doesn't do anything and always return 0. The goal is for the list of strings to apear in the path options for bindings in the input action asset. They will only be used to identify groups of bindings that should be overrided together.

wicked sable
#

hello everyone it says he can't find the OnShoot method while i.m using it should i update the c# generate after each new action in my input system?

wicked sable
#

it says Onshoot method not found while it is added to my actions

wicked sable
#

nvmd i should name it " Shoot " not "OnShoot"

junior wraith
#

hello, i have a question, im pretty new to the "new" input system. my question is about whether i have to reference a InputAction in each script in which i need it, or can i make a one reference in scripts with static instance of it, and use that reference in all scripts where i need it?
for example i have a InputManager script where i calculate all the angle for rotating to face the mouse and stuff like that, which works cuz i can read the value and save it to a public vec2. but with a button value, where i either need to subscribe a function to it or use "triggered" value within it, im not sure, or rather it doesnt work, so is it possible or do i need to make a new reference to the Actions asset and all the input actions in it anew?

austere grotto
#

It's often useful to have only one copy of the input actions asset which you manage from one place and share it around so that input rebinding etc works in one central place

#

I don't recommend reading the input in one place

#

Just managing a single instance of the asset in one place and letting other scripts access that is usually best.

junior wraith
#

well this is my code, but when i use anything other than vector value, it doesnt work, when i use the roll.triggered in other script, it says missing reference

austere grotto
#

show the exact code you tried and the exact error you got

junior wraith
#

this is the script in which im trying to access it

austere grotto
#

The stuff in PlayerRoll.Awake and OnEnable should actually go in Start

#

because if you have it in Awake it's possible for it to run before InputManager.Awake

junior wraith
#

ill try puitting it in start

austere grotto
#

The InputManager itself should be little more than this tbh:


    public static InputManager instance { get; private set; }
    public PlayerInputs playerInputs { get; private set; }

    private void Awake()
    {
        instance = this;
        playerInputs = new PlayerInputs();
    }

    void OnEnable() {
       playerInputs.Enable();
    }```
#

Also I'm a little confused by your use of the PlayerInput component here

#

because it seems like your code is using the generated C# class.

#

which means you don't need a PlayerInput component and probably shouldn't have one.

junior wraith
#

i referenced it so i could atleast work on it while i wait for someone to help me

junior wraith
austere grotto
#

all the actual input handling can happen in the other scripts

#

because the individual scripts are the ones that know/care about how individual actions should be processed/handled

junior wraith
austere grotto
#

I'm saying there's too much

junior wraith
#

i see, ill try to change it and ill see

austere grotto
#

Like doing realLookDir = aim.ReadValue<Vector2>(); this could be handled in a script dedicated to looking/aiming or whatever

junior wraith
#

ye, that one line was useless and i deleted it, but i get the idea, ill just make a new script for handeling tose looking and angle data

steady geyser
#

I pull my move action like this:

        var moveAction = _inputMap.FindAction("Move");

when inspecting it with the debugger, there is a list of bindings, but no clear way how to pull the bindings bundled under secondary or primary.

What I'm trying to do is pull a specific binding, e.g Secondary/Left and then rebind it to another key. However I do not understand how to access it.

austere grotto
junior wraith
austere grotto
#

it's a pointless middleman

#

Whichever script ultimately would read moveDir should just grab InputManager.playerInputs itself and read Move.ReadValue<Vector2>() itself

#

And as mentioned before

#

all the OnEnable stuff in InputValues that reads from Inputmanager isn't going to work

#

because Awake/OnEnable will potentially run in a random order

#

it's just running before InputManager's Awake/OnEnable runs

junior wraith
#

well i only wanna use it for the lookDir and moveDir. the other ones i dont care about rn. but the InputManager.instance.playerInputs doesnt work

junior wraith
austere grotto
#

you just can't access it before it's initialized

#

(Also double check you actually have an InputManager instance in the scene)

junior wraith
#

so where should i put the input actions and playerinputs references in the other scripts?

austere grotto
#

as needed

steady geyser
#

@austere grottoYes sir, rebinding is the goal. I want to bind secondary and primary controls.

austere grotto
#

for example in a movement script:

void Update() {
  Vector2 moveInput = InputSystem.instance.playerInputs.Player.Move.ReadValue<Vector2>();
}```
#

though you can do some caching e.g.:

InputAction moveAction;

void Start() {
  moveAction = InputSystem.instance.playerInputs.Player.Move;
} 

void Update() {
  Vector2 moveInput = moveAction.ReadValue<Vector2>();
}```
junior wraith
#

so mostly start, update and fixedupdate right?