#🖱️┃input-system

1 messages · Page 44 of 1

austere grotto
#

change from Pass Through to Value

#

and change control type to Axis I believe

eternal pecan
#

yep that worked! thanks!

haughty fox
#

uhhh input system you ok? It seems like this happens when I directly update the value of a vector2 of a scriptableobject asset.

There seems to be no problem doing something like what I wrote here https://hatebin.com/fenspbrbmr where I update the value of the so inside update while simply just polling the vec2 on its own

#

I wanted to ask, what should the appropriate way to poll the mouse input relatiive to the centre of the screen? Currently I'm using the Mouse Position binding, which gives a vec2 with its origin on the bottomleft of the screen. What I'm doing is doing an additional calculation like this

aim = ctx.ReadValue<Vector2>();
AimDirectionData.Value = new Vector2(aim.x - Screen.width / 2, aim.y - Screen.height / 2).normalized;

and translating the origin to the centre of the screen by also polling the current screen width and height. Is there a more elegant solution to this? I could also just cache the screen dimensions, and then write another script whenever the screen gets resized to update the dims, but thats a lot of work just to get the mouse position relative to the centre of the screen.

haughty fox
tame oracle
grizzled nimbus
#

I have the following code
input.CharacterControls.Run.performed += OnRunInput;
I know that this calls the function OnRunInput when the run button is pressed.
But I also want to call the function OnRunInput when the run button is released so i can revert the speed of the character back to its initial value
How do i do that?

#

I tried to do that in the movement function, but when you keep on running in the same direction and then release the run button while still moving in the exact same direction the speed will not update

haughty fox
grizzled nimbus
#

so input.CharacterControls.Run.cancelled += OnRunInput; right beneath performed?

haughty fox
#

well depending on what OnRunInput does, so if you want your character to stop, youd want another function to do just that and register .cancelled to that function instead

grizzled nimbus
#

thanks, that seems to work

haughty fox
tame oracle
harsh seal
#

So PS5 Controller to PC to Unity is does not work?

harsh seal
#

just tried a ps4 controller and it seems to work

#

but ps5 does not?

timber robin
#

@tame oracle Stop spamming your question. You're going to be hard pressed to find someone who is proficient in that library who also got the new input system working in a Discord full be beginners.

tame oracle
#

Then were do I look?

timber robin
#

Sometimes there just isn't an answer.

austere drum
#

in the patience cupboard

timber robin
#

Someone has to be the first to solve a problem, and you're likely going to have to be that person.

tame oracle
#

I stayed up all night and still can't get it to work

austere grotto
#

Just one night?

tame oracle
#

I learned about it yesterday

#

Then spent the rest of the day looking at the code to see what was going on the tried to add the new input system.

austere drum
#

I've been trying to just rotate something for the past week... And my average day is about 18 hours of screen time.
1 day is nothing for the thing that you are trying to do

tame oracle
#

How about you animate it?

#

Or change the rotation?

timber robin
#

Do you know how the new input system works?

#

You may first want to become an expert on understanding how to use it before trying to integrate it into a library.

tame oracle
#

That's not the problem

#

The project is based around the old one

timber robin
#

Right ... so ... if it's open source, and you're proficient with the new input system, then it should be convertable?

austere grotto
#

There's a 1:1 migration for most things

tame oracle
#

Thanks, sorry if I was rude

sterile gazelle
#

😄 👍

#

and just dont deal with migration

tame oracle
sterile gazelle
#

oh that would be a problem i guess

tame oracle
#

Yeah😂

timber robin
#

If you're planning on publishing on the Switch, you are aware that you need to be a registered developer?

tame oracle
#

Yes

#

I am one

sterile gazelle
#

werent you like.... begging for switch dev codes yesterday @tame oracle

tame oracle
#

hey y'all! can anyone reccomend a good input control for touch controls ?

grizzled nimbus
#

I want to create first person controls with the new input system.
I do
value = context.ReadValue<Vector2>();
and then
_move.MoveDirection = new Vector3(value.x * runSpeedX, 0, value.y * runSpeedZ);
how do i change this so pressing forward on the joystick will also be forward where the player is looking?

#

and in the move function I have
var time = (Time.fixedDeltaTime * speed.Evaluate(_move.MoveDirection.magnitude));

#

rigidbody.MovePosition(_transform.position + _move.MoveDirection * time);

plush wasp
#

@hard hedge it could be because you're binding on perform

hard hedge
#

what do i bind it on

austere grotto
#

The perform will only happen when the button is actuated

#

Either poll the value in Update

#

Or save the value on performed and apply it each update

#

For an axis you'll get a performed every time the value of the axis changes but again not every update

hard hedge
#

how do I get it in update btw

austere grotto
#

myInputAction.ReadValue

hard hedge
#

Vector2 inputVector = controls.Player.Movement.ReadValue<Vector2>(); doesn't work

austere grotto
#

Why not

hard hedge
#

controls is a class I generated from the InputAction

austere grotto
#

Is your control type set to Vector2?

hard hedge
#

yes, i sent a screenshot on the otehr channel

austere grotto
#

Action type should be value

hard hedge
austere grotto
#

Ok so what's happening

#

Did you enable your controls?

#

controls.Enable()

hard hedge
#

yes I've doen that

#

oh wait

#

i'm dumb

#

sorry, my Move() function wasn't being called

granite ivy
#

input.GetKey is for keyboard inputs..... if i need it to find joystick(mobile)inputs i need input.GetJpystickNames .. ?

grizzled nimbus
#

okay, after some hours of research i got this
_move.MoveDirection = transform.right * value.x * walkSpeedX + transform.forward* value.y * walkSpeedZ;

#

this works for WASD

#

but when i use my control stick my character gets out of control

#

the last part is with WASD

#

and with WASD, W is always forward, A is always to the left of the char, etc

#

value = context.ReadValue<Vector2>(); as before

#

at some random points the char starts spinning in place

#

i used _move.MoveDirection = new Vector3(value.x * runSpeedX, 0, value.y * runSpeedZ); before and this did not happen

radiant pilot
#

Sorry if this gets asked a lot, but I can't find an answer online. I don't have the option to add a PlayerInput component in my game. I have Unity 2020.3.7f1 installed. Do I need a newer version? Or is there some place I can download the package?

grizzled nimbus
#

have you installed the player input package?

#

or doesn't it appear in the package manager?

radiant pilot
#

I don't think so, as I don't see it in this list

#

I'm not sure where to get it from though. Even the official documentation told me to just "select it from this list" to install it

grizzled nimbus
#

click on packages: in project

#

change it to something else

austere grotto
#

It's in Unity Registry

grizzled nimbus
#

yeah

#

i have mine under unity registry

radiant pilot
#

Thank you! I did not know that it was only showing the packages I had installed

#

I found it

#

I knew there was a simple answer, I just couldn't find it on my own 👍

tacit pecan
#

Hi guys,
Hoping someone can help me here 🙂
I am making a drag and drop type of calculator. I am not that skilled, but i have the basic understanding of the most things about object oriented development i believe.
I am using the eventsystem from Unity. Right now i need to be able to make unlimited operators by dragging from a box. So the general gist is:
You take your mouse to the box
When you click and hold a movable/dragable object is instantiated and is already being dragged by the mouse, to the position of the mouse. and then it is a drabable object like any other.
I got all the drag and drop functionality down and it works as it should. But instantiating an object that is already being dragged (OnDrag) i dont know how to force that behaviour. Hoping someone would be able to help me. Thank you 😄

eternal pecan
#

ok so im converting my controls to be controller supported, and i set the left and right movement to x and b for xbox controller (dont ask) which was a & d before, and now i can only walk back once and never again. I have already implemented the press key to join thingy and would like some help.

marsh fractal
#

I want to get the current control scheme and change inputType depending on which it is, this works like 1/10 times:

#

Can I get the current control scheme in a different way? I've been looking all over but can't find a good solution

rocky tundra
#

hey, how do i check the last input made by the player?

bleak stag
#

How to have an object point towards the mouse cursor whilst rotating around a player character in 2D? (new input system) (feel free to tag me) / how does the mouse delta work

marsh fractal
#

Is there a more effective way of forwarding unity input events from an InputManager script to my player's different state classes than using delegates? I've recently converted from Send Messages to Unity Events so I've gone from returning Vector2 and bool values to using delegates.

#

This is in my NormalState class:

#

Previously I checked HandleInput() in Update using bools for actions.

magic pier
#

So with old input, I had a Move() method that was being run in FixedUpdate that would check input and, if condition was met, would run movement code (e.g. rb.AddForce). So the physics code was in a separate method from FixedUpdate.

But from what I'm reading here, the new input system is designed so that I would move the physics code to FixedUpdate, and the movement = new Vector3 goes in the OnMove method (for example, when using SendMessages)?

#

I just want confirmation that InputSystem wants me to place my movement code in two separate locations.

#

'cause I'm driving myself mad trying to write my code sensibly.

austere grotto
#

you simply have new options now

magic pier
#

Dang, then I guess it's just me 😂 I've spent days trying to figure it out, looked at every tutorial I could find :/

austere grotto
#

what exactly does the old code look like?

#

Input.GetAxis?

magic pier
#
FixedUpdate() {
    Move();
}

Move() {
    if (Input.GetAxis("Horizontal")) {
        movement = new Vector3(Input.GetAxis("Horizontal"),0,0);
        rb.AddForce(movement * thrust);
    }
}
austere grotto
#

so good news and bad news

#

the good news is that if you get an InputAction reference - then the code for what you're doing is quite simple and more or less a 1:1 translation:
just replace Input.GetAxis("Horizontal") with myHorizontalAction.ReadValue<float>()

#

the bad news is that Input.GetAxis has some build in "smoothing" that Unity does automatically, that you can't get built in with the new input system

#

so the behavior won't be exactly the same without implementing your own smoothing

magic pier
#

And do the other ways of implementing with InputSystem have smoothing built-in?

