#🖱️┃input-system
1 messages · Page 17 of 1
how do i set the controls the default is none right?
heres my code, I will say the input component on the player isn't accepting input either. It gets no callback context. https://hatebin.com/booueslqtw
the ui works when the input component on the player is off, but the player input doesnt work anyway basically
default one is not none
I would recommend simply deleting your EventSystem and recreating it
to get the default back
possibly clicking ... and Reset will work too
wdym by "it gets no callback context"?
you'd have to show how you set this up
that code links to this (i know I have it set as the menu action map ill add the real playercontrol aciton map later)
is that what you wanted?
ive set up the new input system before so idk what I messed up here
Hi. My controls work fine when on PC, whether I use the keyboard or the mouse, but it doesn't work at all on android.
Here are a few information about it, but let me know if I should provide something else.
It's not obvious on discord, but there are 3 images:
1- The Input Actions
2- The Button itself. Took the Up, which is W on keyboard, as an example.
3- The script that normally catches the input.
well I reinstalled the input system and remade everything and now it works. idk what happened but that was super frustrating. Ty for trying to help praetor
I just can't get it to work...
I'm thinking of just flipping it on it's head and mapping all events manually or whatnot.
hey guys. i was setting up actions for my controller when i realized that the game shits itself when i try to fire my weapon. it works fine with a mouse but with a controller it fires more rounds per second evrey time i press/release the right trigger. any ideas how i can fix this?
first video is with a controller. this is with a mouse
also my weapon wont stop firing
PrimaryAttackInputStarted starts a shooting courutine and PrimaryAttackInputCanceled stops any active shooting courutine
One missing screenshot here is the configuration of the PrimaryAttack action itself
alr here it is
unclear where this code is running. Maybe share the full scripts as per !code
📃 Large Code Blocks
Use 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 format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
they are in line 33 in Awake() https://hatebin.com/qrkkbtimnq
Can you show the waepon script too?
its quite long. ShootingCoroutine() is on 106 inputs on 251 https://hatebin.com/eklrvtpedk
so yeah this coroutine is intentionally shooting continuously while the button is held down
doing StopCoroutine(shootCoroutine); INSIDE the coroutine is not correct
yes its supposed to shoot when the shoot button 1 is held down and stop when released
just use yield break; to stop the coroutine from inside itself
it still shoots more then it should
it also wont stop when i release the right trigger
but it does stop shooting when the reload starts
so thats one bug gone ig
i dont know how to explain it. when the trigger is pressed it starts shooting, when it is released it starts shooting again
What happens if you use Performed instead of Started?
Basically it seems to me like multiple shooting coroutines are being started simulatenously
You should use Debug.Log and confirm that is the case
i was just gonna say that
gimme a sec
performed fixed that but now there is another issue lmao
if the trigger is being held then i suddenly release it and press it again more coroutines start and they wont stop until the weapon reloads
the only solution
In case someone would like to take a look, I still have my issue with #🖱️┃input-system message
(And I also created a Forum post about it to try to get more eyes on it since I'm clueless about this one: https://forum.unity.com/threads/unable-to-handle-touch-input-but-keyboard-works.1512641/)
my guess is it has to do with your control schemes
does it work if you get rid of all the control scheme stuff?
Android will have a virtual keyboard device from the OnScreen Button but no mouse
so I feel the Mouse & Keyboard scheme won't apply
By "get rid", you mean check every box?
Oh, I'll look into that then.
I removed the schemes, and I'm able to still control with my keyboard (once I remapped them)
When emulating touch with the mouse it still doesn't work. Haven't tried deploying to my actual device though.
does the button actually respond to the mouse at all?
like does it dim as you mouse over it etc?
Do you have an event system in the scene?
GameObject, sorry
remove it from there
create a new one
GameObject -> UI -> Event System
this will ensure it has the proper components on it - such as the input module
and that it's a separate object, which it should be
You also need to make sure your canvas has a Graphic Raycaster
When I do that, it navigates me here. I'll delete it before
yes delete it first
remove the input module first
then the event system
then create the new one
once that's done ensure your canvas has a graphic raycaster
Seems to work when I click... give me a sec to try it on the device itself as touch.
Well it works! Thanks a lot! 😄
I have one button that doesn't work, but that must be me messing it up while doing my different tests.
(and the game is laggy as hell on my phone, but that's something else I'll have to investigate 😛 )
So what I needed all that time was an independant EventSystem, not one hooked to the same object. Great!
Hey guys! Please I need some help 🙏🏼
How can I make local co-op with two different gamepads?
I want 2 different player objects answering to the same inputs (same inputActions) from controller 1 for player 1, and controller 2 for player 2.
BUT I do not want to use PlayerInputManager, or PlayerInput.
What can I do?
If you don't want to use the built in solution you will have to handle player device mapping and joining/leaving etc all on your own
I don t need to handle joining / leaving, I just need for one player to listen inputs from gamepad 1 and another to listen from gamepad 2
Also I want the players to be able to play on the same keyboard, but if I use the built in solution I think I won't be able to do so?
Ok I see, so not easy with PlayerInputManager..
If anyone has the answer I d be grateful
anyone know why in the unity inspector player my game works fine, both players can be controlled seperately through keyboard and controller. but when built they both follow controller and neither follows keyboard?
it seems that if theres a controller connected they both use it automatically despite that both are manually set in the inspector
I’ve never known how the input asset things work lol, I’ve always used the Input Action in C#, not great for customisable controls but it is easier for me
I’ll have to learn it someday
I have multiple PlayerInput components active at once which causes PlayerInput.ControlsChangedEvent to not be called on either for some reason? Should I just aim to only have one input active at once or is there some other thing causing it not to invoke?
For context I'm using it to check which input device is being used and it works fine until there are multiple PlayerInputs active in the scene at once
PlayerInput is designed to be 1:1 with human players
Unless you're doing local multiplayer you should only have one
ah groovy then, so if I were to have non-local multiplayer I'd still have one and just ignore the others
Hello so i am not really sure of where I should post it but I am getting a real headache on this one:
I am making a multiplayer local game on Unity.
I already managed to make the Input System work and used some controllers put my prefabs everything works really well!
But I want to make a menu before starting the game where somebody could join the game by pressing start on his controller.
The question is how should I do it are there good practices ?
And how can I pass the which controller to which player from my Lobby Scene to my Game Scene when they start the game.
If there are any unity packages references for this kind of stuff I would be glad to look at it
Hello, I encountered an issue with setting vibrations on a PS4 controller. It is connected to my laptop via Bluetooth (I tried also via USB though). I tried to use gamepad.SetMotorSpeeds as it is commonly said how to do that, but unfortunately it doesn't work - there is just no vibration.
Yet haptics do work well in some games, so it is not a hardware issue. Now I have no idea on how to deal with this problem, maybe there is a common issue regarding this which I dont know about?
I want to make a couch co op game that works like rain world, where there are up to 4 players and you can set controls for each one
so for example if you had a controller and your friend didnt you could set player 1's controls to gamepad and friends to keyboard
or if you both didnt have controllers you could just do both keyboard but someone has wasd and other has ijkl
but it seems the new input system doesn't really support this super well?
Do you want fixed 4-key sets that can be used or do you want users to be able to register 4 buttons on their own?
i was thinking settings that you can change on the fly
thats easy enough thanks to that sample
Well you can use the normal multiplayer function that the input system offers and then use the rebind function that it offers to just put it all to the keyboard on different keys
Otherwise if you have fixed sets just make an asset each for the 4key sets and use them for each player
the existing PlayerInputManager splits it based on Input Scheme right?
that means it might not work
Use multiplayer event system and Input System UI Input Module
You can have multiple of them controlling multiple root canvases
and bind an input asset to a player that has control over it
each asset can just contain a few keys on the keyboard
How would multiplayer UI input help here? The problem i'm having is that I might have more than one player on keyboard and the normal multiplayer thing doesn't support that from what I can tell. If it split players up based on the action map it would work fine for me (also with rebinding). Also since they are rebindable what if a player does half keyboard half gamepad, I don't know if that works either (it should use the gamepad connected that player index, and then keys should all use the one keyboard in theory)
You can have multiple action assets read from the same device and listen to different keys aslong as you dont bind any device to a player
or even action maps
only downside is you have to manually listen for the input in code
var inputMapName = _contexts.config.input.InputMap;
var sharedInputAsset = _contexts.config.input.InputAsset;
_inputAsset = Object.Instantiate(sharedInputAsset);
_inputActions = _inputAsset.FindActionMap(inputMapName);
[...]
private Dictionary<System.Guid, System.Action<InputAction.CallbackContext>> GetBindings()
{
var configInput = _contexts.config.input;
return new Dictionary<System.Guid, System.Action<InputAction.CallbackContext>>()
{
{ configInput.MoveReference.action.id, OnMovement }, // MoveReference -> "public InputActionReference MoveReference"
{ configInput.TurnReference.action.id, OnTurn },
{ configInput.TurnMouseReference.action.id, OnTurnMouse },
{ configInput.ShootReference.action.id, OnShoot }
};
}
private void BindActions()
{
var bindings = GetBindings();
foreach (var (key, value) in bindings)
{
var action = _inputActions.FindAction(key);
action.started += value;
action.performed += value;
action.canceled += value;
}
}
private void OnMovement(InputAction.CallbackContext ctx)
{
var movement = ctx.ReadValue<Vector2>();
if (movement == Vector2.zero)
{
_entity.RemoveMovement();
}
else
{
_entity.ReplaceMovement(movement);
}
}
[...]
Just have an up, down, left, right action on all of them and listen for a different InputMap for each player
Above some sample code, its not 100% for your situation but you can find the functions you need
Or would that still not work in your case? In which case i dont understand the problem correctly 😄
I found a keyboard splitter thing that seems to do what I need using the base thing
its still hacky tho
2 keyboard players and as many controller players
Hello so I have a problem regarding controllers I have InputDevices that I know are good (I checked their name and connected them with the PlayerInputComponent)
First is an XInput and second is a Keyboard&Mouse
void Start()
{
for (int i = 0; i < GameManager.Instance.InputDevices.Count; i++) {
var playerInstance = Instantiate(_playerPrefab);
var playerComponent = playerInstance.GetComponentInChildren<Player>();
// ...
var playerInput = playerComponent.GetComponent<PlayerInput>();
playerInput.SwitchCurrentControlScheme(GameManager.Instance.InputDevices[i]);
}
}
But when I try to move them around using this:
public void OnMove(InputAction.CallbackContext context)
{
PlayerInput playerInput = GetComponent<PlayerInput>();
int playerIndex = playerInput.playerIndex + 1;
Debug.Log("Player " + playerIndex + " moved");
for (int i = 0; i < playerInput.devices.Count; i++) {
Debug.Log("Player " + playerIndex + " has device " + playerInput.devices[i]);
}
movementInput = context.ReadValue<Vector2>();
}
(This is a classic CharacterController with the new Input system)
Both of the players move regardless of the controller and both of them have the two devices...
So for reference for anyone it is just that SwitchCurrentControlScheme was returning false an issue with the controlScheme directly
@chilly ginkgo
https://img.sidia.net/ZEyI5/voheSUto43.png/raw
Don't double click it, click once and you will have the checkmark in the inspector
I'm texting. How do you know I'm in this trouble
Saw it in #💻┃code-beginner
Thank you
hello , I'm new in unity and got this messages (I'm using lts 2021 btw) for now there isn't a problem yet but I'm scared later it's gonna ruin something . Do anyone here knows what's wrong and how to solve this ? Thank you so much and have a nice day
Message: Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported since Unity 5.
If you want to use a non-convex mesh either make the Rigidbody kinematic or remove the Rigidbody component. Scene hierarchy path "Player(Clone)/Main Camera/pistol_001/pistol_drum_001", Mesh asset path "Assets/Weapons_FREE/Meshes/pistol_drum_001.fbx" Mesh name "pistol_drum_001"
Message : Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported since Unity 5.
If you want to use a non-convex mesh either make the Rigidbody kinematic or remove the Rigidbody component. Scene hierarchy path "Player(Clone)/Main Camera/pistol_001", Mesh asset path "Assets/Weapons_FREE/Meshes/pistol_001.fbx" Mesh name "pistol_001"
I mean the error is telling you exactly what the issue is
What's your confusion?
also what does this have to do with the input system?
oh I'm sorry lol just found what i should do i forget to check the convex . I'm sorry if i was at a wrong place when asking🙇♂️
Is this the right place to ask questions about UIButtons and the new Input System?
I'm trying to make a button behave like an "OnHold" physical button, that is, that it continuously sends events while its pressed
Give it an EventTrigger (or attach your own script) and handle the PointerDown and PointerUp events
start doing the thing in PointerDown
stop doing it in PointerUp
Use Update or a coroutine to run code each frame.
Not really an input system question tbh, more of a #📲┃ui-ux question
Aye, proper. I've had to write a script for it, I was trying to use VisualScripting instead.
It works, now.
how do you refer to a control scheme in scripting?
im having trouble with two players in my multiplayer game both using the same control scheme despite being assigned different ones, i was thinking if i can reference them in my movement script i could fix that
am i correct in thinking that gameobjects with a playerinput component join a playerinputmanager automatically?
They don't. Only when they are spawned by the PlayerInputManager
how do you join players manually then?
i.e. as opposed to waiting for button inputs orw hatever
is there a way to turn off keyboard inputs on UI elements? My movement keys are cycling through my UI elements by default
disable navigation on the ui elements
or remove the directional input bindings from your input module
Disabling the navigation seemed to work for the buttons, but not for the dropdown UI element.
it's easier to create your own equivalent of playerinput that doesn't know anything about control schemes than it is to use their cockamamie control scheme thing
same with "joining" players
it really depends what your game is
I'm trying to create a util script that sets the time scaled based on holding T+one of the number keys (T+0=0, T+1=0.1 etc, and T alone resets it). However, I cannot find any way to create button combos in the InputActions file. Would I be better off just using Input.GetKeyDown?
just handle the combo logic in your code
input handling is separate from that
I'm not sure what you mean. Are you talking about creating actions via code?
make 10 actions - one for each number button
bind them to the number keys
plus an action for the T key
the actual code will depend on your preferred method of handling input (ew.g. are you using PlayerInput? The generated class? Something else?)
There's got to be some simpler way than doing 10 actions
hehe
because it's by far the best and most well supported way
It will take you like 1 minute
building a workaround will take you hours
Do you know anything about triggering on other Action Maps or do I have to make a new object with a new PlayerInput component?
PlayerInput is the only input handling approach which typically has only one actiuon map enabled at a time
but you'd have to be more specific about what you mean by that
I currently have my stuff on my GameController game object and I'd much rather have some way to access other action maps depending on the script (e.g. UIHandler script would be able to access the UI map, and SlowmoHandler would be able to access another action map)
Would be pretty cluttered to have T and 1234567890 in e.g. the UI map
This is much simpler to do if you don't use the PlayerInput component
Have you looked into using the generated C# class?
Nope. Where can I read more about it?
I have never heard of it^
!code
📃 Large Code Blocks
Use 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 format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
And what is the issue...
I take it those are line numbers with errors or something?
Yes.
And... what are the errors.
namespace, definition, } expected
So yeah, it did look like you were missing a closing curly brace.
Can you please just... post the errors? Provide all info up front. Don't make people drag it out of you
So these are pretty clear. Add a ending curly brace to the last line
Remove the using UnityEngine.InputSystem
That isn't right. Can't remember the right one off the top of my head
Look up the docs for InputValue
Wait wait. Do you have the Input System package installed
No that's correct (the namespace)
That DOES look to be the right one
Yeah, just looked it up
kinda sounds like you don't hav ethe input system package installed
Or perhaps your code is in an assembly that doesn't have a reference to it
Ok, I had did 2 points.
The unity top and bottom.
Both corrected now.
now is the middle, the "Vector".
Read what praetor said. I was wrong about the namespace. Add it back
Do you see what we are saying about the package?
Yeah...
So you need to install it. It isn't installed by default
That's what we were saying about the package
Ok, so it's installed from where?
The package manager
Known as the "InputSystem" ?
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/manual/Installation.html
You also then need to enable it. But a popup should show to ask if you want it done automatically
Ok, it's installed.
That other content looks substantial on the list.
Ok, the top line is clear now.
The middle "Vector" is problematic now.
I got to go, ill bbl.
this is because you wrote this:
internal class InputValue
{
}```
delete that
I was just about to say haha. They probably did a fix suggested by the ide before they had the Input System installed
Hey, is there a way to reset a gamepad when opening new UI?
Basically my player is running right through some EXP bubbles and gets level up, triggering the level up UI in which the selection will burst off to the right side instantly
Also when on keyboard & mouse I play with the mouse key clicked 90% of the time (shooting), if that UI pops up and I release the mouse key it instantly clicks on the element thats under the cursor
hey guys i have a question
sometimes when im starting my game it doesnt register my mouse or something and thats why my character controller doesnt work.
so i have a inputhandler script what is static what execute on [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)]
and my character controller doesnt work when my mouse isnt on focus but when my mouse focus after the function it doesnt work anymore?
does someone has a solution
is there a solution that you can force mouse focussing
Holy crap guys, I've had this "Bug" with the Input System for weeks, turns out it was just Steams "Big Screen" config in the background adding an extra layer of bindings ontop of my Vector2 + Gamepad Buttons
Close Steam = Flawless Split Screen config using Input System
Is the input system the best thing to use for navigating stairs?
Input shouldn't really be relevant for that. You capture input, and it's how you USE it that would matter
Disabling the controls would probably be ideal on popup for a moment or two
maybe make the UI fade in during the time
Yeah I solved it by disabling the event system + input actions until the animation is finished, if the user still holds through that nothing much I can do from what I have seen
eh, that's on them then haha
I'm using a custom render feature to curve my UI. So I need to remap canvas raycast positions from the mouses position on screen to the point on the canvas that gets warped there by the post process curvature. I've got a handy function that convers screen coordinates to curved canvas coordinates, but I can't for the life of me figure how to actually interface with the canvas.
write a custom raycaster
Make a class that inherits from https://docs.unity3d.com/Packages/com.unity.ugui@2.0/api/UnityEngine.EventSystems.BaseRaycaster.html
Actually in this case you may want to inherit from https://docs.unity3d.com/Packages/com.unity.ugui@2.0/api/UnityEngine.UI.GraphicRaycaster.html
My animator is not working.
Maybe go to #🏃┃animation
Or is this because of the input system?
Gonna have to provide a LOT more information
Hi
i'm having some issues with the new Input system
I need to manage local multiplayer
but when on the main title screen and someone press any key i add a new player instance with the player input manager
it create a player with the right control scheme assigned
and then i want to disable the addition of new player so i deactivate the player input manager
and i want the newly added player to navigate in the menu
but if i pressed a button on the gamepad it can then be used in the ui to navigate...
is there anyway to tell the Event System for the UI to only listen to the control scheme of the available player input?
If you use the multiplayer event system you can probably disable all of them except the one for the active player
yeah i tried using it but maybe i don't understand how to really use it
i replace the actual Event System with the multiplayer one
and assigne the root gameobject to be the canvas of my ui
but it doesn't change much
Should i create an instance of the menu inside the player input gameobject?
so that only that player can interact with the menu?
I have a TextField that Im drawing using this and I want to listen for tab, arrow keys and return presses while the user is typing in the field. The problem is that Input.GetKeyDown checks seem to be blocked whenever this TextField is being used. Anyone know of a solution to this?
_input = GUI.TextField(new Rect(10f, y + 5f, Screen.width - 20f, 20f), _input);
when using IMGUI, input handling should be done in ONGUI with Event.current;
Good evening, I want to use WASD to rotate an object in all directions, how can I bind this? I tried adding up,down,left,right binding but it didn't show up
You need to change the action type and control type
Action Type -> Value
Control Type -> Vector2
then it will show up
Thanks
unstable mouse sensitivity when using cinemachine input provder - tried the fix to divide the input by delta time but still doesn't fix it - the only code I have touching the sensitivity is just to set the sens on Void Awake so that shouldn't be affecting it, but here's the code anyways:
if (_cinemachinePov == null)
{
_cinemachinePov = firstPersonCam.GetCinemachineComponent<CinemachinePOV>();
var currentSens = _cinemachinePov.m_VerticalAxis.m_MaxSpeed;
var newSens = currentSens * sensitivity / 100;
_cinemachinePov.m_VerticalAxis.m_MaxSpeed = newSens;
_cinemachinePov.m_HorizontalAxis.m_MaxSpeed = newSens;
}
else
{
var currentSens = _cinemachinePov.m_VerticalAxis.m_MaxSpeed;
var newSens = currentSens * sensitivity / 100;
_cinemachinePov.m_VerticalAxis.m_MaxSpeed = newSens;
_cinemachinePov.m_HorizontalAxis.m_MaxSpeed = newSens;
}
this is actually murdering me as I have no idea why this is happening lol
Is it possible to have multiple action maps enabled at the same time?
Yes
There's only one circumstance where that isn't the default case and that's when you use PlayerInput's SetCurrentActionMap
See the discussion here: #archived-code-general message
For some reason Unity's new input system no longer recognizes my keyboard & mouse. It worked fine before but not anymore:
Ok found it, I had two Player Inputs in the Scene
Hello, I am having problem with the new input system, everything works untill I close and reopen the project. Just so I dont jam a lot of the code here here are links to reddit post and unity answers post I made where you can read the code I wrote for it:
https://www.reddit.com/r/Unity3D/comments/17xdqzn/new_input_system_problems/
https://discussions.unity.com/t/new-input-system-problems/313684
If anybody has any ideas or knows how to solve this, I would really appriciate it 🙂
Hi, so I am having problem with a new input system. I have an Input manager singleton class that looks like this public class InputManager : GenericSingletonClass { private Controlls _controls; public Controlls.MovementActions MovementActions; public Controlls.SwitchingActions SwitchingActions; public overri...
just looks like a script execution order issue
OnEnable on the Pickup script is running before Awake on the Input Manager script
use https://docs.unity3d.com/Manual/class-MonoManager.html to make sure the input manager runs first
I will check that out, I was thinking it was an execution order thing but it did not make sence since while I am in the project it runs everytime, as soon as I close and open it, it breaks. It doesn't break while I'm in the project.
Looking into monomanager
NullReferenceException is pretty unambiguous
the null reference points to ``` public InputAction @Action => m_Wrapper.m_Movement_Action;
Looks like changing input manager execution order to -100 worked
Thank you for the help!
Not sure if this is the right channel, but I have questions about using the Backbone controller on my iPhone.
I recently created a test build of my game. After getting the game to run on my iPhone, I hooked up my Backbone controller and all the buttons work perfectly except the left and right joysticks. The left stick does move my character, but its janky. Up is right, down is left, right is down, etc. Its all out of wack. My right joystick that controls where I look doesn't respond at all. I've messed with different joystick configurations but there are so many I'm not sure which one to use. Anyone have thoughts on what joystick config to use? Also has anyone else attempted to use the Backbone on their iPhone builds and found success on their controls? I'll paste a screenshot of my input setup for my Move action.
So lets say in my code I get an action map like this
And then register a new action like this
Is it the expected behavior, that disabling it like this, wont disable the newly added action?
well you're not adding an action here. You're subscribing a callback function to one of the existing actions
I would expect disabling that action map to disable all the actions inside it. But it's unclear from the second line if the action you're subscribing to is in the action map that was disabled or not
if it's in the disabled action map, I would expect it not to fire any events.
otherwise it will be unaffected
Also disabling the action map doesn't remove any event subscriptions
it only disables the events from being fired
maybe that's where your confusion lies?
right, bad wording on my part, the action DOES exist but it's not mapped on game start
in my case the action i map's action map seems to be properly disabled
becomes this:
in my case it's _activeActionMap
but for some reason it still triggers when i press the key
and this where i map it
so it is in "Battle"
must be missing something
(you can see 'input cycle pressed' even though battleActionMap.enabled is false)
hi! i'd like to know how does my player movement script can distinguish command coming from the right player and the wrong ones?
i have two player Input
using SendMessage
does the player script has to be on the same gameobject as the playerInput?
I don't know I'd have to see the rest of your code.
SendMessage sends messages to the GameObject it's attached to
ah ok
the main problem is that i made a ui to insert players but the playerPrefab is juste the PlayerInput itself
Sounds like you'll have to restructure that somewhat
add a layer of indirection
It's a bit hard cause it's across multiple files, but according to what you said, it should not behave the way it does, so its most likely due to something external?
now i need to find a way to instantiate the real player gameobject in the scene but connect them somehow with the player input
You may be dealing with a completely different instance of the actions asset for example
it's hard to say without seeing code
hold on
@austere grotto maybe this is enough to tell?
bad link, sec
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
let me check
SetActionMapOnEventEnd is what is called in the example above, that disables the actionMap
honestly since you're doing things like this I'm struggling to see why you're using the PlayerInput component in the first place
hmm, maybe cause I don't know what I'm doing, but also local multiplayer
in this case it's mapped at runtime, because the class doesn't exist before the battle is instantiated
some other are mapped above because they are from different scenes
I don't see anything popping out as obviously wrong
damn kk
anything i could print you could think of that might give me more info to debug?
could also try debug mode maybe, i'm a bit clueless to what could be wrong rn
well actually from this screenshot _outsideBattleActionMap is True no?
yeah but the 'Battle' map is under '_activeActionMap', outsideBattle is something i just used for the first example but unrelated
mb
seems like, for some reason, the action is still enabled
Different instances possibly
yeah.. so maybe the first thought I had then.. I'll try to use .FindActionMap everytime and see if it helps
more like - wrong instance of the actions asset itself possibly
It's unclear where you're calling RegisterInput from and where you got the InputManager reference from
there's only one InputManager and RegisterInput is called from the component that uses it when it's started
testing to see if find returns the same value rn
yeah does seem to keep the same state..
find every time or storing locally seems similar
I think i figured it out
@austere grotto issue was _activeActionMap not being nulled onEventEnd (144) and then line 108 of the code i shared above, re-enabling it every time i brought up the console, which I guess I've used also every time to check if it was working
Any ideas why I'm not able to use the Japanese IME in a Unity game?
I want to switch to HIragana mode but it won't let me when Im in game
I'm trying to make a typing game
hello, I have this script in which I'm trying to rotate my camera around a player character whenever I press X and C (for left and right)
and I'm using the new input system
I'm using cinemachine to do the virtual camera and applying the script onto the virtual camera
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class RotateCamera : MonoBehaviour
{
public InputAction rotateAction; // the input action for rotation
public GameObject player; // the player object
public float speed = 10.0f; // rotation speed
private Vector2 direction;
void Awake()
{
rotateAction.performed += OnRotate;
}
void OnEnable()
{
rotateAction.Enable();
}
void OnDisable()
{
rotateAction.Disable();
}
public void OnRotate(InputAction.CallbackContext context)
{
direction = context.ReadValue<Vector2>();
Debug.Log("rotating");
}
}
here is my code
for now I'm not even rotating anything, just trying to log the message that it's rotating. How can I get the script to use the Camera Movement Input Actions I've created?
nothing is being logged at all when I try to run it
Use InputActionReference instead of InputAction
Then you can pick the action in the inspector
You'll just need a .action on it to access the actual action
oh wow thank you so much
So to create a respawn logic with Input System, I had to create a Player Parent with the Model/Camera and a seperate input system gameobject. Link that object to my movement script to broadcast events. Now when my player dies, the input actions doesnt deactivate causing the player instance to be removed.
@obtuse plover Don't cross-post, please.
@obtuse plover You can find tutorials on Input System in the pinned message. You'll find information there how to use it in place of old input system
thank you.
Is there any way to get a joystick position without using unity axis system?
I don't want to use the new input system
And the old one doesn't allow me to make customizable bindings
So I'm wondering how to get joystick's position to make "my own system"
Hi ı am new to unity and ı am doing a tutorial serries but ı am having an issue can anyone help
its about İnputSystem
theres no 2D vector Composite what should ı choose instead
Make sure the control type is set to Vector2.
Does Unity handle key combination binding? Like in fighting games - when you press 2 button at once, special move will happen. I know that there must be a delay between reading keys inputs (because it would be very hard to press 2 buttons exactly in the same time), but does Unity handle it somehow or I must program this on my side (I'm using Unity Input System)?
I dont think unity have that
your wantings is similar to unreal engine input
The input system has support for that but you still would need to disambiguate it from the individual button actions if they exist. It's often simpler to handle it yourself
Which of these bindings causes an object of type Button to be pressed. In my game, using this Map by default the Enter is used, but I can't find any enter binding.
This screenshot is not showing any bindings
this is showing actions
Are you talking about pressing Enter in the UI to press a button?
That would be under the Submit action in your input module - most likely mapped to Submit in this screenshot
Again - you're looking at actions here, to see the bindings you need to expand the actions
Is it possible to have an event for when the up down left right components of a composite vector are just pressed down individually, I want to track how many times an input has been pressed down, rather when the whole action is performed because that seems to track when the action is also released for the composite vector (which I don't want, I just want an event to trigger when a input pressed down)?
Make individual actions for each
Hm, I guess that should work
Hello everyone. Is there a way to understand when action was triggered by one binding, and when by another binding (with one modifier for example)?
In my opinion, the simplest approach is make two actions:
InputAction mainAction;
InputAction modifierAction;```
Then in your code:
```cs
void Update() {
if (modiferAction.IsPressed() && mainAction.WasPressedThisFrame()) {
// modified action
}
else if (mainAction.WasPerformedThisFrame()) {
// plain action
}
}```
Well, yeah
But I mean is there a convenient way to do something like this in one action? The thing is that they are very similar, so it would be logical to put both of them in one action and just check if the binding with modifier was called to do some extra actions
But I mean is it a convenient way to do something like this in one action
There is no good convenient way.
Maybe a cleaner way to write it:
void Update() {
if (mainAction.WasPerformedThisFrame()) {
if (modifierAction.IsPressed()) {
// modified action
}
else {
// plain action
}
}
}```
Oh, got it. Thanks for your help
Check one by one, here they are all open
It is the default when using the Event System of the new Input System. My buttons in my game are pressed with Enter once selected. In addition to clicking on them, which is obvious.
I want to know how to change that enter or add more buttons.
By the way, where it says keyboard, there is nothing more than navigation.
The first screenshot you just sent me is how to add more buttons
Add bindings by pressing that + button
Since this is the default input actions asset you may need to duplicate the asset to change it
(and assign that duplicate to the input module)
Yes, I already did that, that's why it has another name. Thank you very much, as I read Any I thought that the binding was like when they tell you: "Press any key"
Thankss
Works 
Does anyone know how to get mouse and touch input working with the InputSystem on WebGL builds? It appears that it is picking up a touchscreen device on desktop which appears to be consuming my mouse input as touch input. When removing this touchscreen device my mouse input works as I would expect. With the touchscreen device still there my mouse input appears to be consumed by the Touch bindings (e.g. holding left and right mouse button binds to my Touch #1 input)
I am generating tutorial text from input actions. So far, I just handle (possibly composite) bindings. I want to add in interactions as well.
So, I want to be able to spit out something like "Tap 🅰️"
I see that each input action and input binding has an interactions string on it
Is there a convenient way to parse this string into something more structured?
It looks easy enough -- the interactions are comma-separated, and any parameters are enclosed in parentheses
Tap,MultiTap(tapTime=0.2,tapDelay=0.75,pressPoint=0.5)
e.g.
i'm not sure i'll ever actually have multiple interactions at once, of course
I'm also not sure I need to actually implement a general solution for this. I can probably just stick with checking the action and checking each relevant binding
oh yeah, that's perfect
Im trying to write manager for my code which is connected to multiple scripts
Its meant to be for a tutorial so there should be some form of game state and after pressing a button, the state will progress
The issue im having right now is that
void UpdateState(InputAction.CallbackContext context)
{
if (context.performed)
{
Debug.Log("Action: " + context.ReadValue<float>());
}
}
Im only using a single function to update the state, but how do I know where the button press is coming from?
I want to identify if the player is moving or the player is attacking using the player controller events
Or is that not how I should go through this problem?
So you're having many different actions invoke the same UpdateState method
InputAction.CallbackContext has an action member that tells you which InputAction produced it
I suspect you could do something like this
[SerializeField] InputActionReference attackActionRef;
void UpdateState(InputAction.CallbackContext context) {
if (context.performed) {
if (context.action == attackActionRef.action) {
// ...
}
}
}
Use multiple functions
Is it better to use multiple functions @austere grotto
Or better to do like one function for everything
I said what I said.
Hello everyone. After merge of branches in GitHub, I've got a broken InputActionAsset. It sends me to some code, but I don't understand a little, how can I fix it... Can someone help with it :(
just opent he asset and re-save it / regenerate the code
It doesn't open
the json is invalid
did you have merge conflicts in git?
Maybe you accidentally committed the merge conflict markers into the file, or resolved the merge incorrectly
either way the data is corrupted/invalid
Where I can get the JSON file to check it? When I click on the error it leads me to this .cs, but it has a lot of try-catches, so I suppose it is not something I search for
I suppose the wrong conlict resolving is the reason, yeah
then you need to go fix that
the asset file itself is corrupted
this is just the code that is encountering your corrupted asset file
the problem is the corrupted asset file
either checkout an old version, or go into the yaml and try to fix it manually
Found the problem, thanks for your help!
Hi I cant seem to navigate the UI with the d pad on the steam deck I'm using the new input system then UI navigation when going into pause menu for example , any idea? thank you
UI navigation input mapping is handled by your Input Module component on the Event System object
Seems like with the DS4 on the editor I can use the dpad for UI navigation no problem. I'm gonna try the build with the dualsense and check
Maybe is a steam deck issues only
Yep it's working the UI navigation with the dpad with the dualsense and DS4 but not on the steam deck
Does this thing do Horizontal?
Hey does anyone know how to attach methods in other classes to the input in another class? So i have a PlayerInput class where I have my awake function to make an instance of my controls, I have the OnEnable and OnDisable functions set up. I have references to other scripts like my interact system. In my interactsystem script it has the method public void Interact(Input.CallbackContext context) and in my PlayerInput I have interact.performed += interactSystem.Dash; But it isn't working.
What thing? The split screen? That's not related to the input system, that's just how you set up your cameras
oh, ty
You'd have to show your code and explain what "isn't working" means
public class PlayerInput :
OnEnable () {
dash = playerControls.Player.Dash;
dash.Enable();
dash.performed += playerMovement.Dash;
}
public class PlayerMovement :
public void Dash(InputAction.CallbackContext context) {}
The dash works perfectly fine by itself but its not being called even though I tried assigning it in another class. I'm not too sure what this error means ArgumentException: Value does not fall within the expected range.
hey! 2 questions, why cant i see the placeholder in this input field ? and when i play the game, i want this input system to be still in its place, not follow the camera, how do i do that?
where did playerControls come from?
You need to show more code.
What rendering mode are you using for your canvas?
You would need to use a world space canvas if you want it to be stationary in the world
i did use world space, it still kinda moves with the camera, not at all times, but just when im looking at its direction, it starts moving a bit
world space canvas will not move with anything
if it's moving it's due to some script of yours or a component you attached to it or because you made it a child of a moving objects or something.
the canvas wasnt a child of anything, and it only had the input field 😅
you'd have to show a video or something, and also screenshots of the inspector(s) of the objects involved
Sorry I shouldve explained a bit more. PlayerControls is my c# generated class from my InputActions asset. I have it referenced in my PlayerInput class
Wdym you have it referenced? How did you reference it? Share the code.
!code
📃 Large Code Blocks
Use 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 format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
ArgumentException: Value does not fall within the expected range
Where are you seeing this error and what is the full stack trace for it?
(P.S. I don't recommend naming your class PlayerInput since there's already a component by that name in the Input System.)
This error appears runtime and its for the line :
dash.performed += playerMovement.Dash;
Yeah your right I just found it, i'll change the name to Input since it might cause problems later down the line
Well that explains why it's not working then.
Your problem is playerMovement is null
which makes sense because you're not actually assigning it until Start()
OnEnable runs before Start
You should be doing these:
playerMovement = GetComponent<PlayerMovement>();
cameraController = GetComponentInChildren<CameraController>();
interactSystem = GetComponent<InteractSystem>();```
Inside `Awake`, not `Start`
Oh that makes sense, I didn't know OnEnable ran before start thanks for the help!
I just noticed that I'm getting really weird input lag on macOS. When I click the left mouse button, mouse movements are ignored for several frames.
It seems worse when the game's running at a low framerate. The mouse click itself is also delayed.
Other mouse buttons are completely fine.
This is happening in every game I've built
Aha. Thank you Reddit!
er, StackExchange
potato potahto
an application called Magnet was causing it
this might be helpful to someone else searching for this, at least! lemme just throw out more keywords: macos input lag ; macos left click
is it possible for me to use the input system to trigger a button? i want to trigger an OnClick() when i press a button and button.onClick(); doesnt seem to be working for me :/
Hi ! so i want to create actions for my player movement
but i cannot select the bind "right stick [gamepad]" for no reason
and "Delta [Mouse]" to
"right stick [Gamepad] is unclickable
I'm having trouble to store diagonal input with Unity's new input system.
When I walk top-right, the diagonal animation is played.
When I stop pressing 'W' and 'D', I want to play the idle animation for the top-right direction.
But because it is impossible to release both keys at exactly the same time, it switches to either top or right first depending on what key was released first.
How do I prevent this from happening?
void OnMove(InputValue movementValue)
{
movementInput = movementValue.Get<Vector2>();
if (movementInput != Vector2.zero)
{
animator.SetFloat("MoveX", movementInput.x);
animator.SetFloat("MoveY", movementInput.y);
lastDirection = movementInput;
}
else
{
animator.SetFloat("IdleX", lastDirection.x);
animator.SetFloat("IdleY", lastDirection.y);
}
Debug.Log($"X: {movementInput.x} | Y: {movementInput.y}");
}
What do you mean by "Idle top right direction" ?
Not really an input system problem
What you need to do is calculate which of the 8 directions you're facing in C#
And pass that into your animator
Rather than two independent x/y values
Which the animator is too simple to handle
I have a quick question btw, is it bad practice to create multiple instances of the same PlayerInput ?
For example, I have two scripts on a same GameObject :
Both of them have something like :
public class HandlingStuff : MonoBehaviour
PlayerInputManager playerInputManager
private void Awake()
{
playerInputManager = new PlayerInputManager();
}
Do you guys agree there is two instance of the same PlayerInputManager? How would you proceed to create a single instance that I can reference to ? (For example, for calling OnMovementInput, OnAimInput etc...)
I hope I made myself clear... Thanks in advance !
How do I change this default text in the TMP Input Field? Never mind I found in the Placeholder componenet of the Input Field.
It looks to me like you simply named your actions asset that?
Because PlayerInputManager is a thing but that's not how it normally works
If you want to only create one, you should just create one and share it by exposing a reference to it
Please
Wrong action. Do it on the one you set as a Vector2
Movement
If you want to do it for camera you need to set it as a Vector2 as well
Ok thanks you so much it worked !
Hey! Ive been using the fps package as a template with is using the new input system and I just upgraded my unity version because I really wanted to have volumetric clouds, everything went smoothly except that the starter package got broken and its giving me this error
https://i.gyazo.com/64189c601eedc389ca9cf41238c90e6e.png I cant find any tool drop down and I cant find it in the package manager either, is there something else I should do?
everything works except my inputs
fixed it by adding this in the player settings
https://i.gyazo.com/6c5fb64a7221b454e3d342638818eb60.png
hello everyone, I'm sure this has been asked a billion times but does anyone have any idea how to prevent my input system from firing events twice? I tried adding InputAction.CallbackContext context as a parameter and it just throws an error now saying the method is NotFound
it won't fire events twice by default
you also described at least two different problems
share the details of how you tried to set things up and we can show where you've gone wrong
sorry, I was under the impression this was a known issue given everything I was reading online. basically I have set it up as simply as possible, as I'm doing a gamejam. I created a PlayerInput with default settings. in my script, I've imported Unity.InputSystem, and I have a public void OnFire() method. but when I put a debug.log on it, it appears to be firing twice when I click the mouse, which is causing double damage to my enemy
show the details of your OnFire method
generally you will get one callback for pressing down and what callback for releasing. You are supposed to disambiguate that in your code
it's not really an "issue" just perhaps a misunderstanding on how it works.
is there a way I can easily disambiguate it in my code?
I appreciate you taking the time to answer my frantic question lol
yes but I can't help you with that without seeing the code
and screenshots of your PlayerINput component
I'm digging in further and seeing that you're right, my input IS only happening once but my attack is being called twice, I'm sorry I should have checked that before asking! so now I have a starting point
sorry, I feel like an idiot now
nothing like a gamejam to make you go nuts lol
Do you have an event system in the scene?
I assume you mean a UI button (since you said clicks)?
yes to both
@tulip tartan any solution?
Some ui elementcould be blocking it. Show the on click section of the inspectir for the button too
Also, this should be in #📲┃ui-ux or #💻┃unity-talk as this is not an input system issue
i added a graphic raycaster to my canvas and that seemed to fix it kinda
mb im kinda cofused what each channel is for
Nice, glad you got it working.
The button SHOULD have added one when you created it, so that's weird. But good work.
And no worries about the channel. It happens 😄
thanks, i was deleting some things and it looks like ive probably deleted it on accident
I would love some help please!
I have a full action Asset defined. I have the action map set in the Ui_EventSystem as well as the PlayerInput. I don't seem to get ANY input from the D-pad, submit or ananogue for scrolling through the menu.
Controller support for ui has to be set up manually.
You have to tell the buttons and sliders, drop downs and etc, what interactable is on top of them, what is below them, whats on their left, right and.... you also have to make a script that selects a button at the start of the game so you can move to the others around it.
Follow a tutorial on YouTube
This video will show you how to use controller and keyboard (or any control) to navigate your UI menu in Unity. This will be using the new input system available for download in the Package Manager.
📥 Get the Source Code 📥
https://www.patreon.com/posts/48861194
🤝 Support Me 🤝
Patreon: https://www.patreon.com/samyg
Donate: https://ko-fi.com/sam...
Thank you very much for your reply, however I figured out how to fix the controlelr support without manually setting it up. The only button that needed a manual method created was the back button .
Thank you though for taking the time to drop me a link.
If I want to detect the direction from a phone to the ground, do I use the Gyroscope, GravitySensor or Accelerometer?
I'm working on adding mobile compatibility to a WebGL build and it works fine on android/PC but the click and drag motion doesn't do anything on iPhone. We're detecting this movement using Input.GetMouseButtonDown(0) (+ButtonUp). I couldn't find any useful documentation so I just wanted to ask if iOS browsers map that movement to mouse button 1?
InputManager input;
Rigidbody2D rb;
float propulsionForce = 50f;
private void Awake()
{
input = new InputManager();
rb = GetComponent<Rigidbody2D>();
}
private void OnEnable()
{
input.Enable();
}
private void OnDisable()
{
input.Disable();
}
private void FixedUpdate()
{
if (input.Player.Move.triggered)
{
Propel();
}
}
private void Propel()
{
rb.AddForce(Vector2.up * propulsionForce);
Debug.Log("Propelling");
}
What's wrong here? I am spamming the move button but it only debugs sometimes. It does it at random times without a noticeable pattern.
You're trying to read input in FixedUpdate
Input handling goes in Update
Having a bit of a
moment right now with the new input system. I have my input actions and everything set up, but in my player movement script itself I'm a little confused on how to actually use the new input to move my player? I'm subscribing to my actions and then in the listener I have it set a move direction and add force to a rigidbody, but I think I'm missing a step because when I perform said event nothing happens to the object the script is attached to.
Player Controller Script:
// Public
public float movementSpeed;
public Transform orientation;
// Private
private Rigidbody rb;
private PlayerInputActions playerInputActions;
private Vector2 inputVector;
private TwoAnimationStateController animCon;
private Vector3 moveDirection;
private float horizontalInput;
private float verticalInput;
private void OnEnable()
{
playerInputActions.Enable();
}
private void OnDisable()
{
playerInputActions.Disable();
}
private void Awake()
{
playerInputActions = new PlayerInputActions();
playerInputActions.Player.Jump.performed += Jump;
playerInputActions.Player.Movement.performed += Movement;
playerInputActions.Player.Dance.performed += Dance;
playerInputActions.Player.MouseX.performed += ctx => horizontalInput = ctx.ReadValue<float>() * 0.1f;
playerInputActions.Player.MouseY.performed += ctx => verticalInput = ctx.ReadValue<float>() * 0.1f;
}
private void Start()
{
animCon = GetComponent<TwoAnimationStateController>();
rb = GetComponent<Rigidbody>();
rb.freezeRotation = true;
}
private void Update()
{
UpdateInputVector();
// Animation
animCon.UpdateVelocities(rb.velocity.z, rb.velocity.x);
}
private void UpdateInputVector()
{
inputVector = playerInputActions.Player.Movement.ReadValue<Vector2>();
}
public void Movement(InputAction.CallbackContext ctx)
{
animCon.StopDancing();
moveDirection = orientation.forward * verticalInput + orientation.right * horizontalInput;
rb.AddForce(moveDirection * movementSpeed, ForceMode.Force);
}
public void Dance(InputAction.CallbackContext ctx)
{
animCon.StartDancing();
}
public void Jump(InputAction.CallbackContext ctx)
{
if (ctx.performed)
{
rb.AddForce(Vector3.up * 5f, ForceMode.Impulse);
}
}
}
It's probably obvious but I'm not totally sure why my player isn't moving, so any help would be greatly appreciated
AddForce belongs in FixedUpdate, not in your input handling code
also this is very confusing because you appear to be trying to handle the movement input in two different ways
- you do this:
playerInputActions.Player.Movement.performed += Movement; - you do this in Update():
inputVector = playerInputActions.Player.Movement.ReadValue<Vector2>();
pick one
So would I just be calling AddForce in my fixed update with the values from the ctx in my listener? i.e.
animCon.StopDancing();
moveDirection = orientation.forward * verticalInput + orientation.right * horizontalInput;
then in FixedUpdate
rb.AddForce(moveDirection * movementSpeed, ForceMode.Force);
with the values from the ctx in my listener
Pick one - read it in Update, or in the callback. Not both
Either way save it in a variable and use it in FixedUpdate
Oh i'm really dumb I understand, thank you
I've been like frankensteining multiple resources because I couldn't figure it out and the remnants of others has also been interfering with my new stuff
For anyone else who may ctrl+f this or was curious, I fixed this issue by doing:
private void Update()
{
// Inputs
inputVector = playerInputActions.Player.Movement.ReadValue<Vector2>();
moveDirection = orientation.forward * inputVector.y + orientation.right * inputVector.x;
// Animation
animCon.UpdateVelocities(rb.velocity.z, rb.velocity.x);
}
private void FixedUpdate()
{
rb.AddForce(moveDirection * movementSpeed, ForceMode.Force);
}
Sorry had one more quick question, was reading through documentation and I wasn't sure. Is there a best practice for things like holding a button? I see people online suggest something like this:
playerInputActions.Player.Sprint.performed += ctx => isSprinting = true;
playerInputActions.Player.Sprint.canceled += ctx => isSprinting = false;
But just figured I should ask to see if there are any problems with this / if there's a better way
another option is just:
void Update() {
isSprinting = playerInputActions.Player.Sprint.IsPressed();
}```
note that while event based input handling is fine - I wouldn't recommend using lambdas as per your example as you won't be able to unsubscribe them.
A third option is just to make it a property:
bool isSprinting => playerInputActions.Player.Sprint.IsPressed();```
Yeah I was thinking about that as well, theoretically in this specific use case I think it would be fine(?) but I can see instances where lambdas aren't a good solution. I think I'll take that into account and consider making it a property instead since it's just as clean as a lambda imo.
Thank you!
Thank you! But shouldn't rigidbody movement be in FixedUpdate? Is this an exception?
Reading input goes in Update
Physics things go in FixedUpdate
However - in this particular case since you are doing a "one-off" force, it will not matter if your force is added in Update. That being said, one off forces should be using ForceMode.Impulse or ForceMode.VelocityChange.
I want to add a continuous force
then you should be using FixedUpdate for the physics and you should NOT be using .triggered
.triggered is only true for a single frame
Read the input in Update and add the force in FixedUpdate:
bool thrust = false;
void Update() {
thrust = input.Player.Move.IsPressed();
}
void FixedUpdate() {
if (thrust) {
rb.AddForce(Vector2.up * propulsionForce);
}
}```
for example^
ah I see. This makes a lot more sense, thanks
just realised that the person above had a similar question
hey guys, so i am working on a vr game where i can shoot things etc. i am trying to get input from the interactable and i am able to pick it up and all but when i want a action to be triggered in the interactable events category (i want to use activate) i dont recieve anything. it doesnt trigger the function that i am trying to trigger and i cannot find the problem. can anyone help with this problem?
You would have to share code etc
Kinda sounds like a #🥽┃virtual-reality problem though
yeah also shared it in vr but it is input as well tho so i thought it was something i could post here to
i am using the new input system so i dont really have code for it. i am using the package from unity so almost everything is in components that i use on the player and interactable gameobjects
show how you set it up
heyo, got a project which is basically a rhythm game, and like guitar hero, when you press the button it changes the sprite of the button, it works fine for all of my buttons, but when i change the scene or when i reload the scene, the green button stops responding. the inputs are the same as the other buttons, the scripts are the same, nothing is different. to make it work again i have to delete the script and apply it again, then it works fine. does anybody have an idea why it's doing this and how i could fix it?
- check console for errors
- start debugging
no errors, and ive been debugging for a while lol
alright i changed all the buttons to prefabs and now its the red and yellow buttons that dont change sprites :/
lol its back to only the green one not working
so after a lot of messing around i now have input. i wish unity had more detailed documentation about setting things up tho.
but what debugging have you done? Have you checked what the event system is seeing? Is there a UI element blocking them for example?
yeah event system is seeing no problems, when i press the button goes from 0 to 1, so all good there
might've found a fix, trying it now
You'd have to show your code and what debugging steps you've taken
well for debugging you can check in the console, thats mostly what i've been doing, and i can send the code sure
even though it shouldnt be a code issue because all 4 of the buttons have the SAME script
Printing logs is one debugging tool, yes. You were checking the console for what exactly? Did you add log statements to your code?
yeah, i'm checking which color of button is pressed, and i also checked if the input works, which it does (when i click on the green input binding it changes to 1, but the sprite doesnt change) so it seems it's a unity issue or something
ill send the code
📃 Large Code Blocks
Use 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 format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
If the input is being registered successfully that screams to me that the input system is working fine. It's handed over to your code at that point
yeah thats what i thought too, but since the code is the same for all the buttons, technically its fine since it works on the other buttons great
What is this "GameController"? Where does it come from? What's its life cycle?
its the game manager, just an empty gameobject with a gamemanager script managing things around the game
That's not what I asked about
I asked about GameController
Which apparently has the PlayerInput on it?
Where does that come from? Is that a singleton? Is it DDOL?
Can you answer these though?
no idea what a singleton is, but no its not ddol
and i dont really understand what u mean by where does it come from
yes
Which one?
My point is if you have two of them in the scene for example and you are finding by tag there's no guarantee you'll get the same one
oh no i don't have two of them in the same scene thats for sure
nvm its not fixed lol
And you can only have one PlayerInput
yeah
still haven't figured it out lol idk whats broken with it
How can i do get value negative in the input with the new input system???
For what kind of control?
I want to make a button to skip things in my UI. I want to use the new input system. How should I do it?
Is there a way to have "custom" data for certain control schemes? For example I want to have user-configurable "look sensitivity" for my look action for each control scheme (mouse/keyboard, PS, Xbox, etc...) that I can retrieve from my c# look script
Or would I have to have a separate config file that I load manually to assign to separate c# fields then just check which control scheme is being used in my c# look script and apply the corresponding sensitivity multiplier
For the controller of car, that the left trigger go back the car and the right trigger speed up the car.
Make a 1d axis with those two things.
Hi. I'm developing a rythm game BUT it will be on mobile ANDROID OS.
Does the new input system is better than legacy in term of performance? (quick touch response)
Which one should I use?
Performance is basically an irrelevant reason to think about the new input system.
Use the new system if you want event based input handling, runtime rebinding support, etc
Ok. So, what is relevant for optimized touch response? Do I have to use fixed update or something else?
I think you are worried about a non issue
have you confirmed that input handling is somehow a performance problem in your game?
How?
make an action
set action type to Value
set control type to Axis
Add a Positive/Negative binding
If I limit the framerate(for performance) to, lets says, 30 fps, with targetFrameRate and I listen to input in a fixed update at 60 fps it will be relevant in terms of responsiveness no?
Having an issue where pressing space during the rebind process doesn't rebind the current key to space. Every other key and mouse input rebind properly and pressing space makes the rebind UI blink so it knows a key is being pressed but nothing happens.
Ok but now how i read the value?
Same way you read any value in the input system
the data type will be float
it will come from either the InputValue or the CallbackContext or the InputAction depending on what style of input handling you're using
Why are you doing ReadValue<InputAction>??
It would be ReadValue<float>()
also what is input? Is it a float?
It should be in this example
See i want that my controller car is following way:
Yeah
Any idea?
I already told you what to do above.
ok
When I try to edit binding paths, control schemes or anything that generates the devices editor, Unity warns me about Unable to find style 'ToolbarSeachTextField' in skin 'DarkSkin' Used, which prevents that editor from drawing the search bar and "Listen" button properly, and the devices themselves are not interactable even though I can hover over them, clicking them doesnt change the display, ive also tried changing themes + restarting and it still produces the exact same error - I tried in both my existing HDRP project and a new BiRP project, in all my versions 2021.3+ this seems consistently broken, but works fine in 2020.3, all using the latest package - is this just a problem in 2021.3+ or something strange happening? I cant seem to find much about what causes it or how to fix it online other than comments saying "the bug tracker says its fixed but is not actually" Anyone else experienced this?
Hi all. I have a question about consuming events using the new InputSystem package. So I have a ui button that I want the user to be able to click in order to perform some action, but I also have the pointer input set up to interact with the world via a left-mouse click. The problem is that when the user clicks the button, this also fires the "interact" event, which I don't want. The ui button ought to consume the LMB event so that the user does not fire the "interact" event on the same frame. How can I achieve this?
I'm aware of Event.current.Use() which I could put in the ui button callback function, but afaik this is not the same thing as the new input system and doesn't seem to do what I want.
Another solution might be to do a camera raycast to see if the pointer is blocked by UI before performing the "interact" event logic, but I'm hoping there's a cleaner way to do this.
Thanks in advance!
Maybe you could setup different "Action Maps" for the different kind of input you want to split (image is not mine, just an example of action maps), then your UI logic can toggle that action map when its shown/hidden - I do this for my game where I have maps for "navigation" like opening the pause menu, clicking on buttons etc, "player" which are things like movement, jumping etc, "combat" where left click also shoots, attacks, etc - when the pause menu is open, I can disable "player" and "combat" to prevent shooting and moving when you click and press buttons on that screen, then re-enable them when the menu hides - my game may be a bit complex though as I can also have many menus and sub menus active at once, so I use a "manager" to know factors like if any menu is still open, and if the player is still alive before re-enabling input
im using unity's new input system and i want to switch between cameras (from normal to sniper cam)
tell me how
im a begineer
ive not used it, but this looks like a pretty good beginner tutorial. https://www.youtube.com/watch?v=HmXU4dZbaMw&ab_channel=BMo. From what I can tell the default input system is a lot more user-friendly, but I can see the advantage this has. other then that good luck ^-^
The "new" Input System in Unity still doesn't come pre-packaged and is complicated to understand at a glance. It's no surprise new game developers don't know where to look in the engine to find it, or how to use it.
In this tutorial, learn how a beginner can adapt their current project to use the new input system in a simple way, as well as usi...
Switching between cameras has nothing to do with the input system
i want to switch only the durtion of right click
then tell me the soln. as its not working @austere grotto
You would have to show your existing code
of?
You said "it's not working"
yeah
So, the code for whatever "it" is
i mean the script of my previouss code or of the new input system??
Whatever you want help with
i want to switch between cameras but i have unity's new input system
Again^^
using UnityEngine;
public class CameraSwitch : MonoBehaviour
{
public Camera normalCamera;
public Camera sniperCamera;
void Start()
{
normalCamera.enabled = true;
sniperCamera.enabled = false;
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Y))
{
ToggleCameras();
}
}
void ToggleCameras()
{
normalCamera.enabled = !normalCamera.enabled;
sniperCamera.enabled = !normalCamera.enabled;
}
}
!code
📃 Large Code Blocks
Use 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 format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
ik buti forgot
@austere grotto
pls reply
Hmm I see. But does that mean you have no interactable UI when your player controls are active? That doesn't seem viable for my use case, where I want keyboard/mouse input for gameplay but also UI elements that are interactable at the same time.
So I have a InputSystemUIInputModule in my scene, I assume this automatically enables the "UI" maps, which I figured was necessary. So I need to manually handle enabling/disabling this when I don't want UI events at all? Hmm... I could try setting this up but I'd need to do it in a way where some of my HUD buttons are still interactable...
I think where I might be getting wires crossed is that the button event comes from the UnityEngine.UI.Button.onClick callback and the pointer event comes from the InputAction.onPerformed callback. But literally every Unity game that uses UI buttons and the new InputSystem must have this same problem then.
Good morning everyone!
Last night I was up very late, way later than is good for my day job, trying to make my thus far simple app run on a Meta Quest 2. I got it running in that its in the headset, but as I turn my head the scene didn't change, nor could I see any effect from moving hand controllers.
I worked through several video tutorials, no joy, but they all seemed to be a bit older. I'm running the current Unity, I wonder if someone could point me to a current tutorial, or perhaps some hints as to what to check? There is so much to this I don't even know where to begin looking for the issue.
Probably a question for #🥽┃virtual-reality
In my case, I am working on a FPS so by design I prefer the player to not interact with much UI when player controls are active, though thats something you can choose, as entire ActionMaps can be toggled, or just specific Actions, they all have a .Enable() and .Disable() func - toggling that InputSystemUIInputModule could be another option as well, though I havnt personally tried it to comment on that approach, you may still be able to use IPointerHandler interfaces such as IPointerEnterHandler, IPointerClickHandler, etc, which could be a good mix for what your looking for?
There are many ways you can use the input system, using a action map is one way, you can also poll input in Update as another, I believe there are even components for handling object-specific and global inputs
Thanks for your reply! Yeah I think you're right that there are just many ways to use the input system package. Maybe too many such that it isn't obvious what the correct way is for a specific situation haha.
I've found that doing this check inside my InputAction callbacks does pretty much exactly what I want:
if (EventSystem.current.IsPointerOverGameObject()) return;
But now I get annoying log spam:
Calling IsPointerOverGameObject() from within event processing (such as from InputAction callbacks) will not work as expected; it will query UI state from the last frame
I'll just store the value in a bool in update to get rid of the warning spam, but glad it's working now.
Hello,
I am developing a car game.
I want my car controls similar to Forza game for gamepad 🎮
Can someone help me with setting up input asset of new input system and script for mapping them....!?
how come if i spawn more than 1 player the player that was spawned last wont have the current scheme and devices connected?
PlayerInput specifically finds unused devices to bind to
If one is using kb+m the second won't
is there a way i could prevent that?
because all i really need is to just spawn in 2 players
with the same scheme (if possible)
Don't use PlayerInput
what sould i use instead?
One good option is the generated C# class from your actions asset
does it make a difference if the second player is online and not local?
If the second player is playing on a different computer then they don't need a control scheme at all on this computer
Disable/destroy or don't spawn anything related to input on such an object
Hi everyone, i have actually a bug with the unity Input system, i don't know if it's a bug but that's a problem.
I have a first scen with 4 canvases, all the canvases are asssigned to a gamepad, i choose a prefab of character with all the panels in the canvases with my four gamepads.
After all the players selected, the script move in a new scene were my players are instanciated, my 4 players are instanciated but i control them all with my Player 1 gamepad, what can i do to fix that ? sometimes i have just one player controlled by all the gamepads
Were you able to figure it out?
No, not yet
`
if (Input.GetKey(KeyCode.W))
{
CancelInvoke("DecelerateCar");
deceleratingCar = false;
GoForward();
}
if (Input.GetKey(KeyCode.S))
{
CancelInvoke("DecelerateCar");
deceleratingCar = false;
GoReverse();
}
if (Input.GetKey(KeyCode.A))
{
TurnLeft();
}
if (Input.GetKey(KeyCode.D))
{
TurnRight();
}
if (Input.GetKey(KeyCode.Space))
{
CancelInvoke("DecelerateCar");
deceleratingCar = false;
Handbrake();
}
if (Input.GetKeyUp(KeyCode.Space))
{
RecoverTraction();
}
if (!Input.GetKey(KeyCode.S) && !Input.GetKey(KeyCode.W))
{
ThrottleOff();
}
if (!Input.GetKey(KeyCode.S) && !Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.Space) && !deceleratingCar)
{
InvokeRepeating("DecelerateCar", 0f, 0.1f);
deceleratingCar = true;
}
if (!Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D) && steeringAxis != 0f)
{
ResetSteeringAngle();
}
`
Code for input
I need code for gamepad input like the one Forza or nfs has implemented
this uses Input, not InputSystem
The mapping of input
For eg. RT to throttle,
LT to reverse, A for handbrake etc
Unity inputs for xbox Gamepad mapping is difficult for me to implement.
for that, you might want to use InputSystem
I need to convert This code for gamepad inputs
InputSystem is really good for 3 things: 1) mapping different types of controller setups, 2) Calling events based on controller inputs, and 3) capturing more advanced inputs (like tap vs hold vs cancel)
first, you would change the code to use the new input system. Then you’d go to the relevant InputSystem asset and add separate bindings/layouts for different types of controllers
i’m skipping details, but that is the gist of it
and you can check out tutorials to see how that works
I have seen videos but I am unable to understand it
Input is for really quick-and-dirty input detection. Fast to code, but very few features, and few opportunities to improve
do you understand delegates?
Yeah I have worked with them
ok, InputSystem invokes delegates what different sorts of inputs are called
the delegates spit out an object of type CallbackContext
CallbackContext gives information like what sort of interaction (tap vs hold etc) and phase (started, canceled, performed)
you subscribe a method to a delegate of your input system. InputSystem invokes if input happens, then the method goes off
understand?
this is a lot better than having everything that needs to check for the A button checking every single frame “if pressed A OR pressed A equivalent on XBox OR pressed X on PS5 OR…”
the inputaction asset allows you to define bindings
so you can make a given input be called “Jump”, and this is invoked by spacebar (on keyboard), X on PS5, A on XBox…
that is done in the menu of the InputActionAsset
In this code, I am checking the "if's" in the update method for getkey().
Is there any similar getkey() for gamepad ?
yes, but you don’t want to do that if you use InputSystem
Ohh okk
you want to subscribe delegates
then if you want to make commands cancel each other (like brake button cancels acceleration button), then you want to use a command pattern
Ohh okk
command pattern is like: when the button is pressed, you store an object that says to do something. When ready, you sift through and decide which of those actions to do
and you might even simplify with an enum.
Ohh I get it
enum CurrentAction { Neutral, Braking, Accellerating} (as enum flag)
👍.
gl
I will try to implement accordingly
for turning, I would use the .ReadValue method
.ReadValue gets the current value of a given controller input.
and I would ReadValue for control stick because you want to read it every frame. Not just on frames where you actually press something.
i would NOT ReadValue for buttons, because part of the benefit is saving time because you ONLY call the function for braking when the brake is pressed, for example
those should be subscriptions
Ohh okk 👍
I'm getting some really weird behaviour on Linux. (Unity 2022.3.14f1 on Linux Mint 21.2)
What I want to do: Right clicking locks the mouse and lets the player rotate the camera. When the button is released, the mouse gets unlocked and is positioned in the same place as before. The following code works perfectly fine for this on Windows.
private Vector2 pos;
public void Lock()
{
pos = Mouse.current.position.ReadValue();
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
public void Unlock()
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
Mouse.current.WarpCursorPosition(pos);
}
However it behaves weird on Linux.
- WarpCursorPosition doesn't position the cursor on the correct position when playing in the editor. In the build it works fine.
- When getting mouse movement from the old Input system (Input.GetAxis("Mouse X")), the values are smaller when the cursor is locked.
- When getting mouse movement from the new Input system (Mouse.current.delta), the value sometimes "snaps back" when the cursor is locked. This only happens when the mouse is moved in a negative direction. So I move to the left and get -5x or something and on the next frame I get a positive value, as if the fixating the mouse back to the center counts towards the delta...
How do I get the names for the 2d vector keys?
like I am getting normal button presses like this
I'm just not too sure how to get them from a 2d vector
what does it show when you do that for the 2d one
its apparently the same type as a regular button so im not too sure
try it and see
ah wait I see what you mean
when I do this exact same thing its an empty string
huh strange
maybe theres a different way I should be grabbing them instead of indexing the array
input system is confusing lmao
I think you need to get the index of composite, and then iterate from it until you encounter something that is not a part of composite. Lemme check it.
idk I was hoping it was gonna have its like
own type but I think I remember running into this same issue a while back its just strange
it should be fine for now
if I just index if from the array with those numbers
but like obviously if theres a much better way I'd love to implement that
I bet they made it like this to flatten the hierarchy.
Am I also able have an editor reference to an action or is it just only to make a script only one
ah I found it
its quite literally called InputActionReference
@solid forum
[SerializeField] InputActionReference actionReference;
void Start()
{
Debug.Log (actionReference.action.GetBindingDisplayString());
foreach (var binding in actionReference.action.bindings)
{
Debug.Log($"{binding.name} {binding.isComposite} {binding.isPartOfComposite}");
}
I don't see any references between composite and parts of composite, so I guess you will have to iterate.
thats alright
I kinda hate how GetBindingDisplayString() displays keys in a different order than I configured it. 😠
thats unity for you lmao
Now I can't seem to get the rebinding to work
actually before I continue im gonna make sure its the right reference
but yea I'm not sure because even if I like hard code it to be control (just as a testing key) it doesnt override any of my binds
whole code
yea strange it runs it but it doesnt do anything
maybe the index is wrong?
actually yea I believe so wtf
Does anybody know how the docs are indexing with actions
I'm assuming thats just like
all of this
actually huh something as direct as this isn't working
ah its probably the way im using input system
its probably because this project is creating a new Input everytime it needs to use controls
which probably isnt what I wanna do
I prolly wanna use only one and use that
yea this is the issue
since I started this project back in like late 2021
Yeah you can just make one shared instance and reuse it
yea thats what im gonna do since I didnt see a problem creating a new one each time until now
Yep if you need shared state such as enabled/disabled actions or rebinds, that's tried to the instance
haha yea drove myself crazy for an hour, at least its better practice to do it this way
Still wondering how I am able to do this because I can't seem to change the bind while using a reference
im mistaken PlayerInput is its own class
Alright I think im back on track, I haven't finished this but I started using PlayerInput as previously I was using just the raw input
why doesnt user #1 have any paired devices?
What devices are you expecting them to get?
The same keyboard and mouse? It's never going to assign the same device to multiple users
my current issue is:
i have a build and the editor that im using to test. whichever is the "host" has a control scheme and paired devices whilst the player that joins through localhost doesnt
i even tried it on another computer and the issue persists
whichever is the host has working controls and the second player doesnt
That doesn't make any sense. You shouldn't have two input users if it's a networked game
Multiple input users is only a thing for local multiplayer
I. This screenshot you're looking at users on THIS computer
Oh I guess you're running both clients on one PC for testing, yes?
yes
That's not exactly a realistic scenario
i can try having one running on this pc and another one on a different pc
Anyway just destroy/disable any input handling objects or components for all players except the local player
but last time i tried that it still didnt work
but lets say i do want 2 objects/players to be controlled locally on the same pc
do i make 2 separate schemes, separate binds for each or ??
Yea
Or just one scheme and multiple devices that satisfy it
For example a gamepad scheme can be reused by any number of plugged in gamepads
yeah, gamepads i get
but what would i do if i want one to use wasd and the other use arrows?
Then you get to go down this rabbit hole https://forum.unity.com/threads/multiple-players-on-keyboard-new-input-system.725834/
ok so i tried to connect one through my pc and the other through my laptop
same thing
Well you still need to do this
but wont that break inputs for the other player?
ok i finally understood what you mean. but how do i make sure that the component is on the local player only? since it gives both players the component when you connect
Two ways. Either have it on the prefab to start and if (!IsMine) Destroy(whateverHandlesInput); or don't have it on the prefab in the first place and if (IsMine) Instantiate(whateverHandlesInput);
Do you know why my project is now In QWERTY ? it's a bit strange but I have a AZERTY keyboard so I put my mouvement input to ZQSD but now it work only withs the input WASD like if my keyboard was In english, but he is still in french, I can still write normaly in the unity editor with my french keyboard but when I lunch the game it's like if I play with a English keyboard
which of these are you using?
alright so i did this and on paper it looks good. the control scheme and devices look good, but it doesnt actually send any messages. the "On___" isnt working for whatever reason
What is "it"?
Are you using PlayerInput?
In send message mode?
where can I find this option ?
and the player input is only on the local player
Make sure at runtime that all looks good and is enabled etc
Path -> Keyboard
it does
second player
first player
i put some prints to see if the mssages are being sent, and theyre not
thx for your help it solved the issue 🥳
Unrelated to coding but how do I fix this, the UI for the InputActionAsset is not showing properly
You have a log statement saying instance assigned but that doesn't mean you actually assigned or that you assigned the correct one, or that you assigned it to something valid
I have the same issue, tried every Input System package version from 1.0.0 to latest 1.7.1, and many Unity versions from 2020.3.x to latest 2023.1.x, and sadly, it seems specific to the version of Unity - for me, when it happens I get a warning saying Unable to find style 'ToolbarSeachTextField' in skin 'DarkSkin' Used (which apparently dark or light skin doesnt matter, same error happens in both, also tested with resetting layouts) followed by an image similar to yours, after playing around with the Package Manager and different LTS versions, it seems like 2020.3.x works fine, and every version after that does not, regardless of the Input System package version your using
From what I can find online, the general consensus seems to be "the bug reporter says its fixed but its not actually fixed for some versions", it seems Unity must have mistyped a style in newer versions, this post seems to have a solution that may or may not work: https://forum.unity.com/threads/unable-to-use-input-system-panel.1450204/#post-9088999 , alternatively, you may have to downgrade to 2020.3.x from my testing so far if the link doesnt help (you may get package errors when doing this, and potentially other errors if your using a render pipeline or features that are version-dependent)
With your project closed, the fix mentioned in the post:
- navigate to the cache directory (
C:\Users\{user}\AppData\Local\Unity\cache\packages\packages.unity.com\com.unity.inputsystem@{version}\InputSystem\Editor\Internal\AdvancedDropdown\AdvancedDropdownGUI.cs) - edit line 16
public static readonly GUIStyle toolbarSearchField = "ToolbarSeachTextField";add a "r" to the word "ToolbarSearchTextField" - delete your projects Library folder
- relaunch your project (your last opened scene may reset to default)
- open a input action asset window (if one is already open, close and re-open it)
If neither seemed to help, hopefully someone else could provide more insight and alternatives
I have a DualShock 4 controller connected to my PC via bluetooth which is recognized/working fine in Unity, but the UnityEngine.InputSystem.PlayerInput.onControlsChanged event is constantly switching between a (non existent) xinput device and the dualshock device whenever I do any action on the dualshock device. Any idea why this might be happening?
so i'm using a dual shock 3 controller connected through the necessary means (and i tested with both steam and roblox to see if controller works on all joystick inputs and it does) and I noticed with Unity that it registers my left stick for left and right input and right stick for up and down input. Is there a way to have it all set to the left stick?
left stick/gamepad and leftstick/dualshock
that said unsure of weird quirk but it can't seem to read the input of the left stick when i move it up and down
only when i move it left and right
what's even weirder is that on the classic input manager it can read all four axes
from the left stick
when you say gamepad triggers you mean stuff like L2/R2 (LT/RT)?
Yup
I can't seem to figure out how to add them to my input manager.
hard to tell which gamepad button maps to which axis.
28 joystick axis later. none of them are connected to the triggers.
seems like it should be joystick button 10/11
has anyone attempted to map a DS3 (DualShock 3, PS3) controller to unity?
just ask cause on specificity, for some reason left and right on the left stick are mapped to the up and down on the right stick and i'm a bit confused why.
I wouldn't mind if I was given a way to manually recalibrate the controller on the engine because i know it's not a hardware issue when i tested my controller on a few games on steam and roblox as well as an online controller input tester.
Not sure if this is the right spot for it but I'm having issues scrolling with the Scroll Rect, everything looks okay according to a tutorial I was following.
If I click and drag outside of the buttons up or down, nothing happens
Elastic works sort of but it's like a rubber band.
ty
For those lost and ran into the same issue as me I found out setting the controller's HID device mode to XInput solves the issue
i should also preface i use DS4 windows and DSHIDMini to allow my PS3 controller to run on my laptop
and on DSHIDMini is where i set the controller's HID device mode
Has anyone tried to localize keyboard input? There's very little to be found when I google it seems, or I'm just not hitting the right terms
I'm using the input system to rotate an object while I hold a direction, but while I'm holding a direction, it causes the object to very quickly switch between the correct direction and the exact opposite of that direction, and the direction it ends on is one of those, seemingly randomly
You are misusing Quaternions, they do not work like your code assumes they do
Don't use the constructor, use the helper methods like AngleAxis
The bottom code is doing nothing
Hence why it's all greyed out
The top code, the values are probably just not scaled enough, have you tried debugging it to see what angle is?
Bingo, that was it. Thank you
A basic one here:
https://docs.unity3d.com/Packages/com.unity.textmeshpro@1.3/api/TMPro.TMP_InputField.html
How can I set an input field to that greyed-out, disabled state that means that a user can't edit the input field (the type of state that you see all over the internet)? I can't find it at the above link.
Thanks!
question is there a way with the new input system to unify a group of actions in a function?
i plan on having four actions that use the same modifier but use a different face button
and all four of them basically are selecting a skill from an array of 4 skills
so is there a way i can cram the 4 action functions into one so i don't just have each one call the same function but with an index value?
Any cute thing you do is going to be more complicated and less flexible and less supported than simply making 4 actions. Don't overthink it.
gotcha
Hi
How can I make a positioning system for a racing game with a pass on the number of laps each vehicle has completed in Unity?
How can i make a coop setup screen using the player input manager?
I so sorry
question. Tried doing a button with modifier combo for the skills (basically had square button for normal attack but L1+Square for skill attack) but it seems as though both of them are called at the same time. Is there a way to fix it so that if the modifier button is pressed it ignores the action variant without the modifier? (like if i press L1 + Square it should not play the action bound to only square)
turns out the answer was in the input settings. for consume input. Kinda wish someone pointed that out to me even if it was obvious.
Why am I getting DualShock AND XInput device input when using DualShock input devices?
It's creating conflicting bindings in the new input system
It seems like currently the only options are to restrict controls to keyboard&mouse/generic gamepad, or don't use the new input system at all
because you can't differentiate between PlayStation/Xbox controllers, since PlayStation controllers keep invoking XInput(Xbox) controls as well...
And no Steam is not running, and I don't have DS4Windows, I tried google already
Xbox controllers work fine, DS controllers register both Xinput & DualShock input device
the input system documentation explicitly states it supports DS4 controllers, so why is it duplicating all inputs as an XInput device as well?
does it natively support DS4 controllers or is it emulating it through an XInput device
What would be the best way to go about just detecting a general mouse click/screen tap.
I don't need to detect the tapping on any specific object, as it's simply to progress dialogue.
A variation of InputAction.WasPressedThisFrame()
Hi, I created a virtual cursor that I can use with a controller except that the problem is that it no longer detects the interface if I launch the game with a resolution other than 1920x1080
With another resolution the cursor (the green square) detects the button even though it is not positioned on it
Does anyone have a solution please?
You'd have to explain how you created the cursor
In my canvas i created an image for the cursor, i put his anchor in left bottom, and then i added the script Virtual Mouse. My canvas is scaled with screen size 1920x1080
Why am I getting DualShock AND
Hey, I'm a bit new to the new input system and I'm trying to get each player assigned a controller.
Right now I have 2 controllers plugged in and both players respond to both controllers.
In my player input script I created a PlayerID that gets assigned in the inspector and based on the player ID it will use the actions 1 or 2 depending on the player number. This helped me with sperating keyboard input from gamepad, but not gamepad from gamepad
Duplicating the input actions isn't the way. Look into PlayerInputManager and PlayerInput which automatically assigns players to input devices
Every tutorial I see just has the player created when the button is pressed and they are assigned different controllers.
But when I do it they are assigned the same controller
It must be my script that is wrong
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I was trying to use the Player Input Manager, but it just wasn't working
PlayerInputManager and PlayerInput is how they do that. You're using the generated C# script which isn't really conducive to local multiplayer unless you want to manage user-device mappings yourself
ohhhh I'm not supposed to use that??? lol
I was under the impression that I had to use the c# class
Thank you for the advice
There are many ways to use the input system and that is one of them
Hey, how can I use UI input system with multiple game objects containing buttons?
Basically I have a state machine, if I choose an option to switch to a different UI object, what do I do to enable those buttons for the Input system?
Do I just Button.Select() whenever I want to "focus" new UI element?
Hi, I'm struggling with something in VR. Unity version 2021.3.9.
I added a Rigidbody and an XR Simple Interactable as components to an object.
I then added a trigger function/method for some in-game menu to the On Select Entered of the XR Simple Interactable.
This works well enough: the way I do it in-game, I'm coming up to the object, intersect it with one of my hand models, then press grab, and the menu pops up fine.
The issue arises afterwards: once the menu is closed, I notice I can go wander wherever else in the scene and it turns out pressing grab again on the SAME controller I originally used to bring up the menu… brings it up again.
If I go back to the object and do it with the other hand, now both hands have “gained” the right to trigger the interaction remotely, if you will.
How can I fix that? I'd want to always only be able to trigger the menu by properly interacting from up close. It works fine at first, but once used, my hands seemingly obtain magical superpowers, and I don't want that~
Essentially, this is the opposite issue to your usual “SimpleInteractable doesn't work with direct interactions AAAAAA” ramble. In my case, it actually interacts too good and I'd like it to stop thinking it's interacting at a distance when it's really not anymore.
Don't hesitate to ping me, by the way, if anyone can help! ^^
I'd say... You'd have to show the code
Makes sense, but I guess what’s relevant is mostly inspector configs? Or can the actual method triggered by the “On Select Entered” cause the issue here?
OKAY got it! My code indeed could've helped, though it alone wasn't enough to view the issue: I configured it to disable the hands, so they thought they were still interesting the object.
Trying to rebind an xbox controller. The rebind command is not detecting it. It detects keyboard input just fine. All other functionality of the gamepad works (movement, etc...).
playerInputActions.Player.Disable();
InputAction inputAction = playerInputActions.Player.Interact;
int bindingIndex = 1;
if (inputAction != null)
{
inputAction.PerformInteractiveRebinding(bindingIndex).OnComplete(callback =>
{
Debug.Log("Binding complete!");
callback.Dispose();
playerInputActions.Player.Enable();
onRebind?.Invoke();
PlayerPrefs.SetString(PLAYER_PREFS_INPUT_BINDINGS, playerInputActions.SaveBindingOverridesAsJson());
PlayerPrefs.Save();
}).OnCancel(callback =>
{
Debug.Log("Binding cancelled!");
callback.Dispose();
playerInputActions.Player.Enable();
onRebind?.Invoke();
})
.WithControlsExcluding("Mouse")
//.OnMatchWaitForAnother(0.1f)
.WithCancelingThrough("<Keyboard>/escape")
//.WithBindingGroup("Gamepad").Start();
.Start();
}
Hey guys i'm having trouble with the new input system and the Camera.ScreenPointToRay function
private void OnAimingTarget(InputValue value)
{
Vector2 rawInput = value.Get<Vector2>();
Ray ray = _mainCam.ScreenPointToRay(rawInput);
_plane.Raycast(ray, out float enter);
Vector3 target = ray.GetPoint(enter);
Vector3 aimingDirection = target - transform.position;
aimingDirection.y = 0;
AimingDirection = aimingDirection;
}
after this method is called aimingdirecion has some weird value
What did you bind the input action to?
to the mouse position
Also what is the "weird value" and how does it differ from what you expect
it is kind of off-centered i guess
Wdym
if i try the ScreenToViewPortPoint function for example and try going with the cursor on the bottom left and on the top right i get respectively (0, 0) as expected and something around (3.8, 2.1) which is really weird
shouldn't i get (0, 0) and (1, 1)?
Do note that since you're doing this in OnAimingTarget it's only going to update when you move the mouse.
What you really need to do is just have this code update the raw input variable but then do all the rest of the code in Update
For viewport point yes unless you're using the wrong camera
yeah that shouldn't be a problem because i'm just rotating the character with AimingDirection
mhh let's see ahah
Definitely a problem because when you move the character it won't be rotated properly until you move the mouse again currently
now i feel embarassed
i wasn't using the right cam
thank you 🤦♂️
is rewired still necessary ? I heard they changed the input since since unity5/2018 and I initially bought rewired because of that. So now that they changed it what is the main point of using it now ?
Rewired was never necessary, and it still is not. You can certainly still use it though, and many people still like to
The "new" input system is pretty great though. I suggest trying it out and seeing what you like best
The main draw of rewired afaik was runtime rebinding.
The new input system supports that out of the box so probably little need for it
Looking for a tutorial on new input system, mainly focused on UI and how to write good for more complex UI instead of 3 buttons examples I see everywhere.
Paid tutorials are fine if not crazy expensive 😄