#🖱️┃input-system
1 messages · Page 44 of 1
yep that worked! thanks!
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.
So I figured out the performance problem, it looks like using callbacks when i need to poll something is real real bad. Still though I'm interested if theres another way to either translate the current mouse position relative to the screen's centre using the current input callbacks
Yes you need the values to be in the same space. Position [Mouse] is in Screen space, you need to convert it to world space camera.ScreenToWorldSpace("Mouse position"); to work with it
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
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Actions.html
each action also has .cancelled, which gets called when an action is released, typically
so input.CharacterControls.Run.cancelled += OnRunInput; right beneath performed?
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
thanks, that seems to work
trying to translate it using camera doesnt get the result exactly the way I want it to. Ive searched around and the two solutions seem to be by doing exactly that, using ScreenToWorldPoint, and the other by doing what I'm doing right now. I'll stick with what I've already got working and just call it a day
Any know how to use the New Input System with this? https://github.com/KonsomeJona/unity-gb
So PS5 Controller to PC to Unity is does not work?
@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.
Then were do I look?
Sometimes there just isn't an answer.
in the patience cupboard
Someone has to be the first to solve a problem, and you're likely going to have to be that person.
I stayed up all night and still can't get it to work
Just one night?
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.
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
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.
Right ... so ... if it's open source, and you're proficient with the new input system, then it should be convertable?
This might be a good first place to look: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Migration.html
There's a 1:1 migration for most things
Thanks, sorry if I was rude
use the version it was made for lol
😄 👍
and just dont deal with migration
Only problem is I want to put it on switch
oh that would be a problem i guess
Yeah😂
If you're planning on publishing on the Switch, you are aware that you need to be a registered developer?
No? When?
hey y'all! can anyone reccomend a good input control for touch controls ?
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);
@hard hedge it could be because you're binding on perform
what do i bind it on
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
how do I get it in update btw
myInputAction.ReadValue
Vector2 inputVector = controls.Player.Movement.ReadValue<Vector2>(); doesn't work
Why not
controls is a class I generated from the InputAction
Is your control type set to Vector2?
yes, i sent a screenshot on the otehr channel
Action type should be value
yes I've doen that
oh wait
i'm dumb
sorry, my Move() function wasn't being called
input.GetKey is for keyboard inputs..... if i need it to find joystick(mobile)inputs i need input.GetJpystickNames .. ?
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
beginning of the video is with control stick
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
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?
have you installed the player input package?
or doesn't it appear in the package manager?
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
You need the Input System package
It's in Unity Registry
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 👍
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 😄
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.
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
hey, how do i check the last input made by the player?
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
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.
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.
The new input system is very flexible and you can continue doing things the way you were doing them before if you want
you simply have new options now
Dang, then I guess it's just me 😂 I've spent days trying to figure it out, looked at every tutorial I could find :/
FixedUpdate() {
Move();
}
Move() {
if (Input.GetAxis("Horizontal")) {
movement = new Vector3(Input.GetAxis("Horizontal"),0,0);
rb.AddForce(movement * thrust);
}
}
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
And do the other ways of implementing with InputSystem have smoothing built-in?
So the drawback is only against the old InputManager, not other InputSystem implementations.
right
Ok, fine by me. Now to search up "how to implement input smoothing in unity"
In this example, what is myHorizontalAction? Just trying to think what to replace that with in my code.
You need an InputAction
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>()```
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.
Make sure you've enabled the asset at some point
e.g.
horizontalAction.asset.Enable();
but that only has to be done once, globally, for all the actions in the whole asset to work
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
@vague gull Do you have a link to the tutorial? 🤔
@vague gull Is it this one? https://www.artsandjustice.org/unity-basics-part-2/
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.
Not adding the jump though
Ok, is Vector3.forward supposed to be in both of the last two lines?
OH thats probably it lmao
I didnt notice that at all, thank you, n sorry if I bothered lol
lmao I saw it the second you posted the code but I needed the tutorial to be sure 🤣
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?
if you mean this:
thank you so much ill take a look (:
No problem :)
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
Do you have the newest version of unity?
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 :)
Both ways are valid, and there are even more ways than that
-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
InputActionReferencefield 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
yup. maybe i dont know how to search it but i cant find anywhere online that has the same issue
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?
how do i do Input.KeyDown(KeyCode.LeftControl); with the new input system?
myInputAction.triggered```
Weird question, is there a difference in performance if input management, and input logic are in the same script versus separated into two?
no
not due to the separation itself
Ok, thank you
and how do i know when it is released?
@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
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?
Ooh didn't know Keyboard had an indexer
kinda funny that they have all those Keyboard.leftControlKey properties too
Just disable your player movement script
alternatively - if you're using the new input system - you can disable the Action Map(s) related to the player moving around
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
Time to separate out your different behaviors into different scripts
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
ill try that
Those are actually super unique to the OS. They resolve to "Does the system think that Left CTRL Is Pressed" which is really important for things like Accessibility settings
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
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.
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
Yea I'm quite sure this is built-in to the new input system, but no idea how the API works
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
thanks!
@frigid ridge there are some examples in the importable samples of the InputSystem but I'd hesitate to call it built in.
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
Can you somehow make the control type of a pass through action a boolean? So you could use ReadValue<boolean>() in the lambda expression?
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.
You're probably best off handling it by telling PlayerInputManager that you want to manually spawn players, rather than when a button is pressed.
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
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?
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.
sikdw]
Probably another UI element on top of it blocking it.
HOw can I detect right click on object?
You can use IPointerDownHandler and check the button that was clicked to trigger it: https://docs.unity3d.com/Packages/com.unity.ugui@1.0/api/UnityEngine.EventSystems.PointerEventData.html#UnityEngine_EventSystems_PointerEventData_button
thanks
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
Do you have Colliders on those things?
yes I do have a collider
are you missing any script on the other assets? or in case collision, rigidbody?
no they all have the same things: character controller, mesh collider (convex, not trigger) and a script which is meant to move them
thats weird, not sure but check if the other objects has static flag on, might be the reason objects are not moving
what is that
select any gameobject, in inspector, top right, you can see a static checkbox
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
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
the problem was my DS4Windows driver that mimics an xbox controller so Unity registered having both the ps4 and xbox controller
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
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:
-
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?
-
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?
- Both actions will fire when holding the modifier and there's not really a good way around it other than handling the modifier manually rather than using the modifier binding feature.
Not sure about the rebinding stuff as I haven't dealt with it yet
@austere grotto ok. I wasn't sure if that had been addressed yet. Thank you. I can manage around that.
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?
https://www.youtube.com/watch?v=LOC5GJ5rFFw Putter, I know this is 3d, but he is using the new input system, maybe it'll help
► ANIMATIONS
https://drive.google.com/drive/folders/1j2HicZMabg4h2Oe8ocxGNuKBHY5kzFJA?usp=sharing
► PLAYER MODEL
https://drive.google.com/drive/folders/1X6DLqSsLT2EAIYpcZGYL-Z93hYOo2sxa?usp=sharing
► EPISODE TWO
https://youtu.be/c1FYp1oOFIs
► SUPPORT ME ON PATREON!
http://www.patreon.com/SebastianGraves
► FOLLOW ME IN INSTAGRAM!
https://www....
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
no gameobjects are static
can you post your move script here?
I've never posted a script how do I do it
you can use any code paste site, https://hastebin.com one
or like mentioned here https://support.discord.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline- under code blocks
I'm using hatebin and I copied the code into there, now what
share the link
there's no link to share
yup just noticed, https://paste.ee another, not sure if its allowed here
A free, easy to use Pastebin.
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^^
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
nope i ran into same issue you're facing in an fresh project, i can move my cube with a set of input actions but cant reuse the same on another object
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.
do you have any idea what the error is or a work-around
either i was doing something wrong, or input system has some issues, but make sure other gameobjects has the playerInput component, reference to the action your cube has in playerInput component, and behaviour is unity events & events has refs to your OnMove & OnJumo methods
EventSystem.current.SetSelectedGameObject(target);
You can also use this to forcefully select something when you know input needs to happen.
Oh damn I fixed it with a way more spaghetti solution... Thank you mate I'll know it for next time!
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.
There's no such smoothing built-in but the algorithm to do it is pretty much just Mathf.MoveTowards
Damn - was hoping to avoid that, but at least I can stop searching and get to that!
Thank you!!
Input system still doesn't have a more native way to deal with this?
Not AFAIK
You'd think, right?
But I haven't checked in a while
I can't find a thing
i did a work around i just made the asset a child of a cube and took away the image comononent from the cube. so the cube moves things and it just looks like the asset is moving
@frigid ridge the primary issue w/ recreating the Gravity/Sensitivity thing is that Processors don't have history 😦
Ah yea that was the issue
Ah thank you! The problem was that I was expecting the OnMove event to fire every frame if any of the keys were pressed, but the video showed that you just simply make a class variable that the On Move context gets set to. Thank you!
try posting your ques here again, even i'm new to the input system, and i dont think it should require that kind of workaround
It works for now so I think I'm going to keep using it like this, though if I run into problems I will repost my question
anyone familiar with XBOX controller input?
any chance you're mixing up the Left Trigger and the Left Bumper?
Hey guys does anyone have a slide controller code? Mine simply doesn't work and I would appreciate to see where I've mistaken.
@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
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
Ok, seems like the InputProcessor framework is broken, not even the default ones work
hello, when I press a button once, it executes 6 times, does anyone know why it happens.
I am using the Input sistem
where exactly would I request Unity to make InputAction.isSingletonAction a public member instead of internal? Its a PR on github the only way?
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!
what does this mean
Input Axis Fall doesn't exist in your input settings
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 😟
Serialized field simply serializes your field, which most folks would use to accessible fields from the inspector whilst still being private. Not sure it relates to trying to trigger your animation. Is the field not visible in the inspector? What's the exact problem?
@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
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.
you mean on the input menu , or just create a different script to call the animation through binddings?
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
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
😟
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?
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.
for now i only have this
2 layers one masked with the other
with 2 parameters for the code
so i m not sure ...
You're getting a similar issue as this: https://gamedev.stackexchange.com/questions/184921/unity-2018-4-25f1-errors-error-cs0118-error-cs0234
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.
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
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)
@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 ^^
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.
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;
}```
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 😦
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....
for now I just switch the state of a boolean to check the mouse behaviour, does exist a simplier way?
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.
you mean need to print the key name?
yeah. I hate having to set up 26+ chars every time I want to do this
ah that was what i was gonna suggest
Yeah I'm already doing that. It is really surprising that there's no way to get the exact key pressed's name
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
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
no i mean just create a list/array, check the key pressed in the array, then print it
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.
Setting up using this anykey, does not return the correct value when using context.control.name
There's a way not using InputAction at all
Check out Keyboard.onTextInput
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.
it's not but is the "anyKey" thing relevant when using gamepad?
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?
How can I make a simple getKeyDown with the new Input System?
I think you can try this
The 1:1 conversion wouild be:
Input.GetKeyDown(KeyCode.E)
```becomes
```cs
Keyboard.current[Key.E].wasPressedThisFrame
Hi can someone help me with the xr toolkit what does this trackedDeviceDragThresholdMultiplier mean?
Docs:
(Scales the , for tracked devices, to make selection easier.)
Thanks 👍
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? .-.
Have you tried printing the mouseHold and experimenting what it does under certain conditions?
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
Seems like a #⚛️┃physics question not an input question
sorry, struggling to find where to put questions
I cant print it rn since that readvalue method gives an error
Any help?
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.
There should be an join on input sample in the input system samples
I actually just found out today that there's a ReadValueAsButton() function that returns a bool
I found out a similar solution
Oh okay that's good
so "myBool = Actio.ReadValue(int)" and then I switch to true of false if that int is > 0
thanks for the help
No problem lol
mouseHold = playerInputActions.Mouse.MouseHold.ReadValue<float>() > 0 ? true : false; //GetKey
here is the line if somebody need it
imo it actually is more readable if you do the ReadValueAsButton func
"MouseHold" is just the left mouse click
Documentation and topics online are really old and scarse tho
whats the difference between pass through and value?
thanks
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
Are you using assembly definition files in your project?
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
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
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
You have to save the lambda in a variable before you assign it, then unsubscribe the saved lambda with -=
System.Action act = ctx => {};
....performed = act;
Thanks it worked!
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
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
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?
I personally don't know how to register mobile touches. However, whenver one happens, you can have an integer called counter. whenever you touch the screen, counter++. If( counter % 0 == 1){
Go to Left Walll
}
Else{
Go to RightWall;
}
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
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.
as long as they don't outright remove the old one heh
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. 🥲
ermm, that wasn't really on point for this channel. probably better off looking at the Collaborative part of the Unity forums.
so im trying to use a custom hid input system, and i am following the docs here: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/HID.html?_ga=2.185536302.680039686.1621801468-1881690151.1621801468
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
{
}
thx!
that helps solve some of the issues, but IInputStateTypeInfo is still not defined
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.
You can unsubscribe it.
Inputaction.performed -= DoSomething;
Currently I have my movement using getaxis. But when I use controller it seems to use getaxisraw. Is there a workaround to this?
How do you properly destroy a component using input system, it keep receiving my input
Are you calling Disable(); ?
I found the solution
searched this some more, found a page here(https://docs.unity3d.com/Packages/com.unity.inputsystem@0.1/api/UnityEngine.Experimental.Input.IInputStateTypeInfo.html)
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
what does the error say when you mouse over it?
"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
thanks
yeah, no clue what im missing... ive tried looking online, but cant figure out what im doing wrong
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/manual/Layouts.html - on the generated layouts section, i just dont know how to integrate it
ay i got it
How do I go about finding that event during runtime? I'm looking through everything in my debugger and nothing seems to show an event.
The event is a property of the InputAction
In addition to unsubscribing/resubscribing to the event you can also just disable/enable the InputAction itself
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
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?
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)
You have an EventTrigger component on it that has an OnCancel handler registered that is somehow broken
For example it's referencing a method that no longer exists or has the wrong arguments
tyvm. Dunno what was wrong, because was getting it for awhile, then without fixing it, stopped getting the error. I'm chalking it up to unity weirdness.
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
IMO target the new one and add support for the old one if it becomes a point of contention for some reason. Worst case, those people can enable both at the same time
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
tl:dr attach a "CinemachineInputProvider" component to your FreeLook, POV, or OrbitalTransposer camera
and set up the axis -> InputAction you want
I'll try that thank you.
Thank you it solve my camera issue really well
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?
If some elements are working but others aren't it most likely is not Input related. But you can check this by looking at the EventSystem in your scene and examining the StandaloneInputModule component. That is responsible for mapping Input to the UI
how would I examine the component, you mean just look at it in the editor? it looks normal 🙂
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
oh interesting
That can help detect objects over other objects etc
It has Input Axes from the input manager on it
Make sure they're populated and correct
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.
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
how did you set up the input action?
and what's the desired behavior
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
you want it as a button?
is this for clicking the stick in?
Or tilting the joystick
Not really, I just want it to play an animation without being so exact. It’s tilting
@austere grotto
maybe make it a Value instead of a Button
Value -> Vector2
you should get performed very early on in the tilting
Who knows, how to add force (rigidbody) to the object in local coordinates using joystick for mobile?
Quaternion currentRotation = rb.rotation;
float moveRotationX = ...
float moveRotationX = ...
Vector3 moveDir = new Vector3(moveRotationX, 0, moveRotationZ);
Vector3 worldDir = currentRotation * inputDir;
rb.AddForce(worldDir);
Thanks
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.
I'd post this in beginner code, this section is for Unity's new Input System package
but here's a tutorial for FP movement, he has one for 2d Movement, too. Brackeys is great for beginner tutorials. https://www.youtube.com/watch?v=_QajrabyTJc
thanks
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.
Are you sure it's an input system problem and not just a problem of blocked raycasts for the pointer?
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
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
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
@tight horizon No crossposting.
You were already told to use #🥽┃virtual-reality so no, that isn't an excuse.
Anyway, I posted a doc link in the channel, hopefully that helps.
how do i get axis value from a joystick x axis
Input.GetAxis("name of axis")
you can find the axis name in the input manager
probably "Joystick X" but i'm not entirely sure
Does anyone here know how to make a car enter and exit system?
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!
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...
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.
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.
How do I configure my Move action to go back to 0,0 when I release the buttons?
pass through.....
if(Input.GetKeyDown(<key>)
{
do something
}
im assuming this will fix it if you're using Input.GetKey
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
@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.
how do i print out to the console whatever button is being pressed on the gamepad?
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
"rezzing"?
oops spawning I meant I will adjust the question
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
The action has 3 phases
Started
Performed
Cancelled
You can read value.phase in your function to see which phase it is
Ok that makes sense. Should I just not go with this method style and just subscribe to the event instead?
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
I guess I can do both right
I generally prefer not to use PlayerInput because it makes this stuff a bit confusing
What are you considering "PlayerInput" ?
The PlayerInput component
Yes
Got it
My issue is the documentation, it's quite confusing
That sounds familiar. I can recommend to look at the example projects that you can import with the new Input System. They show all the different ways to use it. Eg. set up Events and Callbacks in the GUI or do everything in-code.
sprinkle a few insights from the documentation code snippets on top of that and voila.
Currently my code skips over 2 and 3 how would I make it wait?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I'm going to move this to general code because I think its a problem with my int not my input
So I'm having some problems with getting keyboard input to work in unity, is this the right place to post about that?
don't know why it doesn't work but you should ony have 1 if per direction
yep
How do i enable visual studio autocorrect?
Anyone here use Rewired? Is there documentation and/or video tutorials available?
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>();
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
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
This doesnt really tell me the difference
I just want to know if I should read the value of a button as a float
@glossy granite most everything is a float unless its a Vector in InputSystem
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?
"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
Yeah okay. It made sense to do that
if you are using another method for dealing w/ input its less important
I did mark it as a button, but I read it's value as a float
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
How do I use that?
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"
I'll figure it out and toy with it. Thanks for the help!
Do you require any attribution for this help @west oracle ?
nope! 🙂
Thanks for the guidance!
So overall, no attribution is needed, correct @west oracle?
none
I apologize for my confusion, I just wanted to clarify I was making the correct assumption based on your answer @west oracle thanks again!
lol, no need for attribution.
Cool thanks! @west oracle
@west oracle how long have you been using unity?
mm... long time 🙂
Cool cool. I love it and thanks again for all your help and clarification that you do not require attribution! @west oracle
since ... 2009? something like that.
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
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
It's up to you - you don't have to go event-based in the new input system
it supports polling just the same
is there a best way to use input actions without doing event-based?
You get references to the Input actions (there's several ways to do this), and then you just read their value each frame
I'd like to have access to wasPressedThisFrame and such, but all I have is ReadValue
This is a pretty good guide for the 1:1 conversions from everything in the old input system: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Migration.html
anyone know any tutorial of info about change the bindings at runtime for the new input system? like to make a option menu?
lokes nice... gona study it ty
this one goes into a little more detail than that one, and more up to date: https://www.youtube.com/watch?v=csqVa2Vimao
where i get to know about it
playerControls.PlayerMovement.Movement.performed += i => movementInput = i.ReadValue<Vector2>();
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

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.
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?
wdym by "playing an input script"?
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.
It should be faster than running the same code/reading the same input from multiple instances of the script
the cost is that your code is a little more complex and you have a singleton to manage
how do i Add/Remove InputActions during runtime to switch them out?
switch them out?
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
Normally you'd just disable/enable inputactions
or do a rebind if that's what you're going for
but all the add/remove stuff seems to be here:
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/api/UnityEngine.InputSystem.InputActionSetupExtensions.html
AddAction and RemoveAction
i'lll check it out. thanks!
they're extension methods on InputActionAsset
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. :/
I'm not really understanding why you're trying to add or remove input actions
Why don't you just enable/disable them?
Can someone help me understand touch inputs (android)? Mainly what I want to learn is
- swipe action
- touch to move in 3D world
- double tap to action
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?
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
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>());
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
@spice orbit Please don't cross-post #⚛️┃physics
Sorry, Its hard to use physics xD. Is there a proper place I can post for this one?
I left the one in #⚛️┃physics.
By the way, if you're looking to pay someone, you can use the official Unity forums for job postings.
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?
What's the best way to detect a button release with the new input system?
Listen to the .cancelled action on the input.
If I'm doing a multiplayer game local or networked will making InputManager a singleton not work out?
it will work fine.
as long as you make it only control the local player's character
Okay I was a little worried that making it a Singleton would mean only the first player will have access to the input manager
Are you talking about some custom class of your own, or Input System's PlayerInputManager/
My own using the new Input System
If it's your own thing... then whether it's compatible with local multiplayer is up to you
Are the input actions called each frame?
@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.
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
On screen joystick? One simple thing to check is whether the UI itself got screwed up
Does the joystick UI element appear to respond?
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)
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
did you try removing it with the Package Manager?
Yeah it’s gone
But now no inputs are there because the system switched and I want to switch it back
Did you switch it back in the player settings?
Where is that
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
Build Settings -> player settings -> other settings -> input... It'll be a drop-down
FUCK YES
Thank you thank you so much
It’s good now
Welcome
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
🤔 that should work
some one on another server said maybe linux bug but then why would send message work
Any chance you have any compile errors?
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
No I have no errors
I just switched to send message since it works
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 :)
disabling action maps is how I do it.
And the InputActionAsset is basically a singleton scriptableObject that you get for free
assuming you structure your project to reuse a single InputActionAsset
Would there be any advantage to splitting them?
that's one reason I prefer to use things like
InputActionReference in my code instead of the generated C# code or other options
At the moment they are all in 1 input asset
I don't see what advantage there would be unless you wanted to enable/disable entire assets at a time
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.
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
for the player input component which is better send message or invoke unity events
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.
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?
This is a common issue and unfortunately the Input System doesn't have great solutions for it as of now. For now your best bet is to just use two separate InputActions - one for the modifier and one for the action button, and just check if the modifier is held down or not in your code
Instead of using the Button with modifier feature.
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?
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
oh thanks i get it now
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*
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
i see, thank you
When using the PlayerInput component when are the input events called in relation to Update LateUpdate?
@keen drift This doesn't seem to be input related. Move it to #💻┃unity-talk
ah ok. Thanks!
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.
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
disable the CinemachineInputProvider component when you don't want it to work
Or disable the InputAction when you don't want it to work
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?
There is a specialized Multiuser Event System
the MultiplayerEventSystem doesn't seem to play a role
sorry lemme read ur Q more lol
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
i disabled input provider while in play mode in the inspector and it still rotated the camera
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;
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
Yep
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
how do i check if one of my input actions is being pressed in the update function
not sure what's going on... maybe ticket it
var currentValue = myAction.ReadValue<float>();
if (currentValue != 0) ...```
something like that usually
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
a powerful website for storing and sharing text and code snippets. completely free and open source.
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)
hey guys trying to figure out why this error is coming up
just imported the platforms package in order to use crossplatform input
still getting it
Sounds like you have some invalid camera settings or something maybe
Like a clipping plane distance of 0 for example
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
@austere grotto Thanks for you answer. I will look into that 🙂
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;
``` ?
hi does anyone know how to use the input recorder? i couldn't understand much from the documentation and there isn't much online either https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/api/UnityEngine.InputSystem.InputRecorder.html
On UI or on objects in the world? And since you mentioned enchaned touch, are you doing a mobil game?
Actually, I don't want to detect click on a specific UI or object, but anywhere in the screen, like I do for my fingerDown. Using enhancedTouch for polling events on touchScreen devices
Well I don't know what code you use, but I have a solution in bolt. You can probally translate it to C#. It's a custom event which triggers in any object clicked on anywhere as long as they have a collider, then you go into that object and write them a function to that custom event.
I'll have a look thx
OnMouseDown should work
You could also look at IPointerDownHandler
Just make sure you're using the correct Input Module for the input system you're using
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?
I would guess it's not supported. Switch pro controller is mentioned only as having basic support here: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Gamepad.html#switch
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?
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.
I'm currently using a bool to check if its pressed down.
if(value.phase == InputActionPhase.Started){
AttackDown = true;
}
if(value.phase == InputActionPhase.Canceled){
AttackDown = false;
}
scr_Combat.Instance.OnAttack(AttackDown);//Send the bool to an updated function or coroutine
}```
When using Cinemachine's Input Provider is it possible to stop it from taking input such as for when a UI menu is open
Does anyone know if its possible to make cinemachine only move on right mouse click drag?
Like you would see in many mmo games
Disable the relevant input action or action map
hey does someone know a solution to my problem?
Why does WASD work in the new Input system, but my Gamepad not? (My Gamepad is successfully connected because I proofed this)
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
@cursive tulip you have like 1k errors just disabled, maybe show/check out what they say
Does anyone know how i can get the position of XRNodes???
https://docs.unity3d.com/ScriptReference/XR.InputTracking.GetNodeStates.html
The documentation is really confusing
I turned back on in the Project Setting the Input system to: "Both" and there is not a single error anymore. But This does not fix the problem that still only WASD works on the new input system in my video and don't show it up in the console, if I am using my Left Stick on my Gamepad.
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
I also want to support 4 additional VR Devices and maybe also the Steam controller. that's why I really want to use the new input system.
(I try to support closely everything in my game)
can you check the sample projects? i pretty much started off one and it works great
I tried yesterday to load a sample demo from the Input System Asset but it is not self explaining it and if I try to modify it, my modification will not work. the samples work fines also the gamepad support aslong it is everything made not by me
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.
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)
I try at first the get a Vector 2 Value back from the new Input system, before I can include it directly into the game controls. that's why I want first the vector 2 values show'n by the console but there is only output from the WASD Keys from the Keyboard, but no Gamepad Stick, even if I exactly made the complete same on the Gamepad like on the Keyboard...
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
I got a responds from the analysis Unity window so the Controller does work correctly. but the Input system does not notice or apply the Gamepad stick value to the console via Debug.Log
@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);
}
I tried to overwork my code more like this: https://youtu.be/Pzd8NhcRzVo?t=873
Let’s check out what Unity is working on for the new Input System!
► Go to https://expressvpn.com/brackeys to take back your Internet
privacy TODAY and find out how you can get 3 months free.
● Get the new input system here: https://bit.ly/2SiXsgS
👕Check out our merch! https://lineofcode.io/
♥ Support Brackeys on Patreon: http://patreon.com/b...
that's brackeys in general
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
How to add gamepad support with haptics using Unity's latest Input System. For previous videos of the input system:
►How to use Unity's NEW Input System: https://youtu.be/yRI44aYLDQs
►Make a SIMPLE Character Controller using Unity's NEW Input System: https://youtu.be/w1vC32e11wU
►Input System Documentation: https://docs.unity3d.com/Packages/com....
Does anybody know how I can get Input.GetAxis("Mouse X") with the new Input System?
Mouse.current.delta.x
Thanks!
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
@gentle mango now sure how you're calling that in the first place, but https://cdn.discordapp.com/attachments/852698847229771806/852923581919002654/unknown.png
i was just going over this in PM with someone
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)
so would this work if(context.ReadValue<float>()>0)
cuz it still triggers when i release the key
ehh there's nothing wrong with polling
New input system supports both polling and events
it should work - have you printed out what the value is that it's returning?
im gonna do that now
or - are you trying to detect when it's first pressed?
if so - I do recommend using the events
exectly like why cant it be a bool make it so much simpler
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)
well....
if you want to do things the "old fashioned way" you can
e.g.:
Input.GetKey(KeyCode.S) => Keyboard.current[Key.S].isPressed
Input.GetKeyDown(KeyCode.S) => Keyboard.current[Key.S].wasPressedThisFrame
the old fashioned way kinda makes the entire NIS pointless though
Input.GetKeyDown(KeyCode.S) => Keyboard.current[Key.S].wasReleasedThisFrame
agreed haha
but it's there 😄
was really mad when brackeys actually did a video on that
did he?
yep, he didn't even cover other methods in that video
I mean it's good in a pinch to quickly upgrade an old project into NIS
true that
but wouldn't really use it otherwise
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
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
You need to save the state
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!");
}
}```
ok this one worked
👍
Hey. How do I safe the horizontal input in a float as we used to did with the last API ?
You need to create an Input Actions Asset
float hInput = myInputAction.ReadValue<float>();
or context.ReadValue if it's event-based
I fosmone clicks D I want to move the player object right
IF A left
I understood the old API but this seems weird
In your project files of not done yet
Btw, do I have to import a library or so?
If you installed the package nope
it works a little differently
Bruh
Just create one somewhere in your project, it's required to proceed
you will need to devote some time to learning it
If you want to use it correctly, yes
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)
assets ?
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.
Wait why do I have to make an asset ?
Wtf
Why cant I save an input simply in a float ?
Go back to the old input system
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
But I want controller, keyboard and touch support
old input system supports all of that
I had EXTREME STRUGGLES with adding touch support with that
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
I am trying to do that
Here's some videos: https://forum.unity.com/threads/best-practices-getting-started-tutorials.875818/
make sure the input action is the same type as the video
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
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
The PlayerInput component has a playerIndex or something like that
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?
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;
}
}
}
bool _ButtonPressed = _controls.Player.Movement.ReadValue<float>() != 0;
try that instead of ReadValue<bool>()
you mean here right?
sorry for the n00b question but how do i receive that info?