austere grotto
#

No

#

none of them do

magic pier
#

So the drawback is only against the old InputManager, not other InputSystem implementations.

austere grotto
#

right

magic pier
#

Ok, fine by me. Now to search up "how to implement input smoothing in unity"

magic pier
austere grotto
#

you can get that in many ways

#

the most straightforward wway in my opinion is to put a serialized InputActionReference field in your script:

#
[SerializeField]
InputActionReference horizontalAction;
#

then you assign it to the input action in the inspector

#

and you can use:

horizontalAction.action.ReadValue<float>()```
magic pier
#

So the code is:

Move() {
        if (horizontalAction.action.ReadValue<float>() != 0) {
            movement = new Vector3(horizontalAction.action.ReadValue<float>(),0,0);
            rb.AddForce(movement * thrust);
        }
}

InputActionReference horizontalAction is assigned to Player/Move and I made sure that Player is the current action map.

Currently horizontalAction.action.ReadValue<float>() is always 0, even when I'm pressing one of the keys in Move, but I'm troubleshooting it.

austere grotto
#

e.g.

horizontalAction.asset.Enable();
#

but that only has to be done once, globally, for all the actions in the whole asset to work

vague gull
#

I'm trying to implement a movement system, but it'll only move on the Z axis? The other keys work, just dont move in the right direction. Can anyone help?

#

public float speed = 5.0f;
private float horizontalInput;
private float forwardInput;

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

}

`// Update is called once per frame`
`void Update()`
`{`
    `//get player input`
    `horizontalInput = Input.GetAxis("Horizontal");`
    `forwardInput = Input.GetAxis("Vertical");`

   `` //move the player forwards``
    ``transform.Translate(Vector3.forward * Time.deltaTime * speed * horizontalInput);``
    ``transform.Translate(Vector3.forward * Time.deltaTime * speed * forwardInput);``
#

This is the code I have, following a tutorial. The tutorial video seems to work fine, and I think I copied it but it wont move on X axis

magic pier
#

@vague gull Do you have a link to the tutorial? 🤔

vague gull
#

https://www.youtube.com/watch?v=CieCJ2mNTXE Its this one, but I can take a look at that one too?

Unity Basic Movement 3D Tutorial for Beginners. In this tutorial I will show you how to move a cube around with the arrow keys and make him jump with the space key. Follow this movement guide step by step and get some movement going in your first beginner game project as a total beginner.

▶ Play video
#

Not adding the jump though

magic pier
#

Ok, is Vector3.forward supposed to be in both of the last two lines?

vague gull
#

OH thats probably it lmao
I didnt notice that at all, thank you, n sorry if I bothered lol

magic pier
#

lmao I saw it the second you posted the code but I needed the tutorial to be sure 🤣

high apex
#

hi guys! ive been running into a problem with input actions, and i cant find a fix for it

#

i hope this is the right place to ask, but basically when i try to make an action map the properties tab on the far right simply remains empty and doesnt give me any options

#

is there something obvious im missing?

gusty axle
#

if you mean this:

gusty axle
#

@high apex

high apex
#

thank you so much ill take a look (:

gusty axle
#

No problem :)

high apex
#

wait no

#

its not inspector its like in the window where you edit input action maps

#

in all the tutorials i can find there should be options in the right window but nothing shows up

gusty axle
#

Do you have the newest version of unity?

high coral
#

Hey, so I am currently reading into the new input system. I was wondering about the script that an InputAction generates. In some guides the generated class within the generated Script is directly used. Whereas in other the InputActions are referenced in a PlayerInput component that lives under the gameObject that is to be controlled by the input.

So my question is: Which of these two ways is "better"? If both ways are valid, in which cases should I use which way?

#

I suspect I am completely off the rails and somehow did not understand a fundamental part about the new input system. I'd really appreciate any answers :)

austere grotto
#

-You can also directly reference InputActionAsset (the thing I think you meant when you wrote InputAction)

  • You can reference individual InputActions from an InputActionAsset directly via a InputActionReference field directly in your script
#

PlayerInput I would only recommend using if you are doing something involving local multiplayer. It is designed to work alongside PlayerInputManager and automatically create instances for each player, mapped to an individual controller for example

high apex
west oracle
slender frost
#

Hello, I am trying to use Unity's Input System to create a platformer. In the game, there will be a walk control and a run control. Walk control is executed whenever a movement key is held, run control is executed whenever a movement key is held after it has been double tapped.

For the run control key, I tried to use the MultiTap interaction on the Input System, but the control is only registered as performed when the last tap is released. Is there any workaround for this?

versed bison
#

how do i do Input.KeyDown(KeyCode.LeftControl); with the new input system?

austere grotto
boreal badge
#

Weird question, is there a difference in performance if input management, and input logic are in the same script versus separated into two?

austere grotto
#

not due to the separation itself

boreal badge
versed bison
west oracle
#

@versed bison triggered will fire twice if your action's interaction is set to Press & Release

#

but if you dont want to use Actions and you strictly want keyboard you can also use:

            if (Keyboard.current[Key.LeftCtrl].wasPressedThisFrame)
            {
                //down
            }
            else if (Keyboard.current[Key.LeftCtrl].wasReleasedThisFrame)
            {
                //up
            }
#

@slender frost that...is actually a really interesting one! Kinda surprised there isn't a built in for that.

#

Imma make one 🙂

#

LMAO Actually!

#
////TODO: change this so that the interaction stays performed when the tap count is reached until the button is released
#

this is at the very very top of the MultitapInteraction.cs

prime kite
#

im trying to make the controls pauses when the paused UI is active, i dont want to use timescale because it is a mulitplayer and i dont want everyone to freezes when someone is settings. how could i do it?

austere grotto
#

kinda funny that they have all those Keyboard.leftControlKey properties too

austere grotto
#

alternatively - if you're using the new input system - you can disable the Action Map(s) related to the player moving around

prime kite
#

oh i never thought about that

#

thanks!

#

but the movement is in the player script itself, if i disable it it will disable the entire thing

austere grotto
#

It's good practice to have each script only handle a small, well defined bit of behavior

#

"Stuff that should be disabled when the game is paused" seems like a pretty good boundary to go with for now

prime kite
#

ill try that

west oracle
prime kite
#

when i separate the movement from the player the transform.position broke, i cant move but the animation still work

#

i have the script in the player prefabs, i dont know why it didnt work

#

nevermind, switched to rb.velocity and it worked again

untold sun
#

I turn off my player controls action map, and turn on the UI controls when the pause menu comes up. Saves me from worrying about what scripts do what where and whether I've added any that I forget about etc.

twin sundial
#

is it possible to get the name of the input button the player has to press? I want my game to say "Press [nameofbutton] to Continue", but I want it to be dependent on the controller being used

frigid ridge
#

Yea I'm quite sure this is built-in to the new input system, but no idea how the API works

untold sun
#

I did something similar recently, but it wasn't totally straight forward

#

for Keyboard for instance

#

The main thing was:

                string deviceLayout, controlPath;
                int bindingIndex = action.GetBindingIndex("Keyboard&Mouse");
                string bindingString =
                    InputActionRebindingExtensions.GetBindingDisplayString(action, bindingIndex, out deviceLayout, out controlPath);
#

I preferred Gamepads if Gamepad.current was not null, and tried the keyboard display instead if it WAS null and Keyboard.current wasn't

#

And then I just have some boring code to map the binding string to the right entry in a spritesheet for display

#

But this should work fine even if they user has remapped the input

twin sundial
#

thanks!

west oracle
#

@frigid ridge there are some examples in the importable samples of the InputSystem but I'd hesitate to call it built in.

mental zenith
#

is there a known way to stop the player input manager from spawning a new prefab when a bluetooth controller is disconnected and reconnected trhough signal issues?

#

the documentation is giving me nothing

#

I just want an event to latch onto where I can stop spawning a new prefab

boreal badge
#

Can you somehow make the control type of a pass through action a boolean? So you could use ReadValue<boolean>() in the lambda expression?

boreal badge
#

Alright figured it out. For anyone interested: Action type "Button" returns a float value of 0 or 1, depending if the action is started, which you can substitute as a boolean.

west oracle
quaint owl
#

Idk if this is the appropriate channel for this question. But I've been learning UI a bit, buttons in particular, and I have a circle button and it used to work fine, I could click anywhere on the button and it would work. Then my computer crashed with some things unsaved, and now the button only works when I click the bottom half of the circle. The top half of the button doesn't work. I've tried completely rebuilding it and it still isn't working correctly. Any advice on what to check in the inspector? anything of the sort, I'm stumped

shell sonnet
#

i'm using the new unity input system and i want to add a button that you need to hold in order to activate a certain ability, so i added a new action to the action map and added bindings to the action with the hold interaction, but for some reason after i use press the button and it's activated once then it doesn't activate again. any idea why?

shell sonnet
#

please i need help this is for a 3 day jam and it's the last thing i need in order to finish the player controller and i have no idea how to fix this.

gusty axle
#

sikdw]

austere grotto
raven crest
#

HOw can I detect right click on object?

hoary walrus
#

help: Input system is only working with 3d cube object but not with other 3d objects such as assets

#

It reads the input but it doesn't do anything with the action

austere grotto
hoary walrus
nova inlet
hoary walrus
nova inlet
nova inlet
#

select any gameobject, in inspector, top right, you can see a static checkbox

rotund grotto
#

why is my Input.GetButton("Fire1") triggering on my joystick buttons that are not defined in the Input Manager

#

eg. I defined it on my Square button on ps4 controller but for some reason it also triggers on O

mental zenith
#

So as far as I understand it, if you disconnect and reconnect a controller paired to a player input component, the new input system is supposed to reconnect that controller to the same component?

#

spent hours trying to find a straight yes or no to this question now

rotund grotto
grizzled nimbus
#

how do i check in the new input system if the control stick is not tilted in any axis?

#

