#🖱️┃input-system
1 messages · Page 13 of 1
its English (US)
mine works lemme see what it looks like rq
go edit/project settings/input manager/ check the box for 'Use Physical Keys" see if it works
self and def dont exist as options
no its not the unity version its the input system package version thats the reason ours are different i think?
ive got the old one
so should I change it to na older version?
your version should be fine. im using something similar for my game:
using UnityEngine;
public class PlayerMovement2 : MonoBehaviour
{
private CharacterController2D controller;
private float moveSpeed = 5f;
private bool jump = false;
private void Awake()
{
controller = GetComponent<CharacterController2D>();
}
private void Update()
{
float move = Input.GetAxis("Horizontal") * moveSpeed;
jump = Input.GetButtonDown("Jump");
controller.Move(move, jump);
}
}
just copy my code and pray it works lol
alright
oh wait you dont have controller
ohyea
or do you
im using keyboard
you can use my code only if you are using a character controller
ohhh
i should mention one thing
im using 3d aswell
sorry for not mentioning earlier
oh im in 2d. just find a script online for player movement so you can work on something more interesting
google 'player movement script unity'
modify it to your liking after it works
yeah thats what i did, I followed a youtube video and I got to this point, but the movement inputs just seem to be flipped
its odd because when i originally launched unity, there was literally 0 inputs in the input manager so I had to set it to default
so your input horizontal is making you jump and input vertical is making you move side to side
bruh your player object might be rotated 90 degrees
OHHHH
Im totally unsure why
but
it wasnt rotated at all
but rotating it 90 degrees fixed it??
big win
hey guys, I'm trying to code a game that basically involves moving sprites and snapping them into specific locations on the screen. I got the functionality to work so that I can hold down the left mouse button on an object, drag it to move it around, and let go of the left mouse button to put it down, but I can't quite figure out how to get it to snap into position. I have a function I'm working on that somewhat works, but the problem is it snaps both the goal position and object into the center of the screen immediately on start and I'm unable to move the object again (it's still trying to select the object in the inspector though). Here's a link to the code I'm currently working with --> https://gdl.space/utecorodet.cs. If anyone can help or give advce I'd greatly appreciate it!
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.6/api/UnityEngine.InputSystem.CommonUsages.html How can I find out what these "common" ui actions are actually bound to on different devices?
ah the input debugger has this
Hello ! (i know this is a frequently asked question but i tried so many things that didnt workd) This is a very simple error but i cant get it to work.. Basically, my inputs work on the editor but when i build they dont work anymore.. and thats it. I dont have build error or anything btw.
Probably a script execution order issue or something. Check your player logs for errors to help debug
there are no errors, it says
Add logs where you subscribe to the inputs and logs where you use them
on my player i have the movement script and i have the player input action component aswell, and the mode is "Send messages" so the in my code i do something like "OnRightClick()" and when i right click it call this method
so i dont have subscriptions to the inputs etc..
so im here now @supple crow @turbid olive (sorry for the ping
heyo i have the same problem can you say how you solved it?
You need to use PerformInteractiveBinding().WithTargetBinding. I remember it being a bit finicky, but I used this video as a reference https://www.youtube.com/watch?v=dUCcZrPhwSo
thank you :))
can someone help me out with my problem please
i'm not experianced with unity, but something oyu can do is scale your game around unities units, then you can simply use a rounding function to round to a unit like
Math.Round()
or whatever the c# equivalent is
i know very little, as i'm just getting started, but that's what i would do, or if you're deep into game development , but you are pretty set, you can do something where like if it's every 7 units do something like
if (pos %7 != 0) {
position -= pos%7;
}
or something akin to it
just thinking about it, what i would do depending on your system is have the xyz, then based on an imput lerp from a to b with an animation or whatever you want. then also set some gate where it can't be changed again until that value is reached. ie
eventCalledFromInput() {
if (player.worldlocation == desiredLocation) {
changeLocation() {
desiredLocation = logic();
}
}
else {
alert("you can't do that dummy!")
}
}
(no idea with the above sorry)
i'm having an issue currently trying to grasp the new input system. for some reason if a key is reset back to 0, it doesn't trigger a call unless another one is being activated.
ie, if i press w and let it go, this code will think w is still pressed, does anyone maybe know why?
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
public class Test : MonoBehaviour
{
//public InputAction playerControls;
private TestPlayerInput input;
public Rigidbody rb;
[SerializeField] private byte movementSpeed = 1;
[SerializeField] private byte usrLookSensitivity = 2;
private Vector2 moveDirection;
private float moveDirectionX;
private float moveDirectionY;
private void Awake()
{
input = new TestPlayerInput();
}
private void OnEnable()
{
input.Enable();
}
private void OnDestroy()
{
input.Disable();
}
// Start is called before the first frame update
void Start()
{
Debug.Log("test.cs loaded");
}
// Update is called once per frame
void Update()
{
//this calls the fuction assigned to get value each time the input changes
input.Player.Move.performed += MovementValues;
}
void MovementValues(InputAction.CallbackContext value)
{
Debug.Log(value.ReadValue<Vector2>());
Vector2 movement = value.ReadValue<Vector2>();
moveDirectionX = movement.x;
moveDirectionY = movement.y;
if (moveDirectionX == 0 && moveDirectionY == 0)
{
moveDirectionX = 0;
moveDirectionY = 0;
}
}
private void FixedUpdate()
{
rb.velocity = new Vector3(
(moveDirectionX * movementSpeed),
0,
(moveDirectionY * movementSpeed)
);
Debug.Log(rb.velocity = new Vector3(
rb.velocity.x + (moveDirectionX * movementSpeed),
rb.velocity.y + 0,
rb.velocity.z + (moveDirectionY * movementSpeed)
));
}
}
got it, it's because i needed to add:
input.Player.Move.cancelled += MovementValues;
This is a basic gameplay but seems like you are overcomplicating it a bit rather than laying the foundation.
For snapping stuff to locations most basic approach would be to code a grid of [n x m] where each cell would denote a position. Upon hovering your item over this area you can distance check each position (or use colliders/overlap queries whatever fits) and upon releasing you can set the position to the value present in grid, cell size must be > (the largest item on your grid) just so that they can be arranged easily.
At last simply scale grid to screen or vice versa.
Checkout codemonkey's grid implementation, It would be a good start for you!
I was actually able to figure it out mostly by changing the Vector3's to Vector2's, I'll look into that though I appreciate it a lot 🙂
Have you tried turning off code stripping? Or added a [Preserve] attribute on the methods so they don't get stripped?
not sure whats going on, but I'm having a weird issue
heres my basic rotation code (in FixedUpdate):
float mouseX = Input.GetAxisRaw("Mouse Y") * -lookSpeed;
float mouseY = Input.GetAxis("Mouse X") * lookSpeed;
float roll = Input.GetAxis("Roll") * rollSpeed;
gameObject.transform.Rotate(mouseX, mouseY, roll);
float angle = Quaternion.Angle(transform.rotation, prevQuat);
if(angle > 12f)
Debug.Log("dx: "+Mathf.Abs(mouseX-prevX)+", dy: "+Mathf.Abs(mouseX-prevY)+", dr: "+Mathf.Abs(mouseX-prevR)+"\ndangle: "+angle);
prevX = mouseX; prevY = mouseY; prevR = roll; prevQuat = transform.rotation;
my problem is for 4-5 frames in a row randomly MouseX or MouseY will be unreasonably high and not change. heres an example of the problematic output:
is this likely a unity problem or is my mouse just broken? I dont seem to get any unusual mouse input anywhere else
FixedUpdate executes at fixed interval regardless of where the engine state is. Maybe that burst is due to the fupdate code executing several times. Try adding Time.FrameCount to that debug and check weather it is the case or not
FixedUpdate is not the place to read input
That just means FixedUpdate ran 4 times that frame
You absolutely only want to read mouse input in Update
If you need to consume it in FixedUpdate the appropriate technique is to accumulate it in Update and consume it in FixedUpdate
simple example @dawn pebble
Vector2 accumulatedMouseDelta = Vector2.zero;
void Update() {
Vector2 mouseInput = new(Input.GetAxisRaw("Mouse X"), GetAxisRaw("Mouse Y"));
accumulatedMouseDelta += mouseInput; // accumulate mouse input
}
void FixedUpdate() {
Vector2 mouseDelta = accumulatedMouseDelta; // copy the mouse delta
accumulatedMouseDelta = Vector2.zero; // zero it out so it's "consumed"
// use accumulated delta here
transform.Rotate(mouseDelta.x, mouseDelta.y, roll);
}```
ahh this is great! thanks
I was thinking fixedupdate since my movement is going to be physics based
but it reading input multiple times makes sense
Also since you're just using transform.Rotate, which is teleportation as far as the physics engine is concerned, you could also skip this complexity and just call Rotate directly in Update
This complexity would make more sense if you used Rigidbody.MoveRotation for example
im planning on using a torque system, I just left it simple while I work on other mechanics
Then yes -- accumulate/consume is an appropriate pattern for handling torque from mouse input
Does anyone have any knowledge or resources on how to support HOTAS setups with the new input system? I'm making a VR cockpit game and would like to support HOTAS as an optional way to control the ingame joysticks and throttle. Joystick input seems pretty straightforward in the input bindings (see pic) but there doesn't seem to be an existing binding for a single-axis throttle input, or a twist input for the joystick. Am I missing some way to create your own bindings for stuff like this, or do I need to rely on users with HOTAS setups to interactively rebind the throttle control to match their hardware?
hey, I have problem with input system on phone, it's my code
using UnityEngine;
using UnityEngine.InputSystem.Controls;
public class Movement : MonoBehaviour
{
private SimpleInput input = null;
private Rigidbody2D rb = null;
private float movespeed = 10f;
private void Awake()
{
input = new SimpleInput();
rb = GetComponent<Rigidbody2D>();
}
private void OnEnable()
{
input.Enable();
}
private void OnDisable()
{
input.Disable();
}
private void FixedUpdate()
{
rb.velocity = input.Player.Movement.ReadValue<Vector2>() * movespeed;
}
}
and tthis game pad can move, but he isn't work
Seems ok. Use debug.log to see what the input data is reading?
ok i'm idiot xDD
Appreciated
!code
📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
im having trouble with some code. im following a youtube tutorial. it's specifically making me open unity in safe mode and giving me the console error of "Assets/scripts/MovementStateManager.cs(49,10): error CS0102: The type 'MovementStateManager' already contains a definition for 'Gravity'" heres the code https://hastebin.com/share/qisijokawu.csharp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
As it says you already have something with that name
You have a field named Gravity and a method named Gravity
They can't have the same name
#💻┃code-beginner in the future for this kind of question
It's the fact that you used the exact same name for both things. Making one capital and one not just means you are giving them different names, since C# is case sensitive
yeah
So I have a question. Is it really bad to have input relating things in update methods?
I swear guides online always gaslight me
this one says not to do input in update methods, but then how else do you do actions where you hold down the button? (Like for example a rapid fire gun)
There's nothing wrong with input processing in Update
Hello there 👋
I'm not sure if that's the right channel, but I'm facing a problem regarding UI Toolkit's text field.
Although my keyboard is connected, and is detected for any other inputs from my game, it seems to not be detected by the text fields. Do you guys know how can I fix that?
I can actully select the field, but when I write something, nothing is actually writing
Update: When I change the current value via code, I can remove chars (select, etc...) but cannot add any
Gave it a read and here are my two bits if it helps anyway.
Most probably they refer to physics simulated game where it is absolutely necessary for input - dependent simulation to occur before update as physics step isnt tied to frame Update. However using .IsPressed for button types usually breaks the point of adding interactors processors and modifiers so I find .WasPerformedThisFrame() better, Still exploring this part btw.
Might be a long shot but Ig the term Input Processing is also ambiguous between The 'processors' which one can embed in the binding compared to actually process the input. Since 'processors' are part of the state of Input, Its better to embed them with actions in action map compared to executing them 'Updates()'.
In the end there is no perfect solution or silver bullet. Play with it look what works for you and decide. Check out samples as they provide a greater context for dealing with different situations, samyam on yt is also a decent resource for overview of different aspects.
I was trying to use Netcode for GameObjects together with the new input system, but realized that would not be possible because the first prefab created is the only one whose inputs are detected by the event system.
Is there any way for me to try and make this work?
I started a new vr project in 2022.3.1 and the input binding window is broken, has anyone seen this before?
I think Unity's dark mode is broken in the Input System UI
hmm, I haven't had any problems with it previously, is this a new thing?
I think so
When Codemonkey made a video on the new Input System, that didn't happen and he had light mode on, but on mine I get the same thing as you and every time I open that menu I get a warning realated with the dark mode
try switching to light mode I guess
it looks like right click the items works so at least I can work around it
changed theme and restarted but no change
but yeah I see the warning "Unable to find style 'ToolbarSeachTextField' in skin 'DarkSkin' Used"
looks like maybe someone misspelt that
can somebody help me with this?
Having a curious issue on Steam Deck, the input debugger reports the **Select **and **Start **buttons as **swapped **(testing through remote input debug at runtime) and indeed they are!
This happens both while using the Steam Deck's built in controller, as well as any external XInput controllers. Windows build, run through Proton.
Testing the same Xbox controller on my windows desktop and it reports the *correct *button mapping.
I think this used to work correctly, perhaps a couple versions ago? Has anyone else experienced similar mapping issues?
Hmm alright, seems to be a bug in Input System. I've imported the "Visualizers" sample in a new project in Unity 2022.3.2f1, built the "GamepadVisualizer" as a windows app and there too, Select and Start are swapped on Steam Deck using XInputControllerWindows.
I mean, it matches the layout displayed here 😛 just no controller has that layout
(Start should be on the right)
aha!
windows build through proton: swapped ⭕
native linux build: correct ✅
Hi,
I want to build an UI Selection System where I have a stack of selections. That way, if an Event was not consumed by the "currentSelectedGameObject", it can search for a Listener further down the stack. I also want to add additional Navigation events for paging through menus with LT and LR. Because I can't find a clean way to implement these features with the "InputSystemUIInputModule" (new InputSystem), I'm thinking about building my own UI InputModule so I have total freedom on how I want my Inputs from the InputSystem to be converted to UI Events.
However this InputModule is a REALLY complex class and I don't know if this is the right move. On the other Hand this class needs to handle a LOT of usecases like AR, Mobile, etc. For me it would only be Mouse and Controller so it might not be so bad.
Has somebody had experience with building their own implementation of BaseInputModule? How paintful is it? 😄
Hey Guys! Quick Question... With the new InputSystem and "Send Messages" - i easily receive a Button press in my script with OnButtonPress(InputValue value). I would now like to get the actual key that was pressed - a string of "a" for example when button "a" was pressed... Can not wrap my head around and can not find a solution anywhere
What are you trying to accomplish with this?
A few notes to unpack here:
- Typically each significant "button" you can press in the game should be its own input action. If you have other buttons that do the same thing, they can be bound to the same action, but if you have buttons that do different things, they should be bound to different actions This is how the input system was designed and this is what will be the most straightforward and supported way to work
- SendMessages mode is quite limited, only giving you an InputValue, which barely has any information in it. Other modes of operation such as UnityEvents mode will give you a CallbackContext which contains a lot more information.
How do I specify which mouse button in a 'pointer down' event on an event trigger? I need to deactivate an object from that event but only if the left button is clicked
Also, when I call a method on that click event and use Input.GetMouseButtonDown(0) the condition still read as true when I click the right mouse button, so I can't seem to return early. Is there utterly no distinction between different mouse buttons in the "on pointer down" event?
That seems ridiculous so I must be missing something
Why would Input.GetMouseButtonDown(0) return true on right click?? It works completely normally in every other use case but this one?
The PointerEventData parameter has that information
Much thanks!
I added it as a parameter and now I can't call the method from another object's event trigger
It should have been a parameter in the first place
And it comes from the event
Well actually EventTrigger uses BaseEventData
You need to cast it to PointerEventData
You also need to properly assign it in the EventTrigger inspector with the dynamic parameter
The problem is that I'm trying to trigger the player inventory object to disable, but that object doesn't have it's own raycast target, so I was sending a message from a background object, which does have a raycast target, to the ScreenGroup class attached to the inventory screen group.
So I was specifying the object and method to target, then I tried using IPointerDown handler and it made every UI element in the inventory object close the inventory instead of only the background bc every child counts as the parent's raycast target
I need to deactivate the parent of the background object when it's clicked, or somehow stop or allow only specific children from triggering the inventory screen group's event
Or I could just quit with the event system and just create a new class for the screen background objects
Hi, I need help! I'm implementing mobile-support for my camera controller but these scripts for some reason do not support multitouch.
I want to make it so that touching the touchpad with another finger "overrides" the input but the input stays on the other finger that touched first which isn't really "multitouch-worthy"
If you want to see what I mean please test my prototype https://drive.google.com/file/d/134HDj5Z_gMCwcr8to8yyhJhW_iU68kTR/view?usp=drivesdk
How to reproduce the problem:
- Use your first finger to touch the dedicated touchpad that covers the entire right side of the screen (this works)
- Use your second finger to again, touch the touchpad, but this in any way does not add nor override to the input created by your first finger
Why this is an issue - players are going to have unique and intricate button layouts, and there will be moments where they'll touch buttons on the right side and then attempt to aim using multiple fingers, however with the current issue I'm facing this will not work as intended. The "aim" input will simultaneously overlap with the button input and using another finger in an attempt to aim on another spot of the touchpad will not work.
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.
My DuakShock4 is being detected as both DualShock4GamepadHID and XInputControllerWindows, which leads to having all inputs being doubled and being interpreted as 2 different kinds of gamepads. Other people who tested the build had the same problem. Unity version: 2022.2.0f1, Input System 1.4.4. The problem also seems to appear on Unity Version 2022.3.2f1 and Input System 1.6.1. Any ideas on what to do to get rid of the wrong gamepad detection?
Hi I was coding the initial stuffs like player input and after some test I've been wondering if someone knows the default speed
Wdym by default speed?
transform.Translate(Vector3.right * Time.deltaTime * rightInput);
It moves kinda slow for what I'm planning and I was wondering how many units the charcater/player makes per second
Depends where you got rightInput from but if it's joystick or keyboard input for example it's between -1 and 1
You're typically expected to multiply your own speed variable in.
Typically everything will be normalized to 0-1
So I guess the answer to your question is 1
rightInput = Input.GetAxis("Horizontal")
got it now ty
Can I get the raw mouse vector2 input in the new input system?
Went through your code, I would suggest using canvasses and implementing joysticks using IPointerDown/Up/Drag behaviors instead of handling touch-GO identification via raycasts and delta measurements manually.
Yep
does anyone know how to get the left joystick from a 3ds in unity 5.6.5f1? im trying to remake a game for the 3ds but i just cant get access to the joystick.
Does someone know how to move the Canvas so the mobile screen can move with drag detection?
When using drag detection it need to move over the gridmanager, but the 3 black boxes need to stay at the same place
hi, i heard the new input system has or had performance problems with quest. Do you know if that's true, or if so, if something was fixed there?
I have a button that calls StartRebind in this code when clicked: https://hatebin.com/jriszvprqj
but I get the following error when trying to re-enable the inputAction:
I'm on version 1.6.1
HELP PLEASE: I want to simulate xr controller grip button press using new input system. Found out InputSystrm.QueueEvent(); can do it but i couldn't figure it out how to use this.
down here
The issue was in saving and loading the keybinds, changing calls to ToJson and LoadFromJson into the methods using input overrides fixed it
Hello, when I connect my ps4 controller with USB all my commands works,
But when I connect it with bluetooth I can’t moove with y axis
Someone can help me please ?
It might be a controller issue
Question:
1: How do I rebind Composite Buttons? For example, I'd like the player to be able bind either DPad or Left Trigger, depending on what they prefer in my rebind options. (Or WASD)
My current code is as follows:
public class RebindKey : MonoBehaviour {
public GameObject rebindPrompt;
public InputActionReference inputReference;
private InputActionRebindingExtensions.RebindingOperation rebindingOperation;
public string exclude;
public string bindingGroup;
public void DoRebind() {
rebindPrompt.SetActive(true);
rebindingOperation = inputReference.action.PerformInteractiveRebinding()
.WithControlsExcluding(exclude)
.WithCancelingThrough("<Keyboard>/escape")
.OnMatchWaitForAnother(0.5f)
.OnCancel(operation => SaveRebind())
.OnComplete(operation => SaveRebind())
.Start();
}
public void SaveRebind() {
rebindingOperation.Dispose();
rebindPrompt.SetActive(false);
}
}
I'm also wondering:
2: How can I go about allowing for two inputs to one keybind via rebinding? I tried increasing the OnMatchWaitForAnother but that didn't seem to work.
I explicitly indicate whether the rebound input is a composite in the rebinding script
https://github.com/jngo102/unity-gametemplate/blob/main/Assets/Scripts/UI/RebindUI.cs
not sure about multiple bindings though
Is it possible to do create custom bindings? Lets say I would want for keyboard and mouse have direction from center of screen to mouse cursor for a vec2 input for a Action.
What is the correct action type/value/binding for detecting the pressure value of a shoulder/trigger?
as in these things 🤔 unless I am mistaken and they're binary pushed/notpushed
the word 'Trigger' is used a lot for unrelated stuff like events so I am not finding the info I want online 🤔
Axis - Left Trigger perhaps?
I'm trying to enable the canceling of changing a Keybinding via
.WithCancelingThrough("*/{Cancel}")
However, even after rebinding Cancel to be Select on the controller, B still works...
Has anyone else ran into this isuse?
The end goal here is to hopefully have Select and Escape be Cancel buttons.
Make if an axis not a button
Hey guys, I have a few questions about the new input system. I am trying create a rebind system that can allow for both primary and secondary/alternate input as well as bindings that allow for modifier keys such as: <shift> + <key> or <control> + <key>. I was wondering if it is possible to achieve these features with the new input system and if so, how would I go about adding them?
For reference, I am trying to get something similar to this:
To start, I assume you have this configured in your input settings?
low priority visual question, is there a way to re-arrange the events list so L and R are side by side? R got added later
that's odd 🤔 Interesting that the order on the left is not being used. Maybe check the asset file yaml and see if you can rearrange it yourself? (take a backup first 😉 )
Yep, I have the map configured for that
In that case, you want to just configure it similar to that of a Composite (So the same way you can modify WASD for movement to YGHJ) and things should just work. I just tested it myself.
Thanks for the link 🙂
Do they have to be composite as I would like separate bindings for each action? For example:
Action primary secondary
Up <W> <Up Arrow>
Down <S> <Down Arrow>
Left <A> <Left Arrow>
Right <D> <Right Arrow>
Unity's tutorials tend to have one button/field for all mappings but I would like to separate them like above, would I still use composite bindings or would I define a primary and secondary map for each action?
Right so I'm just referring to the modifiers (Shift + Ctrl / Key) combo. Those are Composites still.
As for having a Secondary Map, you would just reference the actions other index instead.
So if you take a look at this screenshot:
action.bindings[0] would point to LeftStick
action.bindings[1] would point to the Comp of Kebyoard-Movement.
action.bindings[2] would point towards "UP"
action.bindings[6] would point towards Keyboard-MovementAlt
Ah, thank you. This is what I've been looking for 🙂
I'm just figuring it out myself. You can do a recursive check in the OnComplete which will allow you to step over all the comp keys as well, so you dont have to have a rebind button for each indvidual key.
private void PerformRebinding(InputAction inAction, int inCurrentBindingIndex) {
//Update display text
rebindingOperation = inAction.PerformInteractiveRebinding()
.WithCancelingThrough("<Keyboard>/escape")
.WithTargetBinding(inCurrentBindingIndex)
.OnMatchWaitForAnother(0.1f)
.OnCancel(operation => OnCancel())
.OnComplete(operation => OnComplete(inAction, inCurrentBindingIndex))
.Start();
}
private void OnComplete(InputAction inAction, int inCurrentBindingIndex) {
rebindingOperation.Dispose();
inCurrentBindingIndex++;
if (inCurrentBindingIndex < inAction.bindings.Count && inAction.bindings[inCurrentBindingIndex].isPartOfComposite) {
PerformRebinding(inAction, inCurrentBindingIndex);
} else {
rebindPrompt.SetActive(false);
}
}
Thanks a lot for the code snippet
Quick follow up question, how would you go about prompting the user if they try to bind a duplicate key or overriding the key. For example, if the player tries to bind "<W>" to another action then it will set "Up" to <unbound>?
Haven't figured that out yet tbh.
And truth be told, I'll probably just let the user have duplicate inputs. Personally, I hate games that stop users from doing that. I understand, maybe complications/issues but yeah lol
I saw it somewhere in the docs tho, so I know its possible to check.
I guess logically, OnComplete you could step through all actions and all bindings, and if it matches with what you just set, you just null it out.
At least thats what I'd probably do.
When creating the rebind functionality, it seems that the UI is tighly coupled to the rebind system in most examples. As someone who is venturing into UI Toolkit, is there a way to apply separation of concerns between the rebind functionality and the UI itself? I was thinking of maybe using events on the rebind system but was wondering if anyone has some examples on how to keep the UI separate from the rebinding logic?
When I use Input.GetAxis(), it doesnt go 0, -1, 1, it fades. Can I change this?
I want it to only equal 0, -1 and 1
Use GetAxisRaw
Now it just doesnt work
define "it doesn't work"
The value of Input.GetAxisRaw() for the horizontal and vertical axis stays at 0
Then you are not inputting anything. Explain what you're doing, show the code, and show how you're checking the values
void Update()
{
float x_axis_keys = Input.GetAxisRaw("Horizontal");
float z_axis_keys = Input.GetAxisRaw("Vertical");
Debug.Log(x_axis_keys);
Wishdir = tr.forward * z_axis_keys + tr.right * x_axis_keys;
//Normalize wishdir
float len = Mathf.Sqrt(Wishdir.x * Wishdir.x + Wishdir.z * Wishdir.z);
if(len == 0)
{
Wishdir = new Vector3(0, 0, 0);
}
else
{
Wishdir /= len;
}
tr.position += Wishdir * Time.deltaTime * MoveSpeed;
}
Just the update method
I log the value to the console
and
show your console window
it might rather be in the inputSystem package 1.6.1
just tried the 2022 lts editor and it's the same thing (with the same error)
and the inputSystem package 1.5.1 yield the same error (and UI weirdness)
Anyone have opinions and experiences on rewired vs input system?
anyone else have a bug when making a control scheme and selecting the devices the left and right mouse button are switched?
i experience this too
i have an issue right now with these control schemes it seems like for some reason left and right mouse clicks are switched around
I noticed more UI bugs with the inspector too
I don't know what they did but a lot of stuff from the UI seems to be changed and it has quite a few bugs still
I am having a problem with the input system and analog stick controllers. It stops calling the event if the value didn't change from the previous frame and I don't know why
is there something in here I need to change to fix this?
The vec2 value is being used to move a mesh but the mesh stutters and freezes constantly, but only when the I keep the analog stick completely still
that's how it works
performed will only be called when the value changes and is not 0
if you want to do something every frame don't use events, use Update
event-based input handling is better for a "button" style input, not for continuous input like movement
you can also just save the input value to a variable and keep using it in Update
either way you shouldn't be doing the movement itself in the input event handler
I used events in another project and this worked fine and since I don't have the option to make this ONE thing not use the invoke unity events bit, Ill try storing the vec2 like you said
Does this look right to you? 🤔
it's very standard to do something like:
Vector2 input;
void OnMove(InputAction.CallbackContext ctx) {
input = context.ReadValue<Vector2>();
}
void Update() {
transform.Translate(input * Time.deltaTime);
}```
I would just do:
inputDiection = context.ReadValue<Vector2>();``` and delete everything else
right now you're ignoring the performed phase
which is... most of the events you will get
hm okay, I put started/canceled in there because button presses fire when pushed AND when unpushed if you don't, but this isnt a button its an analog stick right 🤔
mhmm
in all 3 phases (canceled, started, performed) you will get new vector values
started is only going to happen when you go from the zero state to a nonzero state
and vice versa for canceled
performed you will get whenever there is any new value (you tilt the stick to any new nonzero position)
overall - you don't care about the phase
you really just care about the current direction of the stick
so this is the only code you need
That did the trick, thanks for clearing that up!
How/where can I register my InputProcessor to be able to use my InputActions on the OnCreate of a System (DOTS)?
Seems like systems are created before RuntimeInitializeLoadType.BeforeSceneLoad
As of right I am using Gamepad.current to figure out which controller the user is using (EG: Xbox/Playstation/etc) however if I have two controllers plugged into my computer, Gamepad.current will return the first active one? I believe. EG: Using playstation controller to move, however Gamepad.current is returning xbox.
Whats the best way to go about fix this?
Also I'm trying to cancel a rebind with the following:
.WithCancelingThrough("*/{Cancel}");
However, I'd like it to use Custom controls for the cancel, and not the default B button and Esc.
I tried the following:
.WithCancelingThrough("*/{CancelRebind}");
where I set a rebind, however, that doesn't seem to work.
Thoughts?
Hey so i have a little Problem, if i write something with Input.touches it doesnt do it. Anything that has this in it for ex. Debug.log it, it doesnt do it and i didnt find anything about it(for mobile android)
make sure your package is up to date
i remember someone else pointing out a typo in the source that was breaking that menu
I have been with this like 2 hours and still no solution... Two players must be connected with a shared keyboard and have different UIs for navigation. I have tried to subscribe to the move callback of the UIINputModule to handle some logic but the event is received for both players! I have tried tons of other stuff and nothing has still yet worked.. I can't also seem to get how to use the NavigationEvents from the MultiplayerEventSystem
//This event is called when keyboard is pressed and not when the correct player pressed a
input.move.action.performed += OnMove;
I have already done this :(
You should try using the PLayerInput component like in the example from the forum post
you also need to make sure you have multiple control schemes set up
Yes! Totally set up!
In fact, the buttons do move separately. The problem is when using the move.action.performed callback
That callback is shared
But the navigation and the buttons are separated
That's the strangest part
Would you like some more images so you can see better the problem?
but it looks like you're not using playerinput
you're using the generated C# class
I don't know that it supports control schemes that way
Just because chat is boppin today. I'm still trying to figure out a good solution to this.
I set player input when instantiating the InputSystemUIInputModule
you're confusing your input action asset with the actual PlayerInput component
:( But it0s not the actual asset it's the instantiated PlayerInput from when a player joins a game
I'm not sure how to use control schemes outside the context of the PlayerInput component
this code implies you are using hte generated class
how else would you have the names input.move
why access it through the input module?
that's pointing at the asset file
not at the instance from the PlayerInput
access it through your playerinput
myPlayerInput.actions["UI/Move"].performed += OnMove;```
Okay with that it is working thanks so much ^^ But it feels honestly quite off :( I feel like it's just better to handle UI with UI events and triggers and not with Input on itself
Also it's still strange to me why th InputSystemUIModule class on itself succesfully separates both players but not when using the same callback through code
It's unclear to me why you're manually setting up this OnMove listener
why are you doing that
because at runtime it creates the MultiplayerEventSystem which actually uses your instantiated input action assets for the input module and not the shared asset file like how you had it here
I need to setup some events specifically for each player when they select a new button
So a new button is shown correctly
Why not use OnSelect on the button? Or ISelectHandler
I need to know the direction of the input, basically it's a customization menu where they can select multiple customizables
A bit like mario kart vehicle select
To do what with? Don't you get that behavior automatically with UI navigation?
Wait, are there scroll menus for that 🤡 ?
New Input System in Unity 2019.
Multiplayer UI Tutorial ment to be played with several Joysticks (gamepads) in Local.
Documentation: https://docs.unity3d.com/Packages/com.unity.inputsystem@0.9/manual/QuickStartGuide.html
I FOUND THE ERROR MAN
I'm dumb AF
This was not set, it was the control scheme
Not it works as it should
OMFG
I didn't save it last time
And it got lost
Please what are the name of d-pad buttons in the old input system ? Because i don’t understand what it is said on this image
it's the 7th and 8th joystick axis
you'd have to set up an axis for it in the input manager
But i don’t want to use them for movements, i want for them example that the up button open the menu and that the down button give healph
what does that have to do with anything I said?
there's nothing forcing you to use the input for any specific purpose
The axis are for movements ?
^
I need to enter a button name in the imput manager to use them,
Pick whatever name you want
No i can’t it desapear if it is not the good name
For example on the ps4 controller the x button is named joystick button 1, but i don’t now the name of d-pad buttons
what?
refer to the diagram
pick the axis
that's all
I put nothing in positive button and negative button ?
is there a way to multiply the thumbstick x and y values? for an example: when thumbstick value is 0.5, then i will multiply it by 2x so it will be 1
Use * to multiply numbers in C#
ok, but how do i access the thumbstick values in code?
surely you're already accessing them?
Or you wouldn't be able to read the data at all
Also I guess you could use the Scale processor if you really want the input system to do it for you
seems silly though
the thumbstick movement is still ultra slow (even thought i set the scale to a ridiculously big number), while moving with mouse works fine.
you shouldn't be scaling the input
you should simply have some kind of sensitivity/speed variable in your look/move script
show your code
wait a second
- You should never multiply mouse input by deltaTime
- your mouse sensitivity variable already exists, just set it in the inspector
definitely delete the input scale processor
ok
i set the mouse sensitivity variable in inspector
now my mouse is ultra fast (i need to set the sensivity to 0.1 to make it usable) and controller is like 5x times slower than my mouse
you can't/shouldn't really bind mouse delta to the same input action as joysticks. They don't really work the same way
mouse sensitivity like that is expected especially if you have a high dpi mouse
ok
how about now? i created different actions for mouse and controller
now my mouse isn't doing anything
because you're ignoring it completely now
the first line is overwritten by the second line
should i create 2 scripts? first for mouse, second for controller
you probably would want two different sensitivity settings
basically you're doing:
int x = 6;
x = 5;``` and then saying "why isn't x 6?"
I'm in the process of creating a category system for my crafting UI but I don't know how to do it so that, for example, when I click on the Weapon category it shows me the recipes that have the Weapon enum selected on their scriptableobject.
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.
make some kind of "ItemLibrary" scriptable object. Assign everything all your items to that library. Have your UI code reference the library and search the items
the problem is that I can't see how to do it in terms of code
which part
asign the recipe to a category
that the SO for the recipe
now it has to put the recipe in the right category
IEnumerable<RecipeData> weaponRecipes = allRecipes.Where(r => r.category == Category.Weapon);```
what do you mean?
it's already in the category
sorry it's the wrong channel
but how do I introduce it into this code because it creates the recipe
jsut ccheck if the category of the recipe matches the desired category
e..g if (availableRecipes[i].category != currentlySHownCategory) continue;
just a simple if statement
or better yet
get only the correct recipes (as I showed above) and do the loop only on those
so thahts ?
you obviously don't want to add it to the list of displayed recipes before that check...
also it doesn't really look to me like your code editor is configured properly
yes
I defined a "keydown" action and assigned an "Any Key" binding. Is there a way to read which key was pressed? Should I use a different binding? Is there a way to do it without defining 26 actions for each key? I'd just like to get the pressed letter as a string if it's an alphanumeric for example?
brilliant thank you!
is there any way to get vector2 (i guess) values on touchpad?
I can access clicks using this Debug.Log(DualShockGamepad.current.touchpadButton.ReadValue());
thank you
i can't for the life of me figure out how to use the right stick on my gamepad in the new input system
i have a "Move" and "Look" input actions. using "Left Stick [Gamepad]" works fine for Move, but using "Right Stick [Gamepad]" for Look doesn't.
i've tried with both xinput and directinput. neither works.
i've found some posts on the unity forums but niether was answered.
nevermind! i'm just still getting used to the messaging system, where you only get an update when the input state changes 😅
I can Rebind every key on my keyboard but i cant rebind the keys
a,c,r,l im on version 2021.2.14f1
this is the code i use any idea?
How can i change the Horizontal and Vertical inputs from player prefrences without making a custom
input axis system
in code obv
change them how?
instead of W for forward havew G
The legacy Input Manager doesn't support runtime rebinding. You either:
- Make your own system using KeyCodes or something along those lines
- Use Unity's new input system which does support runtime rebinding
- Use a third party input library like Rewired
- Build your own system from the ground up using Raw OS level input handling.
Hey, do you by any chance still have that code? I wrote my own interaction script which does just that but it keeps stopping receiving Process calls when the button is held still, here's what I have 👀
public class RepeatWhenHeldInteraction : IInputInteraction
{
public float repeatInterval = 0.2f;
private double lastRepeatTime;
public void Process(ref InputInteractionContext context)
{
if (context.ControlIsActuated())
{
if (!context.isStarted)
{
lastRepeatTime = context.time;
context.PerformedAndStayStarted();
}
else if (context.time - lastRepeatTime >= repeatInterval)
{
lastRepeatTime += repeatInterval;
context.PerformedAndStayStarted();
}
}
else
{
context.Canceled();
}
}
public void Reset()
{
}
}
I don't actually know if it's a problem with this exact script or some Input System setting that cuts off the updating of the interaction
oh, I found some code on github and they subscribe to InputSystem.onAfterUpdate, that might solve the problem 🙂
I built my own i was asking if i could use unity's for runtime rebinding, but what is unity's new input system btw
it's a new input system with features like runtime rebinding among other things.
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.6/manual/index.html
still having some issues with the input system. i have a camera object and a player object, both with a Player Input component.
i think the issue is having multiple Player Input components?
i thought maybe having two action maps would fix it
you need to explain what the issue is
oh yeah. sometimes input just stops working for one object. but reducing the number of objects with the player input component to one, the issue stops.
ive just begun porting my own input manager from C++. i like the way the new unity input system abstracts stuff, but its pretty confusing to get working properly. 😦
The PlayerInput component is supposed to represent a real life physical person
It should be one PlayerInput per person
and basically PlayerInput is going to pick one input device/control scheme and claim it
so if there's more PlayerInputs than devices matching a control scheme, generally the excess PIs are not going to work
how can i just use the action map and actions abstraction with messages, without having the physical player thing?
i'd like to be able to use my input settings profile with callbacks like OnMove(), without having all the physical player restriction stuff.
I guess build a new middle layer that uses SendMessage?
IDK why you would want that though, the messaging approach is inflexible
less work, i suppose
but building a middle layer for that is even more work
i'll just use the legacy input system
I recommend using the generated C# class: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.6/manual/ActionAssets.html#auto-generating-script-code-for-actions
And just implementing the interface it generates
and subscribing your class to it
definitely wouldn't recommend the old system
i see. thanks
yeah, the legacy input system feels very antiquated, but it's what i'm used to.
the link I gave above actually has a code example of the interface SetCallbacks approach which is what I'm recommending
the input manager i wrote for a separate project just has a map of strings to action structs, containing lists of things like keys, mouse buttons, and gamepad inputs that are considered to be part of that action. then you could get inputs either by float or bool with GetFloat()and GetDown()/GetPressed()/GetReleased(). it works nice, but isn't very flexible for more complex games. i might port over the system to unity eventually before i release my game.
Hello. Anytime I start a new 2D project and create a simple script to move the player left and right along the x axis, once I play the scene the player object automatically moves to the left of the screen. I an barely resist it using the D key. It's doing that in all of my projects. I've tried using transform to move, applying force to 2D rigidbody attached to the player object. I've deleted and reinstalled Unity. I've just started with Unity and I'm losing hope.
What does your move function look like? Do you have a check in place so it only moves on a key press?
When I connect a DUALSHOCK4 controller, two controllers are registered, a DUALSHOCK4 and a XinpurController.
Is this a bug in Unity?
What can I do to resolve this?
The version of Unity I am using is 2022.3.0 and the version of InputSystem is 1.5.1.
public bool PlayerJumped()
{
return playerControls.Player.Jump.triggered;
}
Always returns false even when pressing the key binded to the action
Okay so didn't get .triggered to work but I simply did
public float PlayerJumped()
{
return playerControls.Player.Jump.ReadValue<float>();
}
``` and just compare 0-1 (0 being not pressed, 1 being pressed) and got it to work that way
how do i check a certain key in the rebind operation progress
im doing this but the controlsExcluding is the problem
he also does the first letter ignoring. so how can i add them indicidually
ReadValueAsButton()
To get a bool
Jumping has little to do with the input system apart from just reading the button.
well, then why are you asking it in #🖱️┃input-system
Unity: Version 2021.3.4f1
Input System: Version 1.3.0
I've been randomly dealing with this issue in two projects now. Was just wondering if anyone else has a clue about why this is happening. I am using the default action map from Packages/Input System/InputSystem/Plugins/PlayerInput.
The error manifests upon pressing play in the editor as well as any time I turn off and back on the EventSystem game object and/or it's components in the inspector.
Another thing to mention is that is happens upon spawning a prefab with an EventSystem object within it. I've tried both spawning in Awake and Start, assuming Awake was just too early; however, neither changed the outcome of this issue.
I'm not sure if I can just update the Input System package because it is a dependency of the OpenXR Plugin 1.4.2 and I'm not sure if that will just cause me extra problems.
It also seems random when it happens. I can take the code from one project and put it into another and it works as expected.
I have also tried are deleting the library directory and rebuilding it. I have removed the OpenXR package and the input system package and added them back.
All 3 of these errors originate from my instantiation of my player prefab.
(Error messages will be posted in a second message because of the char limit. Sorry)
Nevermind.. I think I figured it out after stepping through the code a bit deeper. It seems to be caused by an issue with the WaveXR SDK. I'll dig deeper there and I'm sure I'll figure it out. Thanks anyways
Just going to document what the issue actually was:
I had WaveXR Plugin version 5.3.1-r.2 installed. Apparently HTC/Vive decided to mimic devices such as the wrist tracker even though they weren't in use so when it was parsing the bindings for those devices, they weren't found thus leading to the null references. Reverting to version 5.0.3-r.5 was my solution to this issue. This also explains why this was an issue for my newer projects and not the older ones.
#💻┃unity-talk for general questions and the answer is no
I am making a runtime key binder, and I made this code:
{
playerControls.Disable();
keybind.keybindText.text = "press a key";
rebindingOperation = keybind.action.action.PerformInteractiveRebinding()
.WithControlsExcluding("Mouse")
.OnMatchWaitForAnother(.1f)
.OnComplete(operation => finishRebind(keybind))
.Start();
}
void finishRebind(Keybind keybind)
{
playerControls.Enable();
rebindingOperation.Dispose();
keybind.keybindText.text = keybind.action.action.GetBindingDisplayString(0);
}```
The "Keybind" script holds some info like the bind text and the action that is being changed.
When this is ran, it shows that the binding has been changed by updating the text correctly, but the binding isnt applied. How would I do this?
Here's my function (I don't know how to put a check in place):
void FixedUpdate()
{
float horInput = Input.GetAxisRaw("Horizontal");
Vector3 newPos = transform.position + Vector3.right * horInput * _moveSpeed * Time.deltaTime;
_rb.MovePosition(newPos);
}
Then there is your answer. You need to check for when I'd is supposed to move.
A common and simple way is
If(horizontalInput)
{
Your code here
}
(Not exactly ofc, but thatd the idea. If you dont, it will just keep doing it since it's in an update function.
!code
📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
do anyone know how to normalize the axis value as i already add the processor but still its giving values in 0.
show how you have configured the action
you shouldn't use the normalize proocessor at all
what the normalize processor is meant to do is take a range like [-60, 60] and normalize it to the range of [-1, 1] for example
the action is the thing called "Horizontal"
If you want to get only -1, 0, or 1, you can do this:
float quantized = inputFloat == 0 ? 0 : Mathf.Sign(inputFloat);```
worked like a charm thanks for help @austere grotto
this should be mostly fine without an extra check, the value should be getting multiplied by zero when there's no input, so presumably either something is registering as input, there's an issue with the axis configuration (or your rigidbody is slightly to the right of the main transform lol - i think want to be using _rb.position not transform.position when calculating the new position!)
do you have a joystick or gamepad accidentally resting against your keyboard or something?
Do you guys know how I can make an equivalent to GetKeyDown() that only fires once you press and not when you release with the new input system?
for some reason it jumps when I press s or left button
and the groundslam never works
I have the right keybinds I think
I already removed the s key in the move so that's not it
before when I only had jump and no groundslam, character never jumps
but I added groundslam and it jumps when the groundslam is called
ah nvm all my questions
I didn't change the values
I'm trying to get the position of a touch on the screen, I have one main camera, and I've tried to use the viewport and screen position methods to convert the position, however the coordinates are never from 0 to 1 and never from 0 screen height/width. it's between 0 and 200 for some reason and it seems like the positioning is based on some other origin...
my code looks like this:
Vector2 position = touchPositionAction.ReadValue<Vector2>();
Debug.LogFormat("TouchPress ({0}x{1}): world {2}, screen {3}, viewport {4}", Camera.main.pixelWidth, Camera.main.pixelHeight, position, Camera.main.WorldToScreenPoint(position), Camera.main.WorldToViewportPoint(position));
/*
top-left: TouchPress (1080x1920): world (18.46, 1893.85), screen (4084.62, 364578.50, 10.00), viewport (3.78, 189.88, 10.00)
top-right: TouchPress (1080x1920): world (1064.62, 1893.85), screen (204946.20, 364578.50, 10.00), viewport (189.77, 189.88, 10.00)
bottom-right: TouchPress (1080x1920): world (1068.46, 20.77), screen (205684.60, 4947.68, 10.00), viewport (190.45, 2.58, 10.00)
bottom-left: TouchPress (1080x1920): world (456.62, 443.27), screen (88210.50, 86067.75, 10.00), viewport (81.68, 44.83, 10.00)
*/
You're using WorldToxxxPoint which expects a world point as the input
But touch input data is in screen space not world space
You should be using ScreenToXxxPoint
that fixed it thanks! 😄 one other part of the weirdness is that the 0,0 is the bottom-left edge of Unity when I'm running in the editor/simulator, is that expected? I may have found an answer for that one: https://gamedev.stackexchange.com/questions/88504/camera-bounds-grow-along-with-the-game-scene-editor-in-unity
You can check its context:
if (context.phase == InputActionPhase.Started)
Or you can check it inside of action:
if (inputActionReference.action.phase == InputActionPhase.Started)
You can also add press interaction setting to that binding (I haven't tested it tho):
Hi there!
Has anyone here used the Stadia Controller (Bluetooth mode) with the Input System 1.4.4 and Unity 2021.11f1? It detects the input under the input debugger, but it's not listening to events, either in the game or in the input controller setup ...
Obviously everything works with the Xbox gamepad or arcade stick ...
Hi. Does anyone know how to use both the keyboard and a joystick at the same time please? I can't manage to make it work without everything just breaking and lagging and I don't know what I doing wrong😅
What is the difference between AddCallbacks vs SetCallbacks when using the auto-generated input actions class?
It looks like set unregisters any existing callbacks and then adds the new callbacks?
That would seem logical. Peek at the code and see?
What does the Restart function do
Hi, I'm using the first person controller of the Unity Starter Pack. I have the pproblem that when I move the mouse just a little bit its not detected. Does anyone else had the probkem before?
Hi I would like to make the "shooting" part of the InputSystem. The plan is that as long as you press this buttons (Mouse0) the Shoot() will be triggered
With Input.GetMouseButton(0) I would achieve exactly that but would need something to make it dynamic for different systems
is there an equivalent way in the input system?
I don't know if this is the right way but I have done it with two inputs
And its in the Update function?
yes
previous solution was with Events if Input.Player.Shoot.performed but this method call seems nicer
just have to change the IsShootButtonPressed inputs to the inputsystem then it should be smooth enough xD
just realized instead of .performed I could probably add .IsPressed, maybe then you don't need the Hold Interaction
I think both methodes are okey. I just didn't want it to be in Update
that's fine. I want to fire while holding the button, how would you do it if not in update
I have done it with performed
oh okay you made an extra Realease method, that sounds cool
Anyone else had an issue when installing input system and Unity asks if you want to enable it?
it says that it will "RESTART" Unity and "ENABLE" new input system.
It never actually restarts it, it closes the project and I have to manually open it again ;]
How do I setup a joystick for mobile that moves the player?
or you touch the right side to make the player go to the right and the same goes with left side
How'd I do that?
Getting "Cannot find action map 'oldActionMapName' in actions 'actionsName'" after renaming the action group (using new input system).
Pretty sure its a unity bug. How I can fix it?
It disappears if I create empty oldActionMapName, but I don't want to have one.
Look at the stack trace of the error to see where it's coming from
You have a component or script somewhere using it
Maybe your input module perhaps
Help me in adding game controller.
Please.
If you're looking to add game controller support to your game then follow a tutorial, there's one for the new input system pinned to this channel
Using the Input System: https://learn.unity.com/project/using-the-input-system-in-unity
You will have to put in the effort to learn nobody is going to help you if you haven't shown any indication you've tried
Just jumped in. your issue is to use control schemes or what exactly?
Can anyone help me i keep getting a error saying The type name OnFootActions does not exxist in type PlayerInput
I guess this explains it best: https://hal-brooks.medium.com/unity-input-system-control-schemes-bba9f9dad790
Objective: Create a keyboard and Xbox controller scheme for input actions.
Can anyone help me i keep getting a error saying The type name OnFootActions does not exist in type PlayerInput
Wait, is your visual studio not crying about PlayerInput.OnFootActions? Because you only have OnFoot as far as I can see
Did you set it up correctly?
If your IDE is not autocompleting code
or underlining errors, please configure it:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code*
• JetBrains Rider
• Other/None
*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.
So it shows you whats wrong and suggests what might be right
Hi. Does anyone know how could I add processors at runtime please? Like for the player to be able to for example change the axis deadzone at runtime. Thanks
Is there a way to get wasPressedThisFrame for actions? I don't want to hardcode Mouse.current.leftButton, and I want to get a true value when the button was pressed, and false the next frame, but if I use performed, I get true when the mouse button is being held too
Yes Input action has a WasPressedThisFrame() function
🤦♂️ thanks so much, idk why I didn't see it
I keep having this `Unable to find style "ToolbarSearchTextField" in skin 'DarkSkin' Used" error. I tried looking it up but all I found was someone's thread where their post was downvoted and someone said "it's a bug that's already been fixed"
I just added the new input system and I've never used it before so Im not sure how to fix this
It seems to prevent me from adding my control scheme, whenever I try to add it I can create it but I can't add any devices to it
I tried going into the file, tried clearing it, figured it was just some dumb GUI error that shouldn't matter but it's not going away 
okay well apparently to add devices I have to right-click? that's weird but sure-
if anyone knows how to get rid of that error I'd still appreciate it, otherwise I'll just clear it and hope it nevers come up again 
Hi guys! How to detect if said path is a special character?
I like the old input system
I have experienced this bug too i think it’s on unity’s end best to submit it as a bug so they see it quicker, with the 2022 lts i have seen a few annoying bugs like this lately
In 2021 it is not happening, another bug in 2022 is the inspector breaking randomly like randomly a part of the variables that are normally visible in the inspector are not and you see an error related to this
I'm trying to add a Roll mechanic, on keyboard if a key is double tapped it'll alter the player's position. Is there a way to access something like, "if input value is (the key associated with) Roll X Positive"?
Since the player could rebind it, I want it to be "on roll, if the key is Roll X Positive, then add to position.x" instead of "if player double taps D key"
Im just not sure how to do the syntax for accessing "the key associated with Roll[X/Y], [Positive/Negative]
wdym by "angles"?
angles of what
do you mean the 2D input vectors from your joysticks?
thank u its fine it works now
why is it that it only shoots onces and acts like a button even tho its set to pass through and any in the input actions
When I use debug my InputHandler shows the proper values when running. But if I don't use debug and I instead make the values visible an alterative way they either don't update or lag behind until I click on the inspector window
public class InputHandler : MonoBehaviour, GameInput.IPlayerActions
{
private GameInput _inputActions;
[ShowNonSerializedField] private Vector2 _moveAxis;
public Vector2 MoveAxis => _moveAxis;
private void Awake()
{
if (_inputActions != null) return;
_inputActions = new GameInput();
_inputActions.Player.Enable();
_inputActions.Player.SetCallbacks(this);
}
public void OnMovement(InputAction.CallbackContext context)
{
_moveAxis = context.ReadValue<Vector2>();
}
}
hm the input system is driving me crazy...
maybe some one has an advice for this problem:
i have assigned an axis to an action, but when ever i reach -1.0f the InputActionPhase is switching to Canceled, which is probably ok, but the value returned by context.ReadValue is 0.0f!
any idea how to change that ?
seemed to work once i divided the axis in a positive and negative combined action, but with a single value type action the axis is not working as expected
In InputActionState during Phase change ( to canceled ) the trigger maginutude becomes 0.0 btw, i would expect 1.0 there..
only difference i could spot is that the raw memory for that axis becomes 0x 00 00 for -1.0 compared to an xbox controller, which stays at 0x 00 80 for -1.0
before the InputActionPhase switches to Canceled:
cancel event, even tho the xbox controller never generated any new event:
and with disconnected xbox controller, ( axis should be at -1.0 as the other device is still connected ):
[InputControl(name = "leftStick", format = "VEC2", layout = "Stick", displayName = "Left Stick", shortDisplayName = "LStick")]
[InputControl(name = "leftStick/y", format = "USHT", layout = "Axis",
parameters = "normalize,normalizeMin=0.0,normalizeMax=0.03123522,normalizeZero=0.01561761",
offset = 0)]
[InputControl(name = "leftStick/x", format = "USHT", layout = "Axis",
parameters = "normalize,normalizeMin=0.0,normalizeMax=0.03123522,normalizeZero=0.01561761",
offset = 2)]
[InputControl(name = "leftStick/up", format = "USHT",
parameters = "normalize,normalizeMin=0.0,normalizeMax=0.03123522,normalizeZero=0.01561761,clamp,clampMin=0.01561761,clampMax=0.03123522",
offset = 2)]
[InputControl(name = "leftStick/down", format = "USHT",
parameters = "normalize,normalizeMin=0.0,normalizeMax=0.03123522,normalizeZero=0.01561761,clamp,clampMin=0.0,clampMax=0.01561761,invert",
offset = 2)]
[InputControl(name = "leftStick/left", format = "USHT",
parameters = "normalize,normalizeMin=0.0,normalizeMax=0.03123522,normalizeZero=0.01561761,clamp,clampMin=0.0,clampMax=0.01561761,invert",
offset = 0)]
[InputControl(name = "leftStick/right", format = "USHT",
parameters = "normalize,normalizeMin=0.0,normalizeMax=0.03123522,normalizeZero=0.01561761,clamp,clampMin=0.01561761,clampMax=0.03123522",
offset = 0)]
[FieldOffset(8)] public ushort yLeft;
[FieldOffset(10)] public ushort xLeft;
the layout of the left stick for the custom HID.
I'm trying to add a dash to my game using the new input system. Here's my setup
When I run it, none of these debugs show at all, so clearly it's not even entering onDash() when I hit 'Q'. Enabling "Dashing" while playing does nothing either. This is my first time working with Coroutines so I might be wrong there
Besides the coroutine I don't see anything that could be causing me an issue, everything should be set up okay
Movement + Sprinting both work as well, I've tried dash while moving, while sprinting, while not moving, enabling Dashing from the inspector, changing the values, etc
I'll try plugging in a controller but I cant imagine that'll do anything different if it's not working at all already
OnDash != onDash ?
........hahahaha of course

thank you
I shouldve asked here earlier, that wouldve saved me a good hour lol
now lets hope someone can help me 😄
I'm a newbie to game programming but what's your issue? :D
(if you are in any channel besides code-beginner or code-general i will be unable to help lol)
asked my question here right before your's 😄
that problem has eaten already a few days from my sparetime
yeah I can relate 
Figuring out the input system stuff has taken days from me too 
and im like, nowhere near your level
yeah the package is nice and stuff, but sometimes does too much for my taste 😄
ok i think i found out what i am missing:
**defaultState **for the custom HID
question is now, what type should it be ?
hi, Are there any advantages to using the new Unity Input System? (ignoring the fact that it has an interface)
The advantages of using the new input system are that you get to use all of the features of the new input system
Maybe I don't know about them but as far as I can see it is only useful if I want to do multiple control mappings depending on what is connected (Joysticks, keyboards, pointers, etc)
The input system works even if you only want to use one control scheme
It would be really weird if it didn't
I already corrected the question, I made a mistake and changed this "it is only useful"
Multiple control schemes is only one of the many features of the new input system
Hey, can anyone help me out with a script problem i am having
alright, currently trying to follow a tutorial on making a simpla fps platform. I crated a script for movement and my guide tells me to make a c# script. When i try to open it, it goes to "vierw downloads". If i click it, it opens for a half second then closes
not sure why
I'm still trying to diagnose an issue with input actions:
- In the Event System for UI, the Input System lets me bind mouse click so clicking on UI buttons clicks things on UI.
- If I connect an InputActions asset to the Event System, and bind a button to left click, all is fine 👍 .
- If I go to the InputActions asset, and add interactions (ie Tap, Slow Tap, Hold), that binding no longer clicks the UI.
Q: Why? Or how do I get a button with interactions defined to still affect UI.
Why are you adding interactions
Or better yet - why are you using your own custom input actions asset for the input module
What's wrong with the default one
I wanted to have multiple bindings for non-mouse inputs, like gamepad button click
it just made sense to have it all centralized.
is there any best practise for binding axis of various devices ? i seem have trouble with some devices where the axis are non continuous, like the upper part (0-1) is actually the lower one (-1 - 0). so if one moves the axis from low to center to high the value is moving from 0 to 1 flipps to -1 and moves to 0 ...
Hey, I'm trying to get this "rotate Camera" input to work. I Want to rotate the camera with middle mouse (held down and dragged) to orbit around the characters XY axis. Having some difficulty understanding the setup
InvalidOperationException: Cannot read value of type 'Vector2' from control '/Mouse/middleButton' bound to action 'Player/RotateCamera[/Mouse/middleButton]' (control is a 'ButtonControl' with value type 'float')
You're doing .ReadValue<Vector2>() in code where you should be doing .ReadValue<float>(). A button is a single value, and as you have this under a 1D axis binding, it'll ever be 1 or 0 (for mouse button)
it sounds like i need to change the input type then since its a 0/1 only value?
Are you saying to alter the code? This is the cinemachines system not my own
The input type is correct, it's your code that's not right, read the error
Trying to read a vector2, when the input type is a float
i think im following, but also trying to communicate "what should i change and how." Should i change the player input setup or the class itself? If it's the class, then that'd be an issue since it may have features tethered to other things elsewhere. If it's the input, i can change it to a different type
The code, you need to change the code: #🖱️┃input-system message
so its impossible to use the default system to achieve a "mouse hold and drag to rotate"?
this system right here
Ah yeah that script is already provided by Cinemachine so you can't really edit it without breaking other stuff
So switch back the Input Actions Asset to what it was before (probably Mouse Delta), and you need to roll your own code for the hold action
See if you can extend the CinemachineInputProvider script by inheriting from it, to add your hold button
lmao, this becomes a code question again
yea im trying to avoid code in this instance
im fine with it in any other circumstance, just trying to see if the default input can handle it
It doesn't, it seems
Is anyone else not able to update to 1.6.1?
Im having trouble making unity recognize that i have inputsystem package. can anyone figure out how to fix this
try closing unity and then open it again
k
have u tried closing unity and then opening?
yes
whats the error code
what happens if you click quick fix
removes the 3 unused lines
using System.Collections;
using System.Collections.Generic;
using UnityEngine.InputSystem;
these three
show me the script
yes
what version
vscode is not supported by unity
install visual studio
not vscode
!ide
If your IDE is not autocompleting code
or underlining errors, please configure it:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code*
• JetBrains Rider
• Other/None
*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.
same issue
when you downloaded visual studio did you install the unity package? (inside of visual studio installer)
just wanna give a shoutout to the InputSystem developers!
there's been a few rough edges but overall switching to the system has been really pleasant
When binding weapon selectors like this is this usable?
or do i make a new actionmap for instance (Primary Weapon: 1) (Secondary Weapon: 2) etc.
Hello. I added new action map to unity for menu. Done everything like with my first action map, but now unity keeps giving me 'Object reference not set to an instance of an object error'. It seems to be caused by InputActions(controls) because changing action map does nothing. Here's script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
namespace Menu{
public class UniversalMenu : MonoBehaviour
{
Controls controls;
//unrelated stuff here
void Start()
{
controls = new Controls();
//unrelated stuff here
void OnEnable(){
//Line that causes problems:
controls.Menu.Enable();
}
void OnDisable(){
controls.Menu.Disable();
}
}}
Did I forget about something? Or does using second action map require something different?
is the file name called Controls?
Input Actions file is named controls
oo okay so i can reference if a player clicked on 1, 2, 3 seperately?
It won't work
Another bidings are for situation, when multiple keys do same thing
oo okay
For example arrow on keyboard and arrow on gamepad
You need action for every weapon
yes okay i fixed it thank you
what line does it give the error on?
oh, sorry, I forgot
controls.Menu.Enable();
you remove menu and just enable controls
wait actually nvm
did you generate a c# class with the input action?
and that c# class name is Controls?
yes
.
i know
how would I handle multiple GameObject requiring access to inputs via the c# wrapper? I started with creating an instance of the wrapper for each player object but ran into action conflicts when one player was performing an input and the other player was expecting the same performing input but on another device. I'm trying to avoid the PlayerInput/Manager component and trying to assign devices to players manually but I can't seem to detect multiple inputs happening even on different devices
If you're doing local multiplayer I highly recommend PlayerInputManager/PlayerInput
it was made specifically for this use case
if you don't use it you'll have to do the listening for devices yourself with e.g. https://docs.unity3d.com/Packages/com.unity.inputsystem@1.6/manual/Devices.html#monitoring-devices
I'll play around with both methods a bit and see which I end up preferring :) thanks for the links! that's very helpful
also, should I avoid creating multiple instances of the c# wrapper in different components (multiplayer aside)? just now thinking about UI components that may need access to input actions
I prefer to keep it to one instance as much as possible for the reason that it allows me to control certain behaviors globally by enabling/disabling action maps
that makes sense! are you accessing that instance directly or using some kind of event subscription system to broadcast actions?
I do different things in different projects. One convenient approach is to use the wrapper's generated action map interfaces and SetCallbacks/AddCallbacks functionality
In general I try to avoid writing boilerplate code that just duplicates the stuff in the wrapper already
So im trying to get input with the left mouse button but its not working for some reason am i doing everything correctly?
do not subscribe to the callback in Update
that should oinly be done in OnEnable or Start or something
as for why it's noit working in general you need to show the configuration of the Fire action itself
would it work in awake?
no because you're noit creating the PlayerControls object until Start right now
actually
this is brokjen right now
move the Start stuff to Awake
because your OnEnable is going to run before start currently
you SHOULD be seeing a NullReferenceException in your console right now
never ignore errors in your console
with this code
you didn't save
i did but i moved the event sub to awake method
and it worked
oh nvm it worked both ways its just unity bugging
oh but this is just click
i want the player to be able to hold
Update
is this correct?
It's not. You are subscribing to the Shoot method in every update.
You should do either in the OnEnable/awake/start
alright ill try it rn
wait okay this is a gun and im reading the left mouse btn i can still change the firerate right?
nvm im just being dumb
is there any reason the event gets called only once?
private void Awake()
{
List<object> keys = new();
InputAction move = new InputAction();
move.AddCompositeBinding("2DVector")
.With("Up", Keyboard.current.wKey.path)
.With("Down", Keyboard.current.sKey.path)
.With("Left", Keyboard.current.aKey.path)
.With("Right", Keyboard.current.dKey.path);
object obj = new Keybind("Move", move);
keys.Add(obj);
Keybinds.Init(keys);
Keybinds.GetKeybind("Move").performed += (ctx) => Debug.Log(ctx.performed);
}
Its from a player component using my custom keybinding system
what event
performed
Once per click
how many times would you expect?
Normally performed gets called on press and release
At least it does when i use an InputActionAsset
for a 2d vector like this performed will get called any time the value of the action changes to a novel non-zero value
so (0,0) -> (1,0) will trigger performed
also (1, 0) -> (1, 1)
but not (1, 0) -> (0,0)
that will trigger canceled
So this should work ?
public class Keybind
{
public string Name { get; private set; }
public InputAction Action { get; private set; }
public Keybind(string name, InputAction action)
{
Name = name;
SetAction(action);
}
public void SetAction(InputAction action)
{
if(Action != null)
{
Action.started -= OnPerformed;
Action.canceled -= OnPerformed;
}
Action = action;
Action.Enable();
Action.started += OnPerformed;
Action.canceled += OnPerformed;
}
public event Action<InputAction.CallbackContext> performed;
private void OnPerformed(InputAction.CallbackContext ctx)
{
performed.Invoke(ctx);
}
}
It does
Nvm it didn't update the value correctly with multiple keys input but i fixed it by replacing started with performed
Hello guys,
I want to implement a simple Touch (or Click) to make my character move somewhere. Currently, I'm using the performed callback of a simple Action Binding of type Button.
My problem is, if I start clicking somewhere, go really quickly somewhere else far away, then release, the Click is still registered and is done where my mouse currently is after I've moved a lot.
I want to prevent this behavior, I am curious to know if the tools in the New Input System allow me to do that, or do I need to script something to detect all of this?
If I have to script it, I'm pretty sure I know how to do it the old way, but I was curious if the new system provides built-in tools for that.
Thanks a lot!
I don't really understand, do you mean that it moves too when you release the mouse?
If that's the case just use ctx.performed or ctx.ReadValue() with an if statement
i wonder in
input system, do we really need to seperate InputAction event started and performed because it happend at the same time
private void OnEnable()
{
attack.started += Attack_started;
attack.performed += Attack_performed;
attack.canceled += Attack_canceled;
}
private void Attack_started(InputAction.CallbackContext obj)
{
// code
}
private void Attack_performed(InputAction.CallbackContext obj)
{
// code
}
private void Attack_canceled(InputAction.CallbackContext obj)
{
// code
}
I mean we can put the code of started and performed at the same function
private void OnEnable()
{
attack.performed += Attack_performed;
attack.canceled += Attack_canceled;
}
private void Attack_performed(InputAction.CallbackContext obj)
{
// code started
// code performed
}
private void Attack_canceled(InputAction.CallbackContext obj)
{
// code
}
Oh i realized if i map the WASD move it will call the started once and when i press other direction it will call performed once
Then the above question change to: if i have action that only map to 1 key (attack), do i really need to seperate started event and performed event
I fixed it thanks to help from user from other server
controls = new Controls() must be in Awake()
Hey people. I have an issue I was hoping one of you might be able to help with. I'm making a spaceship game that works with a joystick. It works great. However; the issue I have is when I have my steering wheel plugged into my PC as well as my joystick the game works with the steering wheel instead of the joystick and the joystick doesnt work at all. If I start the game with only the joystick plugged in it's fine but I'd rather not have to unplug the steering wheel every time I want to play the game. Is there someway to maybe choose what device the game uses if multiple control devices are plugged in?
Yes, if I click somewhere, move somewhere else really fast, and then release, it's registered where I released but I don't want that.
I also don't want to react to when it's Pressed, I want to keep the behavior on Release.
This doesn't happen if the movement is long and slow, only when things happen fast and the total time spent with the button down is very short.
Started and Performed is basically the same for simple one shot trigger button events, but it's not the same at all for other types of events.
FOr example, Hold event can be started but not Performed if released too soon, they will then be canceled.
Hello everyone, maybe someone has encountered this...
After updating from 2021.3.19 to 2021.3.20 there was a bug with jitter touch input, this bug is 100% reproduced after collapsing and expanding the game
I created a bug report and it was confirmed, please vote for it
https://issuetracker.unity3d.com/issues/android-intermittent-touch-input-starts-to-jitter-after-minimizing-and-restoring-the-app-when-built-on-android
Kind Regards
Reproduction steps: 1. Open the attached project "ReproProj" with the Android Platform selected 2. Build And Run on an Android devic...
For some reason whenever i use the left/right stick of a gamepad to change a Vector2 type value it only works when moving them left or right, while moving them up and down they straight up does not work, does anyone know why this is happening?
Keep in mind i face this issue in a build and not in the editor of my game.
you'd have to show your code
The problem is that i did some testing and by reassigning the up and down buttons to other keys the code worked just fine...
show your code and how you set up your input actions and bindings
For reference: when using it like this the Y value of the vector2 returned is always 0, however when i change the up and down bindings it returns the correct values
Using Unity 2022.3.4f1 with the latest "New Input System" version. Trying to make a "platform and device agnostic" way of controlling the cursor, which is represented as a sprite on a game object. For instance, pointers (mouse, touch, pen) track the pointer position whereas Joystick and Keyboard move the cursor object with Vector2 like you would a character controller.
I am testing on my PC (as that's the only system I have). I have the devices stored in a dictionary ranked by priority with gamepad being first in line above all else.
The system works great except that, if the gamepad is plugged in before I hit play, it won't register; but if I remove it and reconnect it, now it suddenly works. This is not ideal. I've made sure to do my calls in Start vs Awake. Has anyone else had a similar issue with the gamepad not registering properly?
Also, my player prefs for setting "user preferred device" aren't being saved between sessions. Here is the code I'm using. I don't think the issue lies in the other scripts associated with it (Cursor_Base, Pointer, NonPointer, and InputActions) as those all seem to be working properly from what I can tell.
I'm using the new input system and I have my EventSystem configured with the "Left Click" set to the Mouse Click action in the UI map. This Mouse Click action is a button with a binding where the Trigger Behavior is set to "Press Only" but when I click something in the UI, it's fired on press and on release. How can I make it so that is fired only on press?
- There is no reason to use the Press interaction.
- What's wrong with the default input actions asset for the input module?
also define "it" being fired. What exactly is firing?
1 - What should I use then?
2 - It was just to have everything in the same input action asset
3 - for example if I have a button with an on click listener, that method it's called on press and on release
- no interaction
- is there a benefit to that? The default one works flawlessly
- #1 should solve that but if not you can always look into how the click action is defined on the default input action asset
hello does anyone know how i can make a button for a mobile control when i click on the button that the "E" key should be pressed
you're thinking about it backwards
just make a function that is called both by the button and when you press the e key
how
how what
how can i do that
by making a function
and calling it when the player presses the E key
and calling it from the button
on-screen button?
e.g.
if (Input.GetKeyDown(KeyCode.E)) {
MyFunction();
}```
why does this not work?
because you put your input handling inside MyFunction instead of Update?
void Start()
{
yourButton.onClick.AddListener(MyFunction);
}
void Update()
{
if (Input.GetKeyDown(KeyCode.E))
{
MyFunction();
}
}
void MyFunction() {
print("Hello!");
}```
now it will print hello in my console
yes
ok?
this input script doesent work
in what way does it not work
BTW 90% of people in this server are new, it is expected
ohh okay
it doesent press E
what doens't press E
this script
you have to press E on your keyboard to press E
there is no way to press E from a script
no a button
I was explaining how to do what you want without pressing E
for mobile input
there is no way to press E from a button
tehre is no need to press E from a button
call the function that opens the door
Like this
open the door in MyFunction
the print("Hello") was just an example
you can do whatever you want in there
I wanted to ask does anyone know a good way to get the most recent active device using Unity's New Input system?
currently my code looks like this:
public static InputDevice LastUsedDevice { get; private set; }
static InputHelper()
{
// Set the initial device
if (Gamepad.current != null)
{
LastUsedDevice = Gamepad.current;
}
else if (Keyboard.current != null)
{
LastUsedDevice = Keyboard.current;
}
// Listen for device changes
InputSystem.onDeviceChange += (device, change) =>
{
if (change == InputDeviceChange.UsageChanged || change == InputDeviceChange.Added)
{
LastUsedDevice = device;
}
};
}
which works when a device is added etc and getting the inital device but if I have multiple devices connected such as having a contoller and keyboard both it will grab the gamepad and not the keyboard. I want to handle it so it assigns the device based on a button or key press. Is there any good way to accomplish this?
inside UnityEngine.InputSystem.Utilities there is InputSystem.onAnyButtonPress which you can use to catch pressed keys
The way i use it is InputSystem.onAnyButtonPress.Call(key => GetKey(key)); and GetKey is a method like that static void GetKey(InputControl key) then i can read the path tho i think there is a field specifying the device
Yeah key.device should return an InputDevice @novel fjord
hmm i'm trying to figure out how to get the call method to work?
i'm doing this: InputSystem.onAnyButtonPress.Call(GetKey);
but the issue is I need to subscribe not call it initally I want to set the value anytime it's called
Yeah it should just call it everytime you press a key on anything, at least it does in my project
Its getting late so i might not answer if you respond
I'm a little confused with more complex input system where other things at the same time should be enabling and disabling some inputs.
I.e. You have player movement input enabled at start.
The input can be disabled by inventory and map.
Then player opens up inventory ui so the ui forces to disabled.
On top of it opens map. There is no change in input since its already disabled.
Then it closes the map. The movement is enabled yet it shouldn't because the inventory is still on.
What I have done is in singleton with
public Dictionary<string, List<Component>> disallowed; string is an action ID.
I add every single component which disallows action. And refer with every steering component this the singleton.
It works yet, It feels like I am doing something wrong. Like I am skipping input system package in some way.
I was trying to search for this information yet everyone shows very basic cases with input system.
What's a good practice for this ?
I've been using the workflow suggested by the documentation to create an actions object on every class that needed to work with the input system. It was working fine until more complicated cases emerged - now we are doing control remapping, and that remapping seems to happen on a specific instance of the actions object. This means I will only rebind controls for one instance which of course is not correct, I want the change to propagate to the entire game.
What's the correct approach here? Should I be creating just one actions object for all classes to use? I'm confused.
Reuse one object yes
Generally I have one central "InputManager" singleton which manages the instance and access to it
The docs are not suggesting that workflow it's just a convenient way to show how the wrapper class works
thank you! would you be so kind and provide an example of how you implemented it?
I couldn't find that on the internet which is surprsiing coz it sounds like a very standard problem
I just described it
I'm on mobile
It's pretty simple
Just a singleton holding a property for the wrapper
Hello, I have a very beginner question. My game only requires a handful of inputs, so I removed a bunch of inputs from the Input Manager I didn't need. Now whenever I start my game, I get tons of error messages that I don't have certain buttons set up. Do I need to keep all the default inputs?
which "certain buttons" is it complaining about?
There are a bunch that are used by the input module for UI events, yes
The error messages are coming from a script called "BaseInput" but I'm not sure if it is nessesary or not.
Yeah that's your input module
I don't really see much of a tangible benefit to removing the default axes from the input manager
simplest to just restore them
Hey guys I'm a beginner to unity and am using control freaks for a mobile game I'm developing. I want to make it so different target axis for my CF2 Button are triggered based on the number of presses from the user. Is there any way I can make this happen? I'm using the Universal Fighting Engine 2 in my project and do not have access to the backend code that handles each button input. I'd really appreciate any sort of help I can get for this.
Hi, im trying to make a fighting game and im trying to make local multiplayer but with prefabs that have already been spawned and how would I be able to set which controller is player 1 and player 2? how can I do this? I tried using the player input manager but it only spawns the prefabs.
Hello,
I am using the legacy input system and I have the problem where I plug an xbox controller and the maping is one, but when I plug a PS5 or other controller model the mappings are all different.
When I use the Input Manager I have to define what each axis does but how can I flexibly adjust so it knows which axis it should be depending on the controller?
I appreciate any help.
the On-Screen Stick Script doesn't set the pivot correctly
it is only correct when the anchor is at the center
but anywhere else it seems bugged
this is lower left anchor
I can't get my movement to work.
I've set the project to the new system
I have a UI component with an onscreen stick component control path as AndroidJoystick. This works when I play (working = it moves with the mouse, and it gives values in the input debugger).
I have a player component, with a move script and player input component.
Move script's FixedUpdate is getting called, but not the Move function.
Player input component is set with a custom action asset that binds move to a vector2d from AndroidJoystick. It is set to invoke unity events.
I have an event system - the Actions asset here is the default one. I suspect the problem might be the two different action assets, but not sure how to fix that. Edit: Even when setting the actions asset in both event manager and player to the same default one, it is not working (move event not being called)
I started over completely, it's working now. Only thing I did differently was not create my own action asset from scratch, but used the button to create a new one. Haven't tested actual touch to see if that's working, but for now just going to assume it is
I guess this is the right place to ask this. I can't seem to interact with any of my UI elements. I've confirmed that the Event System is indeed present, there's a Player Input Manager, Input System UI Input Module with its actions all assigned and such. Settings are all out-of-the-box.
There's a graphics raycaster and all elements in question are interactable raycast targets... the exact same setup in a different project with the same codebase works fine.
What in the world could I be missing?
Hey, what is the KeyCode for ~ using InputSystem ?
Keyboard.current.[what here?]Key;
Is it the same as Keyboard.current.backquoteKey; ?
Aight, so as I said
There's no ~ in that documentation though
Just like there's none of these:
!@#$%^*()
because they are parts of other keys
Alright, thanks
is there a way i can still use collaborate instead of plastic scm
no collaborate is dead
even if i switch to an older model of unity?
is there anything else i can use instead of plastic scm then
Git
whats the general difference between them both\
too long of a list to explain. THey're just two different version control softwares with tons of idiosyncracies.
How can I have multitouch on my game?
My project is set up so that it has a joystick on the left side to move the player. Swiping anywhere on the screen makes it attack
The problem is that it can't detect the swipe while moving ie the joystick being touched
how are you detecting the swipe?
I followed a YouTube video by samyam
https://youtu.be/XUx_QlJpd0M
Detect swipes and it's direction with the new input system in Unity 2020. I also show how to add a trail renderer for a cool swipe effect.
📥 Get the Source Code 📥
https://www.patreon.com/posts/45726030
🔗 Relevant Video Links 🔗
ᐅHow to use Touch with NEW Input System - Unity 2020 Tutorial
https://youtu.be/ERAN5KBy2Gs
ᐅGet Object from Mouse Cl...
I tried using other bindings other than primary touch but either nothing changes or that the swipe stops working even when not moving
You'll probably want to implement the swipe detection with the Enhanced Touch API instead:
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.6/api/UnityEngine.InputSystem.EnhancedTouch.EnhancedTouchSupport.html
I've come across enhanced touch during my search but I still can't wrap my head around how it works
Hey, any guides on how to do touchscreen camera drag?
idk, but i’d have the camera have a monobehavior, on a tap action callback, look for the coordinates you tapped, and then move the camera accordingly
I don't want a tap action, I need to drag and move
Hello can I get some help over here I am using the StarterAssets with the new Input System however everything seems to be working fine unless I go ahead and add more Actions such as
public bool attack;
public void OnAttack(InputValue value)
{
Debug.Log("OK");
AttackInput(value.isPressed);
}
public void AttackInput(bool newAttackState)
{
attack = newAttackState;
}
I have mapped the left mouse button correctly but OnAttack never gets called am I undetsanding something wrong?
This is how it looks
What's the difference between primary touch and touch #0?
I have just started working with new Input System and I don't understand why performed is triggered just after button is pressed
This is my code: https://www.nombin.dev/noagkwrfra
I see, I should use canceled, not performed
Not sure this is the right place but it's "input" I guess. A volume's colliders are interfering with a raycast. But if I set the volume layer to anything but default, the volume stops working. So I can't mask it. Asked google and it was like "huuuurrr! Use layer masks!" so here I am.
Is this a #💥┃post-processing question?
The answer is indeed to use a layer mask.
I don't see this as being input related.
The input is a raycast and colliders. But I guess I can ask there too.
... right
Hello everyone. Today I upgraded my project to the new input system and am now working on giving the player the option to rebind controls during runtime. Wish me luck 😅
with you luck
Hi everyone, I've got an issue with touch input and UI Toolkit, (I use the old Input.touchCount and Input.GetTouch(0))
The issue is that when I for example click on a floating UTK button, all of my scripts will still detect that a touch input has happened.
How can I change that ?
Getting an error out of the blue when trying to build Addressables relating to the Input System. Worked perfectly fine prior to the time of writing. Updated everything in the Package Manager (except Addressables).
Unity 2020.1.15f1
JetBrains Rider package 3.0.24
Input System 1.6.3
update all of your packages to the latest
Including Addressables?
yes
Ok will do. I’ll let you know if anything changes
@austere grotto I updated the addressables package and now I'm getting these errors
Finally got the rebinding working. Next I need to get the rebinding to override only a specific binding of the same type (keyboard, gamepad, or joystick)
My code so far: var rebindOperation = actionToRebind.PerformInteractiveRebinding()
.WithControlsExcluding("Mouse")
.WithExpectedControlType("Button")
.OnMatchWaitForAnother(0.1f)
.Start();
Looking at WithTargetBinding() but still trying to figure out how to get it to determine what type of device the user pressed during the intereactive rebind
I'm curious, how is IsFirstLayoutBasedOnSecond(string, string) different from if(firstString == secondString) ?
Edit: Ah my debug test printed "XInputControllerWindows is based on Gamepad". I see!
Also, wow. The default name "Mouse&Keyboard" is not recognized as being based on "Keyboard"...
So instead of hardcoding custom strings in my classes, I just renamed the control scheme into "Keyboard" and now it works.
Bit of a dumb hack but hey if it works it works... Edit: Actually that's dumb since it won't work for dualshock etc. Sigh.
Hello all! I'm trying to setup my UI to change based on whatever controller the player is using (Keyboard / Gamepad for now) but i'm not getting any event responses from InputUser.onChange
private void Awake()
{
textDisplay = GetComponent<TextMeshProUGUI>();
}
void OnEnable()
{
InputUser.onChange += OnDeviceChange;
}
void OnDisable()
{
InputUser.onChange -= OnDeviceChange;
}
private void OnDeviceChange(InputUser user, InputUserChange change, InputDevice device)
{
if (change == InputUserChange.ControlSchemeChanged)
{
UpdateUIDisplay(user.controlScheme.Value.name);
}
}
private void UpdateUIDisplay(string deviceName)
{
if (deviceName.Equals("Gamepad"))
{
//buttonImage.sprite = controllerImage;
textDisplay.text = "X";
}
else
{
//buttonImage.sprite = keyboardImage;
textDisplay.text = "E";
}
}
i ran a debug.log to check and OnDeviceChange() is never being called
would appreciate some help 🙏
what are you doing that you would expect that to be called?
I figured it out but it was InputUser.onChange event
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class AnimationAndMovementController : MonoBehaviour
{
PlayerInput playerInput;
CharacterController characterController;
Vector2 currentMovementInput;
Vector3 currentMovement;
bool isMovementPressed;
void Awake()
{
playerInput = new PlayerInput();
characterController = GetComponent<CharacterController>();
playerInput.Movement.Move.started += onMovementInput;
playerInput.Movement.Move.canceled += onMovementInput;
playerInput.Movement.Move.performed += onMovementInput;
}
void onMovementInput (InputAction.CallbackContext context)
{
currentMovementInput = context.ReadValue<Vector2>();
currentMovement.x = currentMovementInput.x;
currentMovement.z = currentMovementInput.y;
isMovementPressed = currentMovementInput.x !=0 || currentMovementInput.y !=0;
}
// Start is called before the first frame update
// Update is called once per frame
void Update()
{
characterController.Move(currentMovement * Time.deltaTime);
}
void OnEnable()
{
playerInput.Movement.Enable();
}
void OnDisable()
{
playerInput.Movement.Disable();
}
}
Anybody sees anything wrong here? My player doesnt move at all...
Any errors in console?
so i have a eventsystem with the new inputsystem.
but i dont know why it gives me trouble with the first selected gameobject it doesnt get set
i try so much but i cant get this to work does someone has the solution for me?
yeah I've never had luck with that
never worked for me in like 10 years of Unity
better off in OnEnable setting the active object
EventSystem.current.SetSelectedGameObject
that was my suggestion yes..
Someone know how I can do to enable or disable a control scheme ?
Via code
I'm still searching on the docu' but if ya know, ping me ! <3
Hello there
is there a way to display controls of an action on screen? like, is there something that's commonly used?
or do i have to develop something myself?
I currently use:
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.6/api/UnityEngine.InputSystem.InputAction.html#UnityEngine_InputSystem_InputAction_activeControl
and
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.6/api/UnityEngine.InputSystem.InputControl.html#UnityEngine_InputSystem_InputControl_shortDisplayName
Which is pretty decent
doesn't give you... icons though
just strings
you'd have to make your own mappings to icons if that's what you want
yes, i guess as much...
thanks
Has anyone tried to read input on an Ipad from a bluetooth device like a remote shutter trigger, music controller, or something that just has a simple button, not necessarily a game controller? We're making a museum exhibit and we just need one button to work (they can't touch the screen)
Err... .WithControlsExcluding("<Keyboard>/anyKey") seems to only affect the Windows key.
...which is also called "Anykey" if I try to map a control to it.
Is this is an inside joke about hitting "any key", or is it a bug of some sort?
leftMeta and leftWindows don't seem to do anything, but this works, I guess?
I would have thought it to affect all keys, going by the name.
can someone help me to fix my update method? specifically this section , It's preventing my enemy from knocking back the player
if (inputVector.magnitude < 0.001f)
{
playerRigibody.velocity = Vector2.zero;
currentState = PlayerState.Idle;
}
else
{
currentState = PlayerState.Walking;
}
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.
well yeah you're doing playerRigibody.velocity = Vector2.zero; every frame when there's no input
how is knockback supposed to work when you are setting velocity to 0 constantly
also it's unclear how your player is moving.. is it using an Animator to move?
Movement is in FixedUpdate..
This
private void FixedUpdate()
{
playerRigibody.velocity = new Vector2(inputVector.x, inputVector.y) * speed;
}
ok yeah so
seems obvious knockback won't work here
Also given that code I don't see why cs if (inputVector.magnitude < 0.001f) { playerRigibody.velocity = Vector2.zero; is necessary as it does exactly the same thing
Yeah , I'm still getting used the the new input system , so is that code just irrelevant?
basically if you want knockback you'll have to stop running this code every FixedUpdate
i don't really see it as being input system related at all tbh
this is your game logic
I think it was because without it my player wasn't stopping properly , but with those lines commented out , everything seems to function correctly
Maybe because I moved the movement into FixedUpdate?
thx @austere grotto this was working
So im trying to trigger a event but strangely enough it doesnt trigger.
I do it like the following in the OnEnable.
InputHandler.INPUT_MASTER.Menu.SwitchTab_Left.started += (ctx) => { SwitchTab(1); };
InputHandler.INPUT_MASTER.Menu.SwitchTab_Right.started += (ctx) => { SwitchTab(0); };
In the OnDisable i do
InputHandler.INPUT_MASTER.Menu.SwitchTab_Left.started -= (ctx) => { SwitchTab(1); };
InputHandler.INPUT_MASTER.Menu.SwitchTab_Right.started -= (ctx) => { SwitchTab(0); };
my IDE say i have to use cancelled?
InputHandler.INPUT_MASTER.Menu.SwitchTab_Left.cancelled -= (ctx) => { SwitchTab(1); };
but that also doesnt do the trick?
I dont get the Debug Messages at all
in the input debugger it gives the right input so it should trigger i dont know why not tho
it was working like this like a month ago