This is no joke right here. Really daunting going through this. Well done. I'm glad I went through this, and I really appreciate the hard work that went into putting this together.
A bug was found where, if you separate a composite binding (ie. A vector2 up/down/left/right binding) into 4 separate bindings that you want to rebind, a duplication was possible within the composite binding itself. To fix this, you'll need to change the CheckDuplicateBindings functions to the following: private bool CheckDuplicateBindings(InputAction action, int bindingIndex, bool allCompositeParts = false) { InputBinding newBinding = action.bindings[bindingIndex]; int currentIndex = -1; foreach (InputBinding binding in action.actionMap.bindings) { currentIndex++; if (binding.action == newBinding.action) { if (binding.isPartOfComposite && currentIndex != bindingIndex) { if (binding.effectivePath == newBinding.effectivePath) { Debug.Log("Duplicate binding found in composite: " + newBinding.effectivePath); return true; } } else { continue; } } if (binding.effectivePath == newBinding.effectivePath) { Debug.Log("Duplicate binding found: " + newBinding.effectivePath); return true; } } if (allCompositeParts) { for (int i = 1; i < bindingIndex; i++) { if (action.bindings[i].effectivePath == newBinding.overridePath) { //Debug.Log("Duplicate binding found: " + newBinding.effectivePath); return true; } } } return false; } This also affects the "reset" button, so you'll need to change the ResetBinding function to the below as well: private void ResetBinding(InputAction action, int bindingIndex) { InputBinding newBinding = action.bindings[bindingIndex]; string oldOverridePath = newBinding.overridePath; action.RemoveBindingOverride(bindingIndex); int currentIndex = -1; foreach (InputAction otherAction in action.actionMap.actions) { currentIndex++; InputBinding currentBinding = action.actionMap.bindings[currentIndex]; if (otherAction == action) { if (newBinding.isPartOfComposite) { if (currentBinding.overridePath == newBinding.path) { otherAction.ApplyBindingOverride(currentIndex, oldOverridePath); } } else { continue; } } for (int i = 0; i < otherAction.bindings.Count; i++) { InputBinding binding = otherAction.bindings[i]; if (binding.overridePath == newBinding.path) { otherAction.ApplyBindingOverride(i, oldOverridePath); } } } } And finally, to ensure you can use either WASD separately OR together, be sure to update the ResetToDefault method to: public void ResetToDefault() { if (!ResolveActionAndBinding(out var action, out var bindingIndex)) return; ResetBinding(action, bindingIndex); if (action.bindings[bindingIndex].isComposite) { // It's a composite. Remove overrides from part bindings. for (var i = bindingIndex + 1; i < action.bindings.Count && action.bindings[i].isPartOfComposite; ++i) action.RemoveBindingOverride(i); } else { action.RemoveBindingOverride(bindingIndex); } UpdateBindingDisplay(); }
@@Storm3532 Fix Below, explanation: Essentially when it's a composite, the bindingIndex that's passed in is its index within the composite itself, and not within the entire actionMap list of bindings. For example with a WASD composite, bindingIndex is 0 for the header (we don't care about), the first item in the composite will be 1 (W in this case), second item will be 2 (A), and so on. With the currentIndex++ where it's at, it matches our composite binding's index to the ENTIRE list of bindings. Since the elements aren't 1-1 in both lists, it means index will be off and will try to compare itself against itself, finding a 'duplicate'. Moving currentIndex++ down so it only starts incrementing once we've found our composite object will make it so the binding item will start at 0 at that point, it will skip the header (because the header isn't considered "isPartOfComposite"), and then it will compare your composite element to the first item in the composite. The indexing should be correct so it will skip over itself and not have a false duplicate. :) foreach (InputBinding binding in action.actionMap.bindings) { if (binding.action == newBinding.action) { currentIndex++;
@@Malaron2 That fixed that issue. Since we're sharing solutions. I discovered that the rebound buttons would only load when I opened the related keyboard or gamepad canvas. Solution: I also added the save rebind script to the EventSystem so it loads when the scene is loaded.
this is by far the best input rebinding tutorial for Unity on TH-cam, bar none. I have viewed other tutorials and they are not as robust as this one. This one results in a professional rebinding functionality, suitable for commercial games
What an absolute gold mine of a video. I am about to enter polish phase on my tower defense game and wanted to offer custom key bindings, but the API is just so hard to take full advantage of. You just saved me hours of trial and error. Cheers mate!
Bro you are an absolute LIFESAVER! I was banging my head against the wall trying to figure out how to prevent duplicates for hours, and trawling through the code was just getting me more confused! Thanks so much for this video.
lots of time, lots of sanity saved and lots of features provided, thanks for helping me modify all those high level language programing of unity's prebuilt code
Hey, thanks for the great tutorial. I set up my input system differently, thought I'd share. Instead of using the UI based Input Action control binding, I did it all in code. I set up an "InputAction" for each action, and used the "AddBinding or "AddCompositeBinding" function to bind keys/buttons to the action. This way, I can store my control binding map in a json file and then read it and load the controls easily. For using these actions, I pass a function definition as an "InputAction.CallbackContext" and add it to action.performed and (optionally) action.canceled. This way, the function gets triggered directly when any action is performed. So, I don't need the bool variables to detect when an action has been performed. The triggered function will receive the context and you can detect whether the action was performed or canceled from the context. I wasn't sure out how to do the re-bindings and stuff, but your tutorial has given me a good idea. Thanks again!
Thank you for putting this video together. Really helped me out and I really enjoyed your method of tutorial making. I've subbed and will be checking out your other work!
This is by far one of the best Unity tutorials that I have ever seen! What would be the right approach if one wants to rebind controls for say 2 players on splitscreen. Let's say we already assigned gamepad controllers for each player and we know which on is which. I just can not figure out how to check during rebinding to accept only the inputs from specific player's controller - and not the other one (since while one player is in rebinding mode - and waiting for the key to be pressed - we do not want to detect keypress from another player's controller). Of course each player needs its own input scheme - even though in their structure they are identical (clones) - but still we need two - that I figured out and that works fine - I just need to prevent rebinding taking inputs from other player's controller. Once again thank you so much for your videos!
Just a tip: You can also press Ctrl + E + C to comment out lines of code, making it a bit easier to reach the keys with one hand in one single motion ;-)
Very nice, very comprehensive overview of how to so rebinding thank you so much. In the beginning you mention rebinding is easier with player input than generated c# classes, but not say why though?
the reset function is not working for me. i've double checked my RebindActionUI prefab reset button and it's set to call the resettodefault function when the player clicks, but for some reason, nothing happens when I press the button. I've got the actual rebinding portion of the tutorial done, but the reset buttons, which were apparently supposed to work out of the box, just are not working for me. Any advice? I followed the code for the reset function exactly
Love this thank you for making it!! Would anyone know how to do composites with the gamepad icons example? I have one action that requires you to hold two buttons at the same time, and it shows properly with text, but the icons don't know what to do. thanks!
Thanks for the tutorial. The last part, saving rebinding, getting: 'InputActionAsset' does not contain a definition for 'SaveBindingOverridesAsJson' and no accessible extension method 'SaveBindingOverridesAsJson' accepting a first argument of type 'InputActionAsset' could be found (are you missing a using directive or an assembly reference?) any idea?
Followed every step, but when it comes to testing the rebind, the rebindUI is updated with my new keys but my character still controls using WASD. I assume this is because I have generated the C# class you said not to, but I need that class. What do we do in that case?
I just ran into the same issue. The video didn't really explain it, but you shouldn't need the class for anything. if you followed his tutorial exactly then you should have a "User Input" script. Inside of that script make functions to get the input actions you defined and you can use those. Here's my code down below (I've needed to modify mine for other reasons) private PlayerInput playerInput; private InputAction moveAction; private InputAction attackAction; private InputAction interactAction; private InputAction crouchAction; private InputAction jumpAction; private InputAction sprintAction; private InputAction pauseAction; private void Awake() { DontDestroyOnLoad(this); playerInput = GetComponent(); SetupInputActions(); } private void SetupInputActions() { moveAction = playerInput.actions["Move"]; attackAction = playerInput.actions["Attack"]; interactAction = playerInput.actions["Interact"]; crouchAction = playerInput.actions["Crouch"]; jumpAction = playerInput.actions["Jump"]; sprintAction = playerInput.actions["Sprint"]; pauseAction = playerInput.actions["Pause"]; } public InputAction getMoveAction() { return moveAction; } public InputAction getAttackAction() { return attackAction; } public InputAction getInteractAction() { return interactAction; } public InputAction getCrouchAction() { return crouchAction; } public InputAction getJumpAction() { return jumpAction; } public InputAction getSprintAction() { return sprintAction; } public InputAction getPauseAction() { return pauseAction; } Hope that helps!
I found an issue where if you cancel the rebinding and the binding contains composits, the changes will not get revered and will stay as is. This causes a duplication glitch that I've tried fixing myself, but could not fix. I also found an issue where if you rebind an action, then put in a duplicate, it resets the value back to its original value before the rebinding. However, I found a solution to this error by putting in a variable to remember what is was before the method is performed, so it can revert to that by using "action.ApplyBindingOverride(bindingIndex, _binding);". _binding is the variable that stores the previous value, which you can set before the operation is called: string _binding = action.bindings[bindingIndex].effectivePath;. Can you please help me with the original problem with that being canceling a rebinding that contains composits (which don't revert the changes)? Thank you!
I need help! Everything works fine but in my game my player's jump height is variable on jump key Being held but so i changed the jump input is userinput but now my player jumps by itself when jump key is held, which is not what i want
I updated the Input System so everything is on point, but the keyboard stopped working with the Action Map I use for the gameplay. I don't want to do all of this without updating, because I know it'll be worse in the future, and the listen function doesn't even work for me in the old version.
Found a bug and I am not sure how to fix it. Let's say you have one button set to R2 and another set to L2. If you remap the button with R2 to X and proceed to switch the second button to R2. When you go to switch the first button back to R2 the font updates but Waiting For Responses is still visible. It would be neat to add the set of code to swap like when you reset but nothing happens if I add action.RemoveBindingOverride(bindingIndex); to PerformInteractiveRebind during check for duplicates nothing happens. Any advice would be great.
Hello. The thing in 4:00 technically is not a singleton. Its a global static reference that self-manages. For it to be singleton, it should automatically instantiate itself. Just a minor nitpick.
In my case after I pressed one button for rebinding its not closing the Rebindingpanel :/ EDIT: found out I missed to return false on duplicate instead I returned also true at the end
Hopefully you see you this, I was just wondering, if You assigned those sprites for xbox but if the player only has a PlayStation controller wouldn't the player only see xbox controls until they rebind ? is there a way to set the default inputs based on what controller gets detected ?
Hi everyone! First of all, great video, it really helped me set up the rebinding options for my game! Still, I need help with a curious issue. Since I put all key reset into one single button, I managed to modify CheckDuplicateBinding function to integrate the swapping method you describe. This way, new bindings immediately swap with duplicates, if found. And everything looks like it's working fine. Now, I encountered a small issue I'm not sure how to solve, so I'm hoping anyone here could point me in the right direction... As I said, rebinding perfectly works as long as I stay in the Editor. When I build the game, however, something weird happens: I can rebind keys without any trouble, but if I close the pause menu (both with escape and by selectin "resume") and then reopen it, the rebind is maintained, but the controls list displays the original, default keys. Example: M key opens map; I rebind the function to key G; now the list says MAP - G and if I close menu and test, G key opens map (perfect); now, if I reopen the menu, it says MAP - M (original binding), but the G key is still the one performing the action. So, to wrap up, the rebinding works perfectly but it DISPLAYS incorrectly... and only in the build, not in the editor, where new keys are displayed correctly. Any idea on what changes between editor and build? Or on where I should go looking for a solution? Thanks!
Hello i'm actualy making a fpv drone video game and i want us to be able to use any radio transmiter. In most of FPV Simulator you have a system call the joystick calibration where you have to move your joystick and the game listen to the input of your controller and bind it. I want to do the same system into my game but i realy don't know how so if somebody know how to do it i will realy apreciat it. Thanx
My question is not entirely related to this video but maybe somebody can still shine a light on it for me. Can I use Unity to create a tool that remaps and/or automates controller input? I've made some makros with AHK but I'd rather switch to something more advanced and polished that also uses a C-style language because I don't really like the syntax of AHK and its documentation is very bad. I know that Python is the first choice for tasks like this in the Open Source community but I don't really like that language either.
Hey there, thanks for this video. I noticed that .WithCancelingThrough ("/escape") will also cancel when you press the "E" key on the keyboard. How would you avoid this? Thanks.
Most of the code was done by Unity themselves in this video and was edited by Brandon. I'm curious what the issues you had with the programming practices? 🤔
@@Luis-Torres As much as i would like to explain doing so in a youtube comment is a bit out of scope. For future reference though don't assume that unity always follows good programming practices.
@@justbake7239 I don't assume Unity follows best practices...but that's not the point 😅 Your comment seems to be criticizing the video itself when the reality is that the criticism should be aimed at Unity if at all. If you're going to make a critique about programming practices, then elaborate on that. If you decide not to, then the comment seems kind of pointless to me. I was hoping to learn something from this comment.
This is no joke right here. Really daunting going through this. Well done. I'm glad I went through this, and I really appreciate the hard work that went into putting this together.
A bug was found where, if you separate a composite binding (ie. A vector2 up/down/left/right binding) into 4 separate bindings that you want to rebind, a duplication was possible within the composite binding itself.
To fix this, you'll need to change the CheckDuplicateBindings functions to the following:
private bool CheckDuplicateBindings(InputAction action, int bindingIndex, bool allCompositeParts = false)
{
InputBinding newBinding = action.bindings[bindingIndex];
int currentIndex = -1;
foreach (InputBinding binding in action.actionMap.bindings)
{
currentIndex++;
if (binding.action == newBinding.action)
{
if (binding.isPartOfComposite && currentIndex != bindingIndex)
{
if (binding.effectivePath == newBinding.effectivePath)
{
Debug.Log("Duplicate binding found in composite: " + newBinding.effectivePath);
return true;
}
}
else
{
continue;
}
}
if (binding.effectivePath == newBinding.effectivePath)
{
Debug.Log("Duplicate binding found: " + newBinding.effectivePath);
return true;
}
}
if (allCompositeParts)
{
for (int i = 1; i < bindingIndex; i++)
{
if (action.bindings[i].effectivePath == newBinding.overridePath)
{
//Debug.Log("Duplicate binding found: " + newBinding.effectivePath);
return true;
}
}
}
return false;
}
This also affects the "reset" button, so you'll need to change the ResetBinding function to the below as well:
private void ResetBinding(InputAction action, int bindingIndex)
{
InputBinding newBinding = action.bindings[bindingIndex];
string oldOverridePath = newBinding.overridePath;
action.RemoveBindingOverride(bindingIndex);
int currentIndex = -1;
foreach (InputAction otherAction in action.actionMap.actions)
{
currentIndex++;
InputBinding currentBinding = action.actionMap.bindings[currentIndex];
if (otherAction == action)
{
if (newBinding.isPartOfComposite)
{
if (currentBinding.overridePath == newBinding.path)
{
otherAction.ApplyBindingOverride(currentIndex, oldOverridePath);
}
}
else
{
continue;
}
}
for (int i = 0; i < otherAction.bindings.Count; i++)
{
InputBinding binding = otherAction.bindings[i];
if (binding.overridePath == newBinding.path)
{
otherAction.ApplyBindingOverride(i, oldOverridePath);
}
}
}
}
And finally, to ensure you can use either WASD separately OR together, be sure to update the ResetToDefault method to:
public void ResetToDefault()
{
if (!ResolveActionAndBinding(out var action, out var bindingIndex))
return;
ResetBinding(action, bindingIndex);
if (action.bindings[bindingIndex].isComposite)
{
// It's a composite. Remove overrides from part bindings.
for (var i = bindingIndex + 1; i < action.bindings.Count && action.bindings[i].isPartOfComposite; ++i)
action.RemoveBindingOverride(i);
}
else
{
action.RemoveBindingOverride(bindingIndex);
}
UpdateBindingDisplay();
}
This makes it so I can't rebind composites at all, it always says there's a duplicate :/
@@Storm3532
Fix Below, explanation: Essentially when it's a composite, the bindingIndex that's passed in is its index within the composite itself, and not within the entire actionMap list of bindings. For example with a WASD composite, bindingIndex is 0 for the header (we don't care about), the first item in the composite will be 1 (W in this case), second item will be 2 (A), and so on. With the currentIndex++ where it's at, it matches our composite binding's index to the ENTIRE list of bindings. Since the elements aren't 1-1 in both lists, it means index will be off and will try to compare itself against itself, finding a 'duplicate'. Moving currentIndex++ down so it only starts incrementing once we've found our composite object will make it so the binding item will start at 0 at that point, it will skip the header (because the header isn't considered "isPartOfComposite"), and then it will compare your composite element to the first item in the composite. The indexing should be correct so it will skip over itself and not have a false duplicate. :)
foreach (InputBinding binding in action.actionMap.bindings)
{
if (binding.action == newBinding.action)
{
currentIndex++;
@@Malaron2 That fixed that issue.
Since we're sharing solutions. I discovered that the rebound buttons would only load when I opened the related keyboard or gamepad canvas.
Solution: I also added the save rebind script to the EventSystem so it loads when the scene is loaded.
Is it action.bindings[i].effectivePath == newBinding.overridePath
or action.bindings[i].effectivePath == newBinding.effectivePath
?
this is by far the best input rebinding tutorial for Unity on TH-cam, bar none. I have viewed other tutorials and they are not as robust as this one. This one results in a professional rebinding functionality, suitable for commercial games
Thank you for your efforts. Your channel is fast becoming my go to place for quality tutorials full of good practices.
What an absolute gold mine of a video. I am about to enter polish phase on my tower defense game and wanted to offer custom key bindings, but the API is just so hard to take full advantage of. You just saved me hours of trial and error. Cheers mate!
Bro you are an absolute LIFESAVER! I was banging my head against the wall trying to figure out how to prevent duplicates for hours, and trawling through the code was just getting me more confused! Thanks so much for this video.
Did you have a bug that when a bind is changed to a duplicate value it is reset to the default?
lots of time, lots of sanity saved and lots of features provided, thanks for helping me modify all those high level language programing of unity's prebuilt code
This is one perfect video! Thank you. Saving it for when I’m redoing my ui and will add rebinding :)
Hey, thanks for the great tutorial. I set up my input system differently, thought I'd share.
Instead of using the UI based Input Action control binding, I did it all in code. I set up an "InputAction" for each action, and used the "AddBinding or "AddCompositeBinding" function to bind keys/buttons to the action. This way, I can store my control binding map in a json file and then read it and load the controls easily.
For using these actions, I pass a function definition as an "InputAction.CallbackContext" and add it to action.performed and (optionally) action.canceled. This way, the function gets triggered directly when any action is performed. So, I don't need the bool variables to detect when an action has been performed. The triggered function will receive the context and you can detect whether the action was performed or canceled from the context.
I wasn't sure out how to do the re-bindings and stuff, but your tutorial has given me a good idea. Thanks again!
Thank you so much, I was searching for this all day.
Great tutorial! I needed to use it on my own project, and it works perfectly right now.
Thank you for putting this video together. Really helped me out and I really enjoyed your method of tutorial making. I've subbed and will be checking out your other work!
This is by far one of the best Unity tutorials that I have ever seen! What would be the right approach if one wants to rebind controls for say 2 players on splitscreen. Let's say we already assigned gamepad controllers for each player and we know which on is which. I just can not figure out how to check during rebinding to accept only the inputs from specific player's controller - and not the other one (since while one player is in rebinding mode - and waiting for the key to be pressed - we do not want to detect keypress from another player's controller). Of course each player needs its own input scheme - even though in their structure they are identical (clones) - but still we need two - that I figured out and that works fine - I just need to prevent rebinding taking inputs from other player's controller. Once again thank you so much for your videos!
Another really good/helpful tutorial from you. Thank you both 🙂
Masterclass of a job, well done 🥳
This is such a life saving tutorial. Many thanks!
Thanks so much for this tutorial, it worked for me and I was extremely lost haha
Just a tip: You can also press Ctrl + E + C to comment out lines of code, making it a bit easier to reach the keys with one hand in one single motion ;-)
i had no idea, thanks!
For Ui icons, I used Xelu’s controller prompts
This is realy helpful, thank you very much!
Thanks for the great tutorial!!!
Amazing tutorial, thank you so much!
Awesome video! Subscribed!
Very nice, very comprehensive overview of how to so rebinding thank you so much.
In the beginning you mention rebinding is easier with player input than generated c# classes, but not say why though?
Thanks a lot for this!
Just wondering, how hard would it be to modify this so you can add several bindings to an action instead of just one?
The duplicate rebind modifications were almost identical to samyam's video. :\
Amazing! thank you so much
Great tutorial, ty
the reset function is not working for me. i've double checked my RebindActionUI prefab reset button and it's set to call the resettodefault function when the player clicks, but for some reason, nothing happens when I press the button. I've got the actual rebinding portion of the tutorial done, but the reset buttons, which were apparently supposed to work out of the box, just are not working for me. Any advice? I followed the code for the reset function exactly
Did you ever figure this out? I've run into the same issue.
Omg.. i just implemented all of this myself not even knowing there were samples in the Unity package SMH. Learned a thing or two.
Love this thank you for making it!! Would anyone know how to do composites with the gamepad icons example? I have one action that requires you to hold two buttons at the same time, and it shows properly with text, but the icons don't know what to do. thanks!
You are a real master, thanks a lot for the insights
Thanks for the tutorial.
The last part, saving rebinding, getting:
'InputActionAsset' does not contain a definition for 'SaveBindingOverridesAsJson' and no accessible extension method 'SaveBindingOverridesAsJson' accepting a first argument of type 'InputActionAsset' could be found (are you missing a using directive or an assembly reference?)
any idea?
Great Video! Can you explain why this method of rebinding won't work if you use C# generated class?
God bless this video. Absolute hero shit : - )
Followed every step, but when it comes to testing the rebind, the rebindUI is updated with my new keys but my character still controls using WASD.
I assume this is because I have generated the C# class you said not to, but I need that class. What do we do in that case?
I just ran into the same issue. The video didn't really explain it, but you shouldn't need the class for anything. if you followed his tutorial exactly then you should have a "User Input" script.
Inside of that script make functions to get the input actions you defined and you can use those. Here's my code down below (I've needed to modify mine for other reasons)
private PlayerInput playerInput;
private InputAction moveAction;
private InputAction attackAction;
private InputAction interactAction;
private InputAction crouchAction;
private InputAction jumpAction;
private InputAction sprintAction;
private InputAction pauseAction;
private void Awake()
{
DontDestroyOnLoad(this);
playerInput = GetComponent();
SetupInputActions();
}
private void SetupInputActions()
{
moveAction = playerInput.actions["Move"];
attackAction = playerInput.actions["Attack"];
interactAction = playerInput.actions["Interact"];
crouchAction = playerInput.actions["Crouch"];
jumpAction = playerInput.actions["Jump"];
sprintAction = playerInput.actions["Sprint"];
pauseAction = playerInput.actions["Pause"];
}
public InputAction getMoveAction()
{
return moveAction;
}
public InputAction getAttackAction()
{
return attackAction;
}
public InputAction getInteractAction()
{
return interactAction;
}
public InputAction getCrouchAction()
{
return crouchAction;
}
public InputAction getJumpAction()
{
return jumpAction;
}
public InputAction getSprintAction()
{
return sprintAction;
}
public InputAction getPauseAction()
{
return pauseAction;
}
Hope that helps!
I found an issue where if you cancel the rebinding and the binding contains composits, the changes will not get revered and will stay as is. This causes a duplication glitch that I've tried fixing myself, but could not fix. I also found an issue where if you rebind an action, then put in a duplicate, it resets the value back to its original value before the rebinding. However, I found a solution to this error by putting in a variable to remember what is was before the method is performed, so it can revert to that by using "action.ApplyBindingOverride(bindingIndex, _binding);". _binding is the variable that stores the previous value, which you can set before the operation is called: string _binding = action.bindings[bindingIndex].effectivePath;. Can you please help me with the original problem with that being canceling a rebinding that contains composits (which don't revert the changes)? Thank you!
The button binding is successful, but it is not mapped to the character
Do I have to use the Input System plugin or can I use the default unity input manager
I can't see Unity.TextMeshPro assembly at 6:31. Do you know how to resolve this?
is it okay to have the user input script as a singleton even if i have multiplayer?
I need help! Everything works fine but in my game my player's jump height is variable on jump key Being held but so i changed the jump input is userinput but now my player jumps by itself when jump key is held, which is not what i want
I updated the Input System so everything is on point, but the keyboard stopped working with the Action Map I use for the gameplay. I don't want to do all of this without updating, because I know it'll be worse in the future, and the listen function doesn't even work for me in the old version.
Found a bug and I am not sure how to fix it. Let's say you have one button set to R2 and another set to L2. If you remap the button with R2 to X and proceed to switch the second button to R2. When you go to switch the first button back to R2 the font updates but Waiting For Responses is still visible. It would be neat to add the set of code to swap like when you reset but nothing happens if I add action.RemoveBindingOverride(bindingIndex); to PerformInteractiveRebind during check for duplicates nothing happens. Any advice would be great.
Thank you
Hello. The thing in 4:00 technically is not a singleton. Its a global static reference that self-manages. For it to be singleton, it should automatically instantiate itself. Just a minor nitpick.
In my case after I pressed one button for rebinding its not closing the Rebindingpanel :/ EDIT: found out I missed to return false on duplicate instead I returned also true at the end
I was actually gonna ask you how you were doing this in your games haha
Hopefully you see you this, I was just wondering, if You assigned those sprites for xbox but if the player only has a PlayStation controller wouldn't the player only see xbox controls until they rebind ? is there a way to set the default inputs based on what controller gets detected ?
Hi everyone!
First of all, great video, it really helped me set up the rebinding options for my game! Still, I need help with a curious issue.
Since I put all key reset into one single button, I managed to modify CheckDuplicateBinding function to integrate the swapping method you describe. This way, new bindings immediately swap with duplicates, if found. And everything looks like it's working fine.
Now, I encountered a small issue I'm not sure how to solve, so I'm hoping anyone here could point me in the right direction...
As I said, rebinding perfectly works as long as I stay in the Editor. When I build the game, however, something weird happens: I can rebind keys without any trouble, but if I close the pause menu (both with escape and by selectin "resume") and then reopen it, the rebind is maintained, but the controls list displays the original, default keys.
Example: M key opens map; I rebind the function to key G; now the list says MAP - G and if I close menu and test, G key opens map (perfect); now, if I reopen the menu, it says MAP - M (original binding), but the G key is still the one performing the action.
So, to wrap up, the rebinding works perfectly but it DISPLAYS incorrectly... and only in the build, not in the editor, where new keys are displayed correctly. Any idea on what changes between editor and build? Or on where I should go looking for a solution?
Thanks!
Thanks
I copy the code step by step and it still can't work in the end ,i don't know why ?😭
Hello i'm actualy making a fpv drone video game and i want us to be able to use any radio transmiter. In most of FPV Simulator you have a system call the joystick calibration where you have to move your joystick and the game listen to the input of your controller and bind it. I want to do the same system into my game but i realy don't know how so if somebody know how to do it i will realy apreciat it. Thanx
Good tutorial but i for some reason cant rebind like jump to left mouse button. Can you please help me.
Why does no one use UI Toolkit :(
Hey man could you do a Steam Deck controls video? Thanks man love the videos
I need to get myself a Steam Deck first. Thanks for the idea!
4:40
Line 97 I think the walk checking is wrong
My question is not entirely related to this video but maybe somebody can still shine a light on it for me. Can I use Unity to create a tool that remaps and/or automates controller input? I've made some makros with AHK but I'd rather switch to something more advanced and polished that also uses a C-style language because I don't really like the syntax of AHK and its documentation is very bad. I know that Python is the first choice for tasks like this in the Open Source community but I don't really like that language either.
Hey there, thanks for this video. I noticed that .WithCancelingThrough ("/escape") will also cancel when you press the "E" key on the keyboard. How would you avoid this? Thanks.
That’s a unity bug. Lemme find you the code for this one sec.
@@AnEmortalKid Hey there, thanks. The solution is to upgrade to input system 1.4.1
@@readyok8230 omg lol. Ok I shall check if I have the latest.
Don't forget to change inputs in settings otherwise this doesn't work
writing each action in three places is not very good
First
it really annoys me when I find a good tutorial but it doesn't stick to good programming practices.
Most of the code was done by Unity themselves in this video and was edited by Brandon. I'm curious what the issues you had with the programming practices? 🤔
@@Luis-Torres As much as i would like to explain doing so in a youtube comment is a bit out of scope. For future reference though don't assume that unity always follows good programming practices.
@@justbake7239 I don't assume Unity follows best practices...but that's not the point 😅
Your comment seems to be criticizing the video itself when the reality is that the criticism should be aimed at Unity if at all. If you're going to make a critique about programming practices, then elaborate on that. If you decide not to, then the comment seems kind of pointless to me.
I was hoping to learn something from this comment.
@@justbake7239well, a lot of the time if it is out of the scope for a comment it is also out of scope for the video...
First