input.CharacterControls.Movement.canceled += OnMoveCancelled;
i have this in my OnEnable and it is never called

#

OnMoveCancelled never does anything

desert thistle
#

I'm just getting started with the input system and from what I've read so far, it looks like the only apsect of it that may be lacking is the use of modifier keys.

My main concerns are:

  1. If there is an action bound to a single key press, and then another action bound to the same key but with a modifier key as well, do these bindings still clash during the disambiguation stage?

  2. If I set up a default action binding to a single key press and a user wants to rebind it to a key + modifier key, you basically have to determine what the user has chosen and determine the type of action binding you need dynamically right?

Or would you create the default action binding as Button with Two Modifiers and just leave the modifiers unbound?

austere grotto
#

Not sure about the rebinding stuff as I haven't dealt with it yet

desert thistle
#

@austere grotto ok. I wasn't sure if that had been addressed yet. Thank you. I can manage around that.

barren locust
#

I'm trying to get a 2D axis to work with the new input system and it recognizes the input as a press instead of a hold

#

Any ideas?

green forge
#

hi guys, I need some help on how to set up a button that can both be pressed and hold

#

I got the input system all set up but got stuck manipulating it in code

hoary walrus
nova inlet
hoary walrus
nova inlet
hoary walrus
nova inlet
#

share the link

hoary walrus
#

there's no link to share

nova inlet
hoary walrus
mental zenith
#

so just as an FYI, apparently the behaviour ive been trying to work around the last couple of days is a bug:
runtime controller auto reconnect/re-pair to player input wont work if the active control-scheme has a action with no bindings due to an array error.

#

In other words all actions here have to have atleast one blue binding underneath for controller reconnect to work as of now

#

gonna submit a bug report, but figured I would share on the off chance anyone else is stuck on the same problem. I had to dive deep into the input code to find this^^

nova inlet
# hoary walrus https://paste.ee/p/zVGXE

code's alright, there must be a PlayerInput script attach to your cube object, which is intercepting the input events, see if that script is present on other objects as well

nova inlet
devout pike
#

Heya! Anyone know what's going on here? I want the menu system to be 100% usable with keyboard only, but for some reason, it only woks once I click a button with the mouse once, after that it starts working. Why does it do that and is there a way I can make it usable with spacebar from the beginning? Mainly just unity buttons + unity base input system.

hoary walrus
nova inlet
west oracle
#
EventSystem.current.SetSelectedGameObject(target);

You can also use this to forcefully select something when you know input needs to happen.

devout pike
#

Oh damn I fixed it with a way more spaghetti solution... Thank you mate I'll know it for next time!

sweet palm
#

Hi all - struggling with the new input system.

I previously used Input.GetAxis to ease between vector float values, and it worked great for my needs. With the new input system. those values snap (like GetAxisRaw), which is problematic. Using both a keyboard and gamepad.

Any thoughts on how to correct this? Ideally at the point of input, but I'm open to suggestions.

austere grotto
sweet palm
#

Thank you!!

frigid ridge
#

Input system still doesn't have a more native way to deal with this?

austere grotto
#

Not AFAIK

sweet palm
#

You'd think, right?

austere grotto
#

But I haven't checked in a while

sweet palm
#

I can't find a thing

hoary walrus
west oracle
#

@frigid ridge the primary issue w/ recreating the Gravity/Sensitivity thing is that Processors don't have history 😦

frigid ridge
#

Ah yea that was the issue

barren locust
nova inlet
hoary walrus
heady pulsar
#

anyone familiar with XBOX controller input?

austere grotto
weak bramble
#

Hey guys does anyone have a slide controller code? Mine simply doesn't work and I would appreciate to see where I've mistaken.

heady pulsar
#

@austere grotto thanks for the suggestion, but it didn't work. i know the trigger works on the controller since when i play spryo reignited the triggers respond to input

soft vale
#

I'm trying to make a smooth input processor for the new input system, and it won't work

#

I have based my code off the last version of the basic input processor shown in the docs (with [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)])

#

It seems like there's some kind of bug that won't call my processor and this is an issue that's been already reported in the forum by others, does anyone have a new solution?

#

inb4 "smooth the input in game": I want my keyboard 1D axis to emulate a joypad's analog stick

soft vale
#

Ok, seems like the InputProcessor framework is broken, not even the default ones work

honest sapphire
#

hello, when I press a button once, it executes 6 times, does anyone know why it happens.
I am using the Input sistem

desert thistle
#

where exactly would I request Unity to make InputAction.isSingletonAction a public member instead of internal? Its a PR on github the only way?

harsh ridge
#

I’m writing a unit test that needs to simulate moving my player prefab and having a difficult time initiating that input. I have the player and can access the method called to move, but it expects a callback. I can also get the InputAction actions from within the player prefab, but still can’t seem to call the dang things.

  • I’ve tried calling .Enable() and then used the myAction.performed += syntax
  • sending the key as an event
  • passing the actionMap (captured from debug logging the input) as JSON
  • adding a game pad with InputSystem.AddDevice<Gamepad>(); but then I’m not sure how to actually “press” the button

If anyone has any potential directions or thoughts, it would be much appreciated!

sonic basin
#

what does this mean

frigid ridge
#

Input Axis Fall doesn't exist in your input settings

hexed needle
#

hello people , i m new learning unity , and i m very confuse ... how can i use this [SerializeField]
private InputActionReference attackControl; to trigger my animation ? i know its a really noob question but its been several days i ve been trying to figure it out on my own 😟

solar plover
hexed needle
#

@solar plover ive been following a Tutorial , since i am learning C# and unity ... but after the tutorial is done and she didn't apply any animation to her "character" , so i have been trying to modify my code , to implement a connection with the animator so when i move my character ill be able to run the animation , ofc i lack a lot of experience ... but i can't find the same type of code in other tutorials , so have been trying to do it myself ... but i can't make it work. she uses "input system" for the controls and cinemachine for the camera ...

#

this is my code at this point

#

pls let me know if its better to show my animator set up

solar plover
#

I'm not too well versed with the new input system but you ought to simply be able to bind inputs to functions (assuming you've got some already).

#

(For movement and such)

#

This time, you'll simply bind the functions invoking the animations; those manipulating the animator variables.

hexed needle
#

you mean on the input menu , or just create a different script to call the animation through binddings?

solar plover
#

Or better yet: if (movement != Vector2.zero) do animation

#

(movement that is)

#

I'm on mobile so it's difficult for me to multiple task and I'm not proficient with Swype or the mobile input layout.

#

You would call your animator walk function after the if statement in Update

hexed needle
#

its ok @solar plover thank a lot for trying to help , as a noob ill try to figure it out a way of doing that ... that's what iv been tryin to do on the last week...

#

i think i m being to ambitious with this

#

😟

solar plover
#

Shouldn't be too difficult, you've almost got it

#

Hmm you're already calling the animator walk in fixed update. Maybe the expression in the if statement with that function is never true?

hexed needle
#

i m not sure being honest

#

i dont know exactly whats wrong

solar plover
#
isWalking = move.x > 0.1f || move.x < -0.1f || move.z > 0.1f || move.z < 0.1f;
``` would be sufficient without the lambda.
#

If any part of the expression is true it'll be true.

hexed needle
#

this is the error its giving me up front

solar plover
#

Have you setup your animation properly? (a different issue)

#

Ah, an error.

hexed needle
#

for now i only have this

#

2 layers one masked with the other

#

with 2 parameters for the code

#

so i m not sure ...

solar plover
#

You'll have to fix all of your errors before anything can be expected to work correctly.

#

What version of input system are you using?

#

You've got to rid yourself of those errors else Unity will not compile and you'll simply be playing old images of your project.

hexed needle
#

Version 1.0.2

#

inputsystem

#

it seems it does not recognize up front the "PLayerControls"

#

and i dunno why since that's the file created by the input system

#

i was in unity version 2021... i switch to unity 2020.3 and now its a different error ...

#

which i m aware ov ... since i dunno what to call on the function ...

#

error_02

solar plover
# hexed needle error_02

You likely meant to pass in move rather than Vector3
Changing AnimateWalk(Vector3) to AnimateWalk(move) where you should place this call in Update rather than fixed update; update also has your local (to the function) move variable.

#

Or make move a class member and everything else would be fine as is (removing move declaration from update - you'd still want to assign it there though)

hexed needle
#

@solar plover it solved it ... but this script is all messed up ... keeps on giving me a bunch of errors =/

#

anyway thank for trying to help , what you said all worked

#

Thank you ^^

jade wing
#

Wow, there's a whole section for the input system.

#

Is anyone around? I'm trying to figure out what I'm doing wrong with this thing. I can't seem to get it to do anything.

jade wing
#

This code isn't being recognized in the Unity Event system and I'm not sure why

    {
        myInput = value.ReadValue<Vector2>().x;
        myBody.velocity = Vector2.right * myInput * mySpeed;
    }```
narrow cove
#

Has anyone here successfully used the Input System with a custom scheme in visual scripting? No luck for me in 2020 or 2021. Seems like a huge problem to not be able to input controls 😦

bleak hound
#

How can I recreate "Input.GetButtonDown" in the new input system? I've already implemented systems with onClick behaviours but I have difficulties on using controls like holding a key....

bleak hound
#

for now I just switch the state of a boolean to check the mouse behaviour, does exist a simplier way?

delicate burrow
#

Hey guys. So I was writing a system which prints the key that was pressed, and is there a way to get it correctly if the InputAction was set up as anyKey? Currently the context.control.name returns anyKey rather than the key that was actually pressed.

gilded cobalt
delicate burrow
#

yeah. I hate having to set up 26+ chars every time I want to do this

gilded cobalt
#

ah that was what i was gonna suggest

delicate burrow
#

Yeah I'm already doing that. It is really surprising that there's no way to get the exact key pressed's name

gilded cobalt
#

i think you should majke a list of all chars and put those in an in statement( i dont know if it will work, i mainly know python)

#

then print the same var you used

delicate burrow
#

A-Z, 0-9, Tab, Space, etc. is painful to set up multiple times. And it's not even easy to copy the json elements as the guids are unity created, and just modifying 1 character of the guid gives errors

gilded cobalt
#

no i mean just create a list/array, check the key pressed in the array, then print it

delicate burrow
#

I mean this. Currently I have it set up like this. It's annoying. If I have it set up like this, then doing context.control.name works fine.

gilded cobalt
#

hmmmmmm

#

i dont know then, sorry

austere grotto
#

Check out Keyboard.onTextInput

delicate burrow
#

Yeah I did consider that, but I'm using gamepad and other devices as well. Using multiple classes like Keyboard & Gamepad is not really an effective way for writing systems I feel.

austere grotto
delicate burrow
#

No, but I'm writing generic code for both devices together. Consider that I'm writing a rebind key system, with both devices, and I want to use the pressed key's name in the UI. It's really inefficient to write that code for keyboard separately, and the generic code for gamepad separately.

#

And it'd be awesome if we had anyKey, or their equivalent support for other devices too. What do you think?

bleak hound
#

How can I make a simple getKeyDown with the new Input System?

delicate burrow
austere grotto
ember sundial
#

Hi can someone help me with the xr toolkit what does this trackedDeviceDragThresholdMultiplier mean?
Docs:
(Scales the , for tracked devices, to make selection easier.)

ember sundial
#

Thanks 👍

abstract condor
#

Does anyone know why my tilemap 2d collider is off on some of my objects?

#

sorry

bleak hound
#

How can I recreate a GetKey on new input system? I read that I should use something like "Action.readValue<bool>"

#

Seems that the action does contain a bool value but an int, why? .-.

barren locust
abstract condor
#

how can I make it so an object collider is only a trigger, and doesnt actually cause collisions?

#

I have a enemy that is supposed to be able to turn and walk up a wall. I have it so he has a detector... a collider used as a trigger... placed out front of him. When he turns, one of the trigger colliders is in the wall, where it should be, but it pushes the mob out. Even though it is a trigger

austere grotto
abstract condor
#

sorry, struggling to find where to put questions

bleak hound
fluid lotus
#

Does anyone have a good method for manually joining players in a local co op using the PlayerInputManager component provided? I’m manually joining because I’m implementing local co op that can have 2 people on a keyboard along with any numbers of game pads connected as well. Currently I’m just checking in update for keyboard.current.(specific key) and gamepad.current.(specific key), and then instantiating my input components based off of that, and it works, but that just seems super messy. Is there a way to detect if different control schemes are being used in order to join a player? I have 2 keyboard control schemes set up currently and a gamepad control scheme; if I could just trigger an event when input came through that could pass info about what control scheme is being utilized or just detect what control scheme is being used somewhere that seems like it would be a lot cleaner.

frigid ridge
#

There should be an join on input sample in the input system samples

barren locust
bleak hound
#

I found out a similar solution

barren locust
#

Oh okay that's good

bleak hound
#

so "myBool = Actio.ReadValue(int)" and then I switch to true of false if that int is > 0

#

thanks for the help

barren locust
#

No problem lol

bleak hound
#

mouseHold = playerInputActions.Mouse.MouseHold.ReadValue<float>() > 0 ? true : false; //GetKey

#

here is the line if somebody need it

barren locust
#

imo it actually is more readable if you do the ReadValueAsButton func

bleak hound
#

"MouseHold" is just the left mouse click

#

Documentation and topics online are really old and scarse tho

fluid epoch
#

whats the difference between pass through and value?

fluid epoch
#

thanks

deep hinge
#

how come it cant detect the namespace?
using UnityEngine.InputSystem;
The type or namespace name 'InputSystem' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?) [Assembly-CSharp, Assembly-CSharp, Assembly-CSharp, Assembly-CSharp, Assembly-CSharp, Assembly-CSharp, Assembly-CSharp, Assembly-CSharp, Assembly-CSharp, Assembly-CSharp, Assembly-CSharp, Assembly-CSharp, Assembly-CSharp, Assembly-CSharp, Assembly-CSharp, Assembly-CSharp, Assembly-CSharp]
I have the input system package installed. I don't have any assembly definition files in my project. I also regenerated project files.

#

every time i wanna try the new input system, it can't detect the namespace

#

the simple demo won't compile

austere grotto
deep hinge
#

no

#

its a totally fresh project. Just imported the simple demo. Also double checked by searching for assembly def files and nothing came up

#

uninstalling and reinstalling the input system package doesn't help

deep hinge
#

Assets\Samples\Input System\1.0.2\Simple Demo\SimpleController_UsingActionAsset.cs(3,19): error CS0234: The type or namespace name 'InputSystem' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)
any clues?

#

whew for anyone having this issue, for some reason it has to do with the unity VS Code package not being up to date

#

what a pain in the bananas

rose forge
#

Hi everyone, does anyone know how I can unsubscribe a lambda function to an Input action?

player.controls.Character.UseAction.performed += ctx =>
{
    OnUseButton(ctx, player);
};

From what I understand replacing += by -= doesn't work and the player is still subscribed to the lambda afterwards

untold sun
#

You have to save the lambda in a variable before you assign it, then unsubscribe the saved lambda with -=

delicate burrow
outer cave
#

I'm trying to add the playerinput class from the default package to objects at runtime using addcomponent, but they never send the messages they're supposed to. The input debugger shows it's receiving the raw input from the controllers but they just don't send messages to my other scripts. Disabling/Enabling the script in the inspector fixes it, but doing it through a script doesn't (not even when delayed)(the enabled property). What am i doing wrong? (the playerinput properties in the inspector look the exact same before and after disabling/enabling them in the inspector)

#

I'm having the same issue when i manually add playerinput and assign the actions through the editor at runtime

#

I've figured it out, i needed to enable the input action assets after assigning it through .enable() . the ActivateInput method on the playerinput script itself wasn't necessary however

little jolt
#

im trying to add in the konami code into something, im going to store the last 10 inputs pressed by the player and if it matches then the event will happen, is there a method to return a key anytime it's pressed?

#

inputString, nvm

smoky reef
#

Hey,
Im creating a 2D Unity-Game for mobile and want to make a game, in which you touch on your screen to jump on the left wall, and then when you touch after this you will jump from your position to right and so on..
But now is my problem, that i dont know how to make a script for this.
Can anyone help me?

ionic willow
outer cave
#

I have this super simple, tiny script

#

and it throws this massive error in the unity internals

#

it happens when onInput is invoked and disables the inputreceiver script, however OnDisable() runs before the errors are thrown. Also everything seems to work fine regardless

#

I must be doing something incredibly wrong, but I just can't figure out what

tame oracle
#

Beware: Unity is trying to force the New Input System on anyone whos using 2021 by disabling the Input Manager by default, anyone who doesnt want to use it (and I wouldnt blame you) you will have to revert it in the Player settings.

west oracle
#

as long as they don't outright remove the old one heh

tame oracle
#

Hello! I’m Rex Looking for someone that has implemented some sci-fi shooter-like fast paced spaceship controller in 3D 😅 with different types of tilt maneuvers all for a touch based system, preferably one fingered 😂 something like this: https://youtu.be/_-18NFwJPpY I managed to pull that off. But I want more manueveurs kinda like space fox 🦊 ughh no relation 😅😬 I mean star fox ⭐️ 🦊 something fast paced and “shooty”. The game is multiplayer so singletons are bad guess, because I don’t know how to use them in a multiplayer game 😭 yet. Pls msg for more informative info stuff. 🥲

west oracle
#

ermm, that wasn't really on point for this channel. probably better off looking at the Collaborative part of the Unity forums.

tame oracle
#

We’d better touch controls for inity stuff 🥔😂

#

😁😅

#

I ❤️ unity

sullen kestrel
#

currently, trying to make the initial struct, but have some issues

#

so far, all i have is this: ```cpp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

[StructLayout(LayoutKind.Explicit, Size = 4)]
public struct fsi6InputReport : IInputStateTypeInfo
{

}

west oracle
sullen kestrel
#

thx!

#

that helps solve some of the issues, but IInputStateTypeInfo is still not defined

grand crow
#

Is there a way to enable/disable one of the events during runtime? For example, I have private void DoSomething(InputAction.CallbackContext ctx) in my script and it is assigned to the event in the input system component. But I want to completely disable this so the DoSomething button doesn't trigger it any more. But also be able to restore it at some point.

delicate burrow
#

You can unsubscribe it.
Inputaction.performed -= DoSomething;

safe tangle
#

Currently I have my movement using getaxis. But when I use controller it seems to use getaxisraw. Is there a workaround to this?

proper meteor
#

How do you properly destroy a component using input system, it keep receiving my input

frigid ridge
#

Are you calling Disable(); ?

proper meteor
#

I found the solution

sullen kestrel
#

but when i try to using UnityEngine.Experimental.Input; i get a error, as the input part of the namespace doesnt exist

#

nvm i got it

#

what am i doing wrong? im just trying to copy whats in the documentation

austere grotto
sullen kestrel
#

"The type or namespace name 'type/namespace' could not be found (are you missing a using directive or an assembly reference?)"

#

so i assume im missing another Using

#

but the docs doesnt supply any information on what to include

sullen kestrel
#

thanks

sullen kestrel
#

yeah, no clue what im missing... ive tried looking online, but cant figure out what im doing wrong

sullen kestrel
#

ay i got it

grand crow
austere grotto
austere grotto
sullen kestrel
#

confused, in another project, the amount of inputs that i can see for my controller in the input debugger is alot more than in my current project where i am trying to get input

#

and, in my current project, the x and y axis for the stick are the same, but different in another project

unkempt trail
#

Hey guys, I'm working on an asset for the unity asset store. It relies on input a decent amount.So far I have built everything using the new input system and it has been really streamlined, especially when adding local multiplayer. I have tested an intermediate layer to support the old input system as well, but it makes the code more complicated than it needs to be.

Do you think its ok to release an asset that requires the new input system or do enough people still prefer the old input to make it worth supporting both?

cedar drift
#

Not sure what this error is about, not sure where to even looks. Any ideas?

MissingMethodException: UnityEngine.EventSystems.EventTrigger.OnCancel Due to: Attempted to access a missing member.
System.RuntimeType.InvokeMember (System.String name, System.Reflection.BindingFlags bindingFlags, System.Reflection.Binder binder, System.Object target, System.Object[] providedArgs, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParams) (at <695d1cc93cca45069c528c15c9fdd749>:0)
UnityEngine.SetupCoroutine.InvokeMember (System.Object behaviour, System.String name, System.Object variable) (at <c7864a0eaeb24b2a999fb177623d54b4>:0)
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)

austere grotto
#

For example it's referencing a method that no longer exists or has the wrong arguments

cedar drift
late ember
#

Just an FYI if anyone has tried unsuccessfully to get Virpil Flight sticks working, the problem is that the device descriptor includes / characters which messes with Unity's path parser and will be fixed by a Virpil software update:

#

seems like a bug though to not be escaping device descriptors in the input system

late ember
echo crag
#

Hello, i have a question.

I've download the package input System 1.0.2 sometime after i've downloaded Cinemachine and configure my camera.
I've created some input action and now i'm facing this :

InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.
Cinemachine.AxisState.Update (System.Single deltaTime) (at

austere grotto
#

tl:dr attach a "CinemachineInputProvider" component to your FreeLook, POV, or OrbitalTransposer camera

#

and set up the axis -> InputAction you want

echo crag
#

I'll try that thank you.

echo crag
high crystal
#

I've decided to add some UI elements to my project, but most elements are not responding. Sliders/Toggles do not work, but the InputField does. I assumed maybe some Input Manager definitions were missing, but I've tried adding some back in (Fire1, Fire2, Fire3) but this does not help. I'm not sure if these definitions are even required for UI to work, or if my problem could be located somewhere else. I have tested in another project where it works with no issues. Any tips?

austere grotto
high crystal
#

how would I examine the component, you mean just look at it in the editor? it looks normal 🙂

austere grotto
#

The other thing to look at is have the EventSystem selected as you play. It will show a preview window under the inspector with info about what UI elements you're hovering over etc

high crystal
#

oh interesting

austere grotto
#

That can help detect objects over other objects etc

austere grotto
#

Make sure they're populated and correct

high crystal
#

horizontal, vertical, submit and cancel all look correct

#

not sure what Pointer:-1 means in the eventsystem

#

pointerEnter seems to show the correct gameobject

#

could multiple canvases interfere with each-other?

#

that was the problem. damn. thanks for your help, was stuck in a loop. I had to turn off the graphic raycaster for 3 canvases I only use to display some text.

haughty parcel
#

Hey everyone.
Is there a way to handle precision in the new unity input system? My Right stick/ right feels like it must just be exact right before it’s performed

austere grotto
#

and what's the desired behavior

haughty parcel
#

Action type of Action is button

Binding is.
Right stick/right

Interactions
Tap max 0.1
Press point 0.1

That’s all

The desired behavior is to play an animation

#

Thanks for responding @austere grotto

austere grotto
#

is this for clicking the stick in?

#

Or tilting the joystick

haughty parcel
#

Not really, I just want it to play an animation without being so exact. It’s tilting

#

@austere grotto

austere grotto
#

maybe make it a Value instead of a Button

#

Value -> Vector2

#

you should get performed very early on in the tilting

haughty parcel
#

I will check that out now. Thanks 😊

#

@austere grotto

frank lion
#

Who knows, how to add force (rigidbody) to the object in local coordinates using joystick for mobile?

austere grotto
#
Quaternion currentRotation = rb.rotation;
float moveRotationX = ...
float moveRotationX = ...
Vector3 moveDir = new Vector3(moveRotationX, 0, moveRotationZ);
Vector3 worldDir = currentRotation * inputDir;
rb.AddForce(worldDir);
frank lion
#

Thanks

lavish swan
#

hi i am new on unity and i wanna do something. i have a sphere and i can rotate this with a/d but i can't move this vertical how to do it? i wanna move this to facing rotation.

cedar drift
cedar drift
lavish swan
#

thanks

loud patrol
#

Hey everyone, I have an issue with the new Input System and my UI, I can't seem to capture Mouse input in the UI of my game's main scene but my gamepad works just fine. In the main menu both devices (Mouse & Gamepad) work fine, but inside, even though I can move the player with both the mouse and the gamepad, I can only get UI input via the gamepad. Below are my Event System and my player's Player Input component. I'm baffled by this and since the new Input system is fairly new I can't find anything online, so any help is appreciated.

austere grotto
loud patrol
#

I guess that's possible, but my Camera does not have a physics raycaster (so that won't block the graphics raycaster) and my graphics rayster is the default from the canvas. Any way I could check if the cause is a blocked raycast? FYI, here is the raycaster in my canvas

austere grotto
#

Yes you can debug it by doing a raycastall on your EventSystem and printing out all the results

#

I have a code snippet for it but I'm on mobile ATM

loud patrol
#

Ok, I'm using this snippet to check for raycast hits and I'm getting hits on most of the UI elements (not all though, but maybe that's something to do with the pointer data). However, still no elements are clickable in my UI

timber robin
#

@tight horizon No crossposting.

tight horizon
#

Yep didn't know where it should go

#

sorry

timber robin
#

Anyway, I posted a doc link in the channel, hopefully that helps.

bright plinth
#

how do i get axis value from a joystick x axis

rustic plume
#

Input.GetAxis("name of axis")

#

you can find the axis name in the input manager

#

probably "Joystick X" but i'm not entirely sure

tough imp
#

Does anyone here know how to make a car enter and exit system?

neon dawn
#

Anybody know how to rebind different controls at runtime? (New input system)
I'm trying to allow players to change their keybinds but dont really know where to start, unity's docs arent that helpful either
any tips are welcome!

eternal tulip
#

I have problems reading the scrollwheel. I can't set a new input event for the scroll event nor is reading Mouse.current.scroll consistent, it only fires occasionally

#

any idea why I can't select scroll or something as an input action?

#

nvm... I overlooked that the action's action value as axis does not work and I tried vector2 and now I can see the scroll event...

odd path
#

If I'm going to have a in-game cursor for my game terrain, that needs to move when the mouse moves over the game BOARD, what is the best way to achieve this with the new unity input system?

#

its just a cursor that moves with the mouse when the mouse moves over the game board.

odd path
#

Sometimes unity makes me want to blow my brains out with this shit. takes 20 hours to figure out how to detect when a mouse is over a game object or not.

eternal tulip
#

How do I configure my Move action to go back to 0,0 when I release the buttons?

#

pass through.....

unborn garnet
#

im assuming this will fix it if you're using Input.GetKey

eternal tulip
#

yea no. @unborn garnet

#

Input is disabled

#

and no, I will not enable both systems.

#

but I found it myself: pass through is what I need. it will also invoke the callback while the value goes back to zero

frigid ridge
#

@tame oracle If you think about it, the tutorial most likely just needs 2 floats that represent horizontal and vertical input, you can get both with the new input system.

neon needle
#

how do i print out to the console whatever button is being pressed on the gamepad?

shut berry
#

I'm having a problem spawning player prefabs they can only spawn with no action inputs configurations on them

#

if I have no input set up file in the player it spawns out but you cannot control it

austere grotto
#

"rezzing"?

shut berry
#

oops spawning I meant I will adjust the question

shut berry
#

I think I fixed it

#

had to remove control scheme

#

I should set it manauly

rapid saddle
#

Simple question:

I have my input system set to Unity Events....When I do a simple Debug.Log on a button press, I'm getting 3 events...wtf?

#

Script is only attached to one object...Only one player input component

austere grotto
#

Started
Performed
Cancelled

#

You can read value.phase in your function to see which phase it is

rapid saddle
#

Ok that makes sense. Should I just not go with this method style and just subscribe to the event instead?

austere grotto
#

If you're only interested in a single phase it may make sense to only subscribe to that single phase's event

#

It's really up to you

rapid saddle
#

I guess I can do both right

austere grotto
#

I generally prefer not to use PlayerInput because it makes this stuff a bit confusing

rapid saddle
#

What are you considering "PlayerInput" ?

austere grotto
#

The PlayerInput component

rapid saddle
#

So you rather just do everything through code

#

Subscribe to events and all that

austere grotto
#

Yes

rapid saddle
#

Got it

austere grotto
#

That's my personal preference though

#

Do whatever you're comfortable with

rapid saddle
#

My issue is the documentation, it's quite confusing

tawdry folio
#

sprinkle a few insights from the documentation code snippets on top of that and voila.

fervent gorge
#

Currently my code skips over 2 and 3 how would I make it wait?

#

I'm going to move this to general code because I think its a problem with my int not my input

digital bronze
#

So I'm having some problems with getting keyboard input to work in unity, is this the right place to post about that?

mossy crest
timid cargo
#

How do i enable visual studio autocorrect?

ancient berry
#

Anyone here use Rewired? Is there documentation and/or video tutorials available?

tight horizon
#

Someone could help me for a line of code that would get my XR controller in the script ?

#

I did this for now but it return null

#

RightController = GameObject.Find("RightController").GetComponent<XRController>();

tight horizon
#

I found the answer if someone is interested

#

You have to use private InputDevice controller and then use the command GetDevicesWithRole

#

Tell me in private if needed more information

glossy granite
#

should you read value of button in the new input system as float? What is the difference between value double and button?

#

for the action types/control types

static walrus
glossy granite
#

This doesnt really tell me the difference

#

I just want to know if I should read the value of a button as a float

west oracle
#

@glossy granite most everything is a float unless its a Vector in InputSystem

glossy granite
#

Gotcha. So if it's a button, you should read the value as a float and the float will be 0 or 1, if it's a value and double, it should be read as a float as well? Why is float not in the list of values?

west oracle
#

"Analog" is "Float"

#

basically though Actions are generic value containers, whether its a Button, Stick, etc, are just useful ways to help with stuff like rebinding or selecting viable inputs

#

(and to help with code generation)

#

also worth mentioning that you don't have to use actions, you can read from devices directly.

#

if its a digital On Off Button just set it as Button

#

its fine to read it as a float, yea

#

if you mark it as a Button and use the Generate C# Class checkbox, it'll be more useful though

glossy granite
#

Yeah okay. It made sense to do that

west oracle
#

if you are using another method for dealing w/ input its less important

glossy granite
#

I did mark it as a button, but I read it's value as a float

west oracle
#

thats fine, it'll typically just give you 0 and 1 if its mapped to a physical on off button on a gamepad

#

a use case where it would be would be a Pressure Sensitive button like a Trigger

#

you could have 2 actions listen to the same trigger, one with a "Trigger Point" at 90%, adn the other constantly.

#

the Button listening to the trigger value would still actually report a 0.9 value, but would also use the "Performed" event or phase

#

there's an extension method for treating it more like a button, yea

glossy granite
#

How do I use that?

west oracle
#

Part 5 for you.

#

can write your own here to understand it better heh

#

but the 1.2 preview package has a similar method baked in

#

Value -> Analog or Axis is acceptable

#

again they really just come down to "if the user pressed the Rebind Control button, which options should we give them?"

#

the float values wouldn't change, no

#

but for example if you set Value -> Stick

#

and said "Rebind MoveAction" (where MoveAction is Value->Stick)

#

it would only return you a list of controls to choose from that matched "Stick"

glossy granite
#

I'll figure it out and toy with it. Thanks for the help!

#

Do you require any attribution for this help @west oracle ?

west oracle
#

nope! 🙂

glossy granite
#

Thanks for the guidance!

#

So overall, no attribution is needed, correct @west oracle?

west oracle
#

none

glossy granite
#

I apologize for my confusion, I just wanted to clarify I was making the correct assumption based on your answer @west oracle thanks again!

west oracle
#

lol, no need for attribution.

glossy granite
#

Cool thanks! @west oracle

glossy granite
#

@west oracle how long have you been using unity?

west oracle
#

mm... long time 🙂

glossy granite
#

Cool cool. I love it and thanks again for all your help and clarification that you do not require attribution! @west oracle

west oracle
#

since ... 2009? something like that.

glossy granite
#

Thanks again for clarifying earlier that you do not require attribution. Sorry for getting confused. @west oracle

#

I really appreciate it! @west oracle

#

I'm really loving the new input system

trail wren
#

so I have a character controller script, and previously I was just getting all my input in Update() and then giving it to that controller, now with the new input system, everything being event-based, should I change all my logic so that I have single line functions directly updating variables in the character controller and cut out my middleman script of gathering and parsing the input? seems like tons of extra lines of code, especially for a dozen+ actions

austere grotto
#

it supports polling just the same

trail wren
#

is there a best way to use input actions without doing event-based?

austere grotto
#

You get references to the Input actions (there's several ways to do this), and then you just read their value each frame

trail wren
#

I'd like to have access to wasPressedThisFrame and such, but all I have is ReadValue

austere grotto
proper dome
#

anyone know any tutorial of info about change the bindings at runtime for the new input system? like to make a option menu?

proper dome
trail wren
radiant shard
#

where i get to know about it

 playerControls.PlayerMovement.Movement.performed += i => movementInput = i.ReadValue<Vector2>();
wise venture
#

can anyone help me understand why in the tanks demo (using the new input system) both tanks move with the same input? i tried adding input binding for keyboard as well since the project only offers binding for gamepad and when i run the game, gamepad controls one tank and the keyboard controls both of them, or vice versa

karmic igloo
whole geyser
#

So I'm working with someone else's code, building out a level. They have a player input script that uses the event system. The player presses a button, and then it calls to an event.
I'm pretty unfamiliar with this, and need some pointers on getting this to work. I have an object I want to destroy as the event, but if I drag my object with the destroy script onto that input trigger, I can't call the functions in the drop down.
I'd appreciate the assist.
Edit: LOL, the functions weren't public. Derp.

grand crow
#

What's the cost/benefit of putting an input script on multiple objects (for example, the player character and the main ui canvas) vs a public reference in a static class somwhere easy to access?

austere grotto
grand crow
#

typo, putting

#

Right now I have my input system stuff on a singleton and I'm wondering if that is going to bite me in the ass later.

austere grotto
#

the cost is that your code is a little more complex and you have a singleton to manage

slow crest
#

how do i Add/Remove InputActions during runtime to switch them out?

austere grotto
slow crest
#

yeah so i have a cinemachine input provider XY axis input action.. i figured out how to remove it during runtime. but i can't figure out how to reasign it in runtime

austere grotto
#

or do a rebind if that's what you're going for

#

AddAction and RemoveAction

slow crest
#

i'lll check it out. thanks!

austere grotto
#

they're extension methods on InputActionAsset

slow crest
#

i can't seem to understand it

#

cameraInputProvider.XYAxis = null; this works in the if statement

#

but how do i assign it after pressing a button?

#

i have a referance to the InputAction in my script but i don't know how to assign it in the else statement

#

i'm new to cinemachine and the new input system. so sorry if i seem really stupid. :/

austere grotto
#

I'm not really understanding why you're trying to add or remove input actions

#

Why don't you just enable/disable them?

fading berry
#

Can someone help me understand touch inputs (android)? Mainly what I want to learn is

  1. swipe action
  2. touch to move in 3D world
  3. double tap to action
solar kite
#

What is an ideal way to handle input? Should I have a InputManager script in the scene, should I have PlayerInput component on the character? Should I just recieve input in the PlayerController for my rb character?

frigid ridge
#

I prefer separating input collection from consuming input. In a lot of games the AI and Player can share most of the components if you separate small number of details from those components

#

It can also enable some interesting automated testing setups

solar kite
#

Does consuming input mean that the PlayerController would be the one handling input on the character?
myControls.gameplay.look.performed += context => look = context.ReadValue<Vector2>();

input collection would mean there's a separate object or script collecting the input(such as the PlayerInput script for the new input system) that then sends that data to the character?
myControls.gameplay.look.performed += context => player.look(context.ReadValue<Vector2>());

frigid ridge
#

Yea I generally dump all the input into a struct and pass it to anyone who registers for it. I think it's less important how you do it, just doing it in some way enables the things I mentioned.

#

The included player component probably fulfils that requirement, assuming you can replicate the data on your AI

timber robin
spice orbit
timber robin
spice orbit
#

Ok

#

Soz

timber robin
#

By the way, if you're looking to pay someone, you can use the official Unity forums for job postings.

whole geyser
#

So I have a really odd bug, and I'm not even sure where to look. I was given a project to build a level, and it has an input trigger script that uses the Unity Events system. You drag the object with the script you want to call onto the input trigger, and it should in theory work. Well, the bool that checks if the player is in the proximity area is completely ignored, and I can click the input button anywhere to invoke the event. I had my CS colleague look at the script, everything seems in order, in theory. Is there something in Unity's Event system that I should be checking or using?

fluid glacier
#

What's the best way to detect a button release with the new input system?

timber robin
#

Listen to the .cancelled action on the input.

fluid glacier
#

Thanks, I'll try that

#

That's exactly what I needed, thanks man!

solar kite
#

If I'm doing a multiplayer game local or networked will making InputManager a singleton not work out?

austere grotto
#

as long as you make it only control the local player's character

solar kite
#

Okay I was a little worried that making it a Singleton would mean only the first player will have access to the input manager

austere grotto
solar kite
#

My own using the new Input System

austere grotto
#

If it's your own thing... then whether it's compatible with local multiplayer is up to you

vernal iron
#

Are the input actions called each frame?

frigid ridge
#

@solar kite Implementing the concrete input handling as a singleton is probably not a good idea for local multiplayer

#

You probably don't need to reinvent input management with the input system's action components, but if you do, you can have a singleton that you use to connect/spawn multiple input instances.

gloomy night
#

My joystick works fine on my pc, but when I play the game on my phone it stops working when i reload scene (from another scene). Also noticed it crashes going back to the other scene. I feel like I have to manually destroy the player input before loading a new scene, maybe?

#

unless my phone is ancient

#

or maybe i need to only have one player input for the entire game instead of for each scene

frigid ridge
#

On screen joystick? One simple thing to check is whether the UI itself got screwed up

#

Does the joystick UI element appear to respond?

gloomy night
#

yes

#

it responds but player does not move

true pilot
#

hi! I am trying to setup my ps4 controller with the new input system, but Unity is recognizing it in a very weird manner... I've played Death Stranding with it so I suspect it's not a hardware or driver problem... here is what happens, first, the North button doesn't recognize the triangle button in my ps4, instead, I had to configure it with the Listen Button, and it got registered as Button 4 [HID::54C-5C4

#

but now I am trying to configure the Right Stick, and the Listen button won't catch anything... I've read here that I can type the name of the stick and it will work (and it does) https://forum.unity.com/threads/solved-new-input-system-not-listening-to-right-thumb-stick.872863/

#

but it seems like a very hacky way of doing it, and I feel like it's going to fail whenever someone tries to play my game with the ps4 controller... maybe I am doing something wrong?

#

I've already tried this option and Unity still doesn't recognize it :S

#

(I don't know if this matters, but I am using Unity v2020.2.4f1)

#

(just in case anyone needs it, this is the hacky way to make PS4's right stick work as intended, don't forget to set the mode to Analog to receive doubles instead of integers input, the Right binding alone feeds the positive and negative X axis so the Left axis doesn't need to be set)

iron estuary
#

So I imported an input system and I decided to back out and save it for the next game I make because it wasn’t working and now no inputs work because I switched to the new input system so how do I switch back

true pilot
iron estuary
#

Yeah it’s gone

#

But now no inputs are there because the system switched and I want to switch it back

delicate burrow
#

Did you switch it back in the player settings?

iron estuary
#

Where is that

delicate burrow
#

And see if you have any errors. I noticed errors by having created a canvas, and the eventsystem gameobject was using the old InputManager's eventsystem

delicate burrow
iron estuary
#

Thank you thank you so much

#

It’s good now

delicate burrow
#

Welcome

gentle mango
#

ive set up the input system added the player input to my component and linked my move function to it but it docent work what did i do wrong

#

if i do invoke unity events and link a function it docent work but if i just use send message and link a function it dose

austere grotto
#

🤔 that should work

gentle mango
#

some one on another server said maybe linux bug but then why would send message work

austere grotto
#

Any chance you have any compile errors?

vestal crane
#

is there any way to make inputs consistent through scene reloads? for me it just seems to randomly think you arent holding anything, but sometimes it works fine

gentle mango
#

I just switched to send message since it works

potent iris
#

Hi...In a real, large-ish project (not just prototype), what would be the best way to implement switching between game modes? Moving the character, pausing it and swith to "UI mode" etc. At the moment I'm thinking of disabling/enabling action maps. Maybe there's a suitable pattern that fits such a scenario instead of a singleton to handle these changes? Thanks :)

austere grotto
#

And the InputActionAsset is basically a singleton scriptableObject that you get for free

#

assuming you structure your project to reuse a single InputActionAsset

potent iris
#

Would there be any advantage to splitting them?

austere grotto
#

that's one reason I prefer to use things like
InputActionReference in my code instead of the generated C# code or other options

potent iris
#

At the moment they are all in 1 input asset

austere grotto
#

I don't see what advantage there would be unless you wanted to enable/disable entire assets at a time

potent iris
#

Yeah that was my thought too. Ok so basically just an inputmanager which disables actionmaps according to if it's in game, Ui etc..

#

It's quite annoying switching from game to UI as you'd have to send a button selection to the event system for it to work (like that first "click") and it doesn't always work.

lofty spear
#

Guys, not sure if this is the right chat, but does anyone know how do I set up controller navigation on a scrolling list? I've managed to navigate my buttons, but I wanted the list to scroll down too

gentle mango
#

for the player input component which is better send message or invoke unity events

uncut cave
#

In new input system, Should I change control scheme from code? Where could I see which control schemes user using?

#

In unity player input component, you can choose what input scheme should user be using.

vagrant raptor
#

Hi all. I'm having some basic problems when using the Input system (v1.0.2). I want to have two different actions to happen; one for when L1+Square is pressed and another action when only Square is pressed (for instance). However, it seems like always when I use the combo L1+Square the action for (only) Square is also triggered.

How can I avoid this?

L1+Square is set up to use a "Button with one modifier".

I have also tried for the "Square only" action to use "Button with one modifier" where L1 is modifier, but inverted so that it should trigger whenever it's not pressed.

Am I thinking all wrong here?

austere grotto
#

Instead of using the Button with modifier feature.

distant latch
#

got a question is event system needed for a button input?
also why do some people create buttons using image instead of just creating UI button?

austere grotto
#

Yes event system is needed for UI buttons

#

As for the image thing, wdym? The button always needs some kind of graphical element but it can be whatever you prefer

#

the default button is an image and some text together

distant latch
#

since i was looking up on how to create a button for unity on youtube but like i saw some people use te ui to create a button while some created an image and the added on

#

then*

austere grotto
# distant latch then*

The default UI -> Button thing just creates some things automatically - the image, the text, and the button. But you can manually do any or all of that yourself too

distant latch
#

i see, thank you

solar kite
#

When using the PlayerInput component when are the input events called in relation to Update LateUpdate?

frigid ridge
vestal crane
#

is there any way to make holding inputs consistent through scene reloads? For me it just seems to randomly think you aren't holding anything, but occasionally it does.

tame oracle
#

how do i stop cinemachine freelook from rotating with mouse move using CinemachineInputProvider with a Vector2 Input system action

#

i want to make it so it only rotates when i hold down the right mouse button

austere grotto
#

Or disable the InputAction when you don't want it to work

sharp geode
#

if i have multiple users and their associated devices, what steps do i need to take to make the Input System UI Input Module to correctly send event system events from those user's devices?

#

input debugger correctly indicates that the second user's mouse and keyboard send events

#

i think setting a device as "current" might ahve something to do with it, but it would appear i shouldn't have ot do that

#

is perhaps user.AssociateActionsWithUser(); significant?

west oracle
sharp geode
#

it didn't change anything

#

the multiplayer event system

sharp geode
west oracle
#

sorry lemme read ur Q more lol

sharp geode
#

i'm debugging, and for some reason, pointerPress of the event data is null?

#

why would that be

#

it otherwise correctly reaches event system's enumerator

#

of event handlers

tame oracle
sharp geode
#

nevermind

#

i figured it out

tame oracle
#

and how do i disable/enable a specific action inside the inputaction asset?

#

in code*

#

Even calling this
mainControls.ThirdPerson.CameraLook.Disable();does not work

#

Even this fails


        [SerializeField] CinemachineInputProvider cinput;
        cinput.XYAxis.ToInputAction().Disable();```
#

this works

[SerializeField] InputActionReference cinputrefxy;
...
cinputrefxy = cinput.XYAxis;
...
cinput.XYAxis = null;
...
cinput.XYAxis = cinputrefxy;
tame oracle
#

wait how do i make it so i have it as "pressed" like wasd keys

#

it only triggers performed once

#

until i let go and press the key again

#

ok guess i have to store last state and use that and update once keys pressed/released

timber robin
#

Yep

somber fern
#

Hey guys!

I just updated my project to Unity 2021.1.7f yesterday and I'm having this really strange behaviour happening: I'm using Input.GetKey(xxx) to move around in a 2D platformer, and for some reason since the upgrade yesterday, some keys remained in the "pressed state" even after I lift my fingers of the keyboard (I have tried different keyboards, so not a hardware issue here). It works for 5 seconds, then some weird input thing happens, then it works for 3 seconds, etc. It feel all very unresponsive and i'm too baffled as I've never experienced this issue before.

I've put debuglogs in the update after if(Input.GetKey(KeyCode.A)) for example and the debug still triggers constantly after I've removed my fingers from the keyboard, so it gets called in the update even though im not inputting anything. Anybody as an Idea of what is happening here?

I did export my build and the issue disappears, it's only doing it inside the editor.

#

I've copied the build and reverted it into a 2019.4.23f and it works fine again, so it deff has to do with the Unity version upgrade. I'm on Mac OSX Catalina 10.15.4

gentle mango
#

how do i check if one of my input actions is being pressed in the update function

sharp geode
austere grotto
#

something like that usually

cursive tulip
#

I loaded a sample scene from the input system package manager. But if I add a own additional setting like the Controller Dpad, why does it not also work like the left Stick, if I placed it in the already made "move" action ?
here the code of it by the way (I did not touched it, but it was in the sample demo and I think it should also detect the COntroller DPad that I added if it is also in the "move" action....): https://paste.myst.rs/a02crqxc

crystal meadow
#

Is there a way to suppress the Assert "Screen position out of view frustum"?
We're trying to implement a continuous scale zoom from our solar system to our local cluster and we keep getting error messages from

UnityEngine.SendMouseEvents:DoSendMouseEvents (int)
and
UnityEngine.EventSystems.EventSystem:Update ()
(along with anything that calls UnityEngine.Camera:ScreenToWorldPoint) ?

(Our input seems to be working just fine otherwise)

acoustic ether
#

hey guys trying to figure out why this error is coming up

#

just imported the platforms package in order to use crossplatform input

acoustic ether
#

still getting it

austere grotto
#

Like a clipping plane distance of 0 for example

crystal meadow
#

well the numbers(position, zrange) are definitely a bit crazy, but the rendering and input are basically working fine, but the fact that we can't supress the asserts is somewhat annoying

vagrant raptor
#

@austere grotto Thanks for you answer. I will look into that 🙂

slate jetty
#

How to detect mouse input with unity new input system as OnMouseDown() {} no longer works ?
I'd like to know if there are similar callback events like for Enhanced Touch :

UnityEngine.InputSystem.EnhancedTouch.Touch.onFingerDown += this.TouchDown;

In the migration guide they mention replacing this with Mouse.current.leftButton.isPressed. Can I do something like

UnityEngine.InputSystem.Mouse.current.leftButton.isPressed += this.TouchDown;
``` ?
wispy jasper
tame oracle
slate jetty
tame oracle
austere grotto
#

You could also look at IPointerDownHandler

#

Just make sure you're using the correct Input Module for the input system you're using

amber finch
#

hello, I have some problems with adding vibration to my Switch Pro Controller in my game. I use the new input system and Gamepad.SetMotorSpeed doeen't work at all. Any help please?

austere grotto
amber finch
#

aww that's too bad

#

btw when I do the "Check for button" thing it recognizes Switch Pro Controller bht also a gamepad

#

what should I choose?

fluid pine
#

What's the recommended way to replicate the old Input.GetMouseButton() behavior? I want to call a method every single frame that the left mouse button is held down, not just on the first frame the input is registered.

deft burrow
solar kite
#

When using Cinemachine's Input Provider is it possible to stop it from taking input such as for when a UI menu is open

leaden edge
#

Does anyone know if its possible to make cinemachine only move on right mouse click drag?

#

Like you would see in many mmo games

austere grotto
amber finch
#

hey does someone know a solution to my problem?

cursive tulip
#

Why does WASD work in the new Input system, but my Gamepad not? (My Gamepad is successfully connected because I proofed this)

rancid fractal
#

hi, i'm very new to Unity and i want to implement touch controls. What i want to do is that if i type twice, it will be recognized. But I really don’t know how to do that.. I hope someone can help

static walrus
#

@cursive tulip you have like 1k errors just disabled, maybe show/check out what they say

signal tendon
#

The documentation is really confusing

cursive tulip
static walrus
#

i'm not sure how but for me everything works out of the box. the only thing is that iirc i didn't need to pick between kb/m or gamepad, i just added input for both

#

i suspect that you need to somehow switch between kb/m and gamepad if you separate them like that

cursive tulip
static walrus
#

can you check the sample projects? i pretty much started off one and it works great

cursive tulip
#

But If I try e.g. to add a additional binding inside of the action input, my modification will not apply and get ignored by the game.

static walrus
#

yeah it took a while for me to get what was going on, but it got really simple really fast

#

not sure how switching works though (as i said, i just added controller stuff the same way as buttons and it somehow just worked and i never asked questions)

cursive tulip
static walrus
#

what about sample project? and is it just the stick or other buttons too?
also, you're calling a method called Player(Asomething) but in the actual script you're just reading value, so i don't really get how it works in the first place

#

what does that thing actually do?

#

also wasn't the stick just 1 "key", and not up/down/left/right? basically i'll check tomorrow

cursive tulip
cursive tulip
#

@static walrus OK I reworked my code to a brackeys tutorial but now, not even WASD is anymore showing up in the console.... But I got now a new Error what says's thats the object reference is not set to an insteand of my "OnDisable" and "Awake" function:

    public InputMaster controls;
    private void Awake()
    {
        controls.Player.Movement.performed += context => NewInSy_WASD(context.ReadValue<Vector2>());
    }
    private void OnEnable()
    {
        controls.Enable();
    }
    private void OnDisable()
    {
        controls.Disable();
    }

    private Vector2 _wasd;
    public void NewInSy_WASD(Vector2 direction)
    {
        Debug.Log("Movement =" + direction);
    }
static walrus
#

that's brackeys in general

cursive tulip
#

if the video starts you can direct pause it

#

@static walrus

static walrus
#

uhhh... but.. why

#

i do it all through script by just creating new inputActions

cursive tulip
#

this was like I made it before

#

why should this better?

#

I use the new input system because I got 8 things to support like 4 different VR plattforms, 3 different gamepads and of course the default keyboard and mouse. Consider that I really have a lot of Devices to support in the same game

#

@static walrus

static walrus
crimson jacinth
#

Does anybody know how I can get Input.GetAxis("Mouse X") with the new Input System?

crimson jacinth
gentle mango
#

how can i tell if my input was pressed and not if it was released ive tried this
var currentValue = context.ReadValue<float>();
if(currentValue != 0f)
but it still will trigger when my key is released

static walrus
#

you're not really supposed check if it's still being held, you detect change. when you subscribe to event (Jump.started += ctx => whatToDo();), you can see when Jump.started and when Jump.performed

#

and if you really need a bool that's also where you set it to true(.started)/false(.performed)

gentle mango
#

so would this work if(context.ReadValue<float>()>0)

#

cuz it still triggers when i release the key

austere grotto
#

New input system supports both polling and events

austere grotto
gentle mango
#

im gonna do that now

austere grotto
#

or - are you trying to detect when it's first pressed?

#

if so - I do recommend using the events

static walrus
#

returns 0 or 1(pressed)

#

which makes it stranger that it's not just a bool

gentle mango
#

exectly like why cant it be a bool make it so much simpler

static walrus
#

you can try to ReadValue<bool> but at 0 it'll return false, and at 1 it returns error (but since it's not false it somehow just works)

austere grotto
#

if you want to do things the "old fashioned way" you can

#

e.g.:
Input.GetKey(KeyCode.S) => Keyboard.current[Key.S].isPressed

static walrus
austere grotto
#

Input.GetKeyDown(KeyCode.S) => Keyboard.current[Key.S].wasPressedThisFrame

static walrus
#

the old fashioned way kinda makes the entire NIS pointless though

austere grotto
#

Input.GetKeyDown(KeyCode.S) => Keyboard.current[Key.S].wasReleasedThisFrame

austere grotto
#

but it's there 😄

static walrus
#

was really mad when brackeys actually did a video on that

austere grotto
#

did he?

static walrus
#

yep, he didn't even cover other methods in that video

austere grotto
#

I mean it's good in a pinch to quickly upgrade an old project into NIS

static walrus
#

true that

austere grotto
#

but wouldn't really use it otherwise

static walrus
#

but like, i just tried to explain in pm the difference

#

old system:
"is it being held? yes? do thing"
"is it being held? yes? do thing"
"is it being held? yes? do thing"
"is it being held? yes? do thing"
"is it being held? no? don't do thing"
"is it being held? no? don't do thing"
"is it being held? no? don't do thing"
"is it being held? no? don't do thing"

new system:
action.started
"do thing
do thing
do thing
do thing"
action.performed

that's it.

#

if unity would pin that shit it'd probably make more sense to everyone why NIS exists

gentle mango
#

ok this is the code ui have for a crouch functin but the input still triggers when i release the key

#

when i crouch it triggers twice

austere grotto
#
bool isPressed = false;

public void Crouch(IAC context) {
  bool pressedThisFrame = context.ReadValue<float>() != 0;
  if (pressedThisFrame && !isPressed) {
    Debug.Log("Pressed!");
  }

  else if (isPressed && !pressedThisFrame) {
    Debug.Log("Released!");
  }

  isPressed = pressedThisFrame;
}```
#

something like that

#

alternatively this might work too:

public void Crouch(IAC context) {
  if (context.phase == InputActionPhase.Started) {
    Debug.Log("Pressed!");
  } 
  else if (context.phase == InputActionPhase.Canceled) {
    Debug.Log("Released!");
  }
}```
deep oxide
#

Hey. How do I safe the horizontal input in a float as we used to did with the last API ?

red widget
#

You need to create an Input Actions Asset

austere grotto
#

or context.ReadValue if it's event-based

deep oxide
#

I fosmone clicks D I want to move the player object right

#

IF A left

#

I understood the old API but this seems weird

red widget
deep oxide
#

Btw, do I have to import a library or so?

red widget
#

If you installed the package nope

austere grotto
deep oxide
red widget
#

Just create one somewhere in your project, it's required to proceed

austere grotto
#

you will need to devote some time to learning it

deep oxide
#

Well

#

I guess that sucks but is mandatory ?

red widget
#

If you want to use it correctly, yes

deep oxide
#

Ok

#

LETS GO

#

JUst a quick explanation. How does it work in general ?

red widget
#

You create the asset and bind actions

#

An Action could be "Move", and under it you set the keybinds for it (eg. WASD and left stick)

deep oxide
red widget
#

Then on the object that is supposed to receive the events (your player), you add an Input System on it and drag your Input Asset in it.

deep oxide
#

Wait why do I have to make an asset ?

#

Wtf

#

Why cant I save an input simply in a float ?

austere grotto
red widget
#

You can now select how your script will receive the input events (let's go for SendMessage for now)
Still with that "Move" action, your script will receive an "OnMove" event, that you bind to a method.
From that method, read the input as a vector or a float

deep oxide
austere grotto
deep oxide
#

I had EXTREME STRUGGLES with adding touch support with that

austere grotto
#

you're going to struggle even harder in the new system

#

Unless you accept that you will need to be patient and try to understand how the new system works

deep oxide
#

I am trying to do that

austere grotto
deep oxide
#

Thats what the video shows

#

That’s what I see

austere grotto
deep oxide
#

Wdym ?

#

I did everything as it was shown there

#

I make a 2D game btw

austere grotto
deep oxide
austere grotto
#

Well I'm not telling you to make it a button

#

I'm telling you to make it whatever they made it in the video

#

probaby Value/Vector2

mighty ivy
#

anyone here migrated from ReWired to InputSystem? i'm really struggling to translate the concepts between the two

#

like, in Rewired you can set an event for an action, and the event is fired and containts the player that fired it

#

the player input manager doesn't...appear....to work how i think i need

austere grotto
#

The PlayerInput component has a playerIndex or something like that

mighty ivy
#

yeah, i dont seem to get that far, so i have a playerinput component and its set to Send Messages. i had assumed i can add a new script with a method called OnMyAction and it would receive a message whenever a MyAction action was detected

#

or, let me be more specific

#

i want a player to join a lobby, so i have an Action called OnJoinGame

#

oh my rubber duck

#

okay so bad typo spotted

#

the message is received but yeah i still need to get the player info

#

so yeah how to access the playIndex from a message though?

cursive tulip
#

Any idea why my code can not detect my right click Button from my input actions ?

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


public class CameraZoom : MonoBehaviour
{
    public Camera myCamera;
    void Start()
    {
        myCamera = GetComponent<Camera>();
    }



    ////////// New Input System Anfang //////////////////
    private PlayerActionControls _controls;
    private void Awake()
    {
        _controls = new PlayerActionControls();
    }

    private void OnEnable()
    {
        _controls.Enable();
    }
    private void OnDisable()
    {
        _controls.Disable();
    }
    private void Update()
    {
        bool _ButtonPressed = _controls.Player.Movement.ReadValue<bool>();
        Debug.Log("Update Inhalt: " + _ButtonPressed);
        if (_ButtonPressed == true && myCamera.fieldOfView > 30f)
        {
            Debug.Log("rightclick-zoom ON!!");
            myCamera.fieldOfView -= Time.deltaTime * 70f;
        }
        if (_ButtonPressed == false && myCamera.fieldOfView < 60f)
        {
            Debug.Log("rightclick-zoom Off...");
            myCamera.fieldOfView += Time.deltaTime * 70f;
        }
    }

}
austere grotto
#

bool _ButtonPressed = _controls.Player.Movement.ReadValue<float>() != 0;

#

try that instead of ReadValue<bool>()

mighty ivy
#

sorry for the n00b question but how do i receive that info?