I couldn't find anything else like this in any form anywhere to help with this - I have no idea how this has so few views/likes. Thanks for doing this it covers everything needed to setup local multiplayer!
I spent a lot of time breaking my head over how to use the C# events with PlayerInput and I came to the same solution as you did. I couldn't find anything better either. Good to get some validation from another fellow developer. Thanks. Exactly what I was looking for.
This tutorial was amazing! Your videos on the new input system are far better than any others that are currently available. In your code, you clearly show care for good software practices which many tutorials lack. You've saved me countless hours and frustration. I'm subbed and looking forward to future videos!
@49:55 I found a good way to do it! In PlayerConfigurationManager don't add DontDestroyOnLoad. In the sample scene keep the player input manager but change the join behavior to join players manually. When you instantiate the players in the LevelInitializer they are instantiated in the order of player number and replace the PlayerInput.PlayerIndex of the now deleted PlayerConfigurations.
i cannot express how much u sir have just saved my life thank u so much to all others of this issue, if you download the scripts from his github, DO THIS IT WORKS
I don't usually make comments on videos but I seriously appreciate this tutorial so much. Have been searching for a while to find a tutorial for this exact thing and I'm glad I found your video! Liked and subscribed! :D
Great Tutorial everything worked out fine, It took me a day to figure this out, but I'm GLAD that you stuck with it until the end, to deliver such quality. I do have an issue when returning to the main menu and trying to join players again (only new devices can join) , but you got me this far I think I can handle that much... If there was a way to clear all devices from the input manager that would work swell. *Edit* well it seems the code from the PlayerSetupMenu worked perfectly. I just told the menu (via for loop) to Instantiate playerSetupMenuPrefabs based on the number of connected devices and connect it to the corresponding device.
I realise you posted this comment a year ago, but I'm just running up against the same issue. I don't suppose you'd be able to go into a little more depth or share the code you used for for solution. Im struggling to loop through the connected devices & connect them to the corresponding inputs.
Great tutorial! I did something similar, but decided to put my PlayerInputHandler on the PlayerConfiguration object that gets created instead. This way, I still have direct access to the PlayerInput component and can subscribe to events (or just use SendMessage) instead of comparing the string name of the class in Controls with the string name of the fired event. This also fixed a problem where controls were playing twice, as both regular and cancelled presses would fire the action event. To get it working, i just had to find the reference to my Mover, which I did by dispatching an Event when a player joins in which is received by the object that contains the game boards. If playerconfig[0] doesnt exist, then it gets the first board's mover, and if it does, it goes the second. Works flawlessly so far, and I can subscribe to each press/cancel/hold event separately.
this seems to be my case, but i still dont get it thoroughly. would you please kindly elaborate the second paragraph, oh how it works by pseudocode? that would mean a lot. Thanks!!
I´m curious about what you did with the LevelInitializer in order to assign the mover I managed to do it with avery convoluted referance but yours seam a bit more clean
Your tutorial was amazing ! Thank you for sharing this and the sources ! They helped me when it doesn't work in my use case, by comparing the configuration diff !
Great Tutorial, I have always wanted to make a local multiplayer game but the old unity system made it so confusing. Thank you so much really needed this. :D
Really appreciate this tutorial! So few people are covering the new Input System. If you're taking suggestions, I'd love to see a tutorial building on this one that demos the automatic split-screen feature in Player Input Manager. I haven't found any good resources covering that feature yet.
I loved this! Thank you for putting this information together in an easily digestible video! I have one question, have you tried this on mobile? Gamepads work, even keyboard and mouse, but when I run on my iPhone the menu doesn't initialize when I tap the screen. It's as if the Touchscreen is disabled. Appreciate any ideas you may have, keep up the great work!
Great vid! Really helped a lot! I am making a simple game with 1 vs 1 local multiplayer. I got that working (thanks to this tutorial) and have been trying to implement an online 1 vs 1 multiplayer using mirror but i can't get it to work. I would like to use the basics you showed in this vid but then have it work online with mirror as well. Is there a simple way of doing it or is it another 1h video on that topic?
Great tutorial. Tried to make player jump. The problem was that both of my players jumping with both controls. Anyone knows how to make Jump function work for each player?
Firstly, great video! been looking for one that explains 2 player set up on one screen. Question - do you know why my UI works for my controller player but not for a keyboard and mouse player?
not sure if u figured it out, but i assume u need to set up your control scheme to allow for keyboard specifically as well as controller! hope that helps!
I have a problem with this. 43:26 I get an error saying ""ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"
@@Chen-pf7wc I solved it (I don't know if you had the same problem). In the player configuration manager I had if (playerConfigs.Any(p => p.PlayerIndex == pi.playerIndex)) instead of if (!playerConfigs.Any(p => p.PlayerIndex == pi.playerIndex)) I was missing the !
There are 2 event systems in the scene. Please ensure there is always exactly one event system in the scene UnityEngine.InputSystem.UI.MultiplayerEventSystem:Update () help
I'm having exactly the same problem, i have downloaded his unity project and it doesn't happen to him, so maybe is the unity version? idk cause i have done this tutorial like 3 times. The navegation works, buti dont like this warning.
Thank you sir, this tutorial was very helpful! I'm now trying to reset the player inputs when returning to the main menu. The way I'm doing it is simply to destroy the Player Input Manager object. However, I'm now having a problem that the players can't select their color at the set-up screen. The player index are successfully being resetted, so I'm not sure what the problem might be. Did anyone here manage to make it work?
Got no problem for the first part, however, for the second part, around 43:00, when you remade the PlayerSetupMenuPrefab, some stuffs broke. I tried remaking it and linking everything, but unfortunately I cannot control the movement on the buttons. I get a "ArgumentException: method arguments are incompatible System.Delegate.CreateDelegate". I think it might have something to do with the event system but I'm not sure what. If you have any clue I would appreciate it. Thanks! EDIT : Fixed my mistake by accident!? First, the colors of the button were set at the wrong place (on the Image component instead of the Button component). Second, I did try to mess around with everything, relinking stuffs etc and now it works... don't ask me how. If you have the same kind of issues, I suggest you look at the github and try replacing some of your prefabs with the prefabs from the github.
Struggling to get beyond 15mins or so with: ''PlayerInput' does not contain a definition for 'playerIndex'. Everywhere where this is referenced. Any insights?
Cannot figure out how to make jumping work T.T I created an OnJump, pretty much replication how OnMove works. I figured out to pass context.ReadValue() instead of context.ReadValue(). But inside my Jumper.cs I have no idea to make the acutal Jump work.
IO know this is 3 years old but I encounter an issue. If the first player is keyboard controlled and the second is a gamepad controlled, after the loading of the second scene, player 1 is stildd controlled by the keyboard and player 2 is still controled by the gamepad. But in the first scene, if the player 1 is controlled by a gamepad and the second player by the keyboard, when the second scene is loaded, the first player is now controlled by the keyboard and the second player is now controlled by the gamepad. And finally, if in the first scene the player 1 is controlled by a gamepad and the scond player is controller bu a second gamepad. When the secon scene has loaded, the first player can be controlled by the first gamepad but the second player doesn't move at all (keyboard or gamepad do nothing) If I use the keyboard for player one, and gamepad for player 2 and gamepad for player 3, all is working very well. Like it seems that unity NEED a player controlled by a keyboard and it NEED to be the player 1 (index 0). Some one to help me ?
Hi, I have a weird bug. after selecting the colors. When both players have the option to press "Ready", if only either one of the player presses ready, the SampleScene is loaded. It does not happen when one player presses ready first and then a second player joins. Can anyone tell me what I might be doing wrong? Edit: Found the problem and solved it. It was a logical error. I feel so stupid Solution: In "PayerConfigurationManager.cs", in ReadyPlayer function, instead of using the correct lambda expression to check the condition, i was setting it up in a wrong way. So for example, instead of p=>p.IsReady==true, it was p=>p.IsReady= true.
i know this video is a little over 2 years old but, can you possibly do a tournament fighter tutorial with auto combo feature with unity's new input system.? unity barely has tutorials on TH-cam for just a tournament fighter let alone a good auto combo input system and the majority of those tutorials if not all of them use the old input system. if you decide to do this tutorial series can you show us how to set up single player, local multiplayer and online multiplayer ?
ion know if anyone still sees this but whenever i load into the sample scene, the player configuration loads with me and it takes up controller, how do i delete it upon loading the scene?
Hey the tutorial helped me a lot, but I got a question for you: Lets say you have a main menu where you setup the players like in the video. Then you enter the game and play a bit and then return from the GameScene to the main menu. Is there any good solution to make the players able to re-change their color (and make it able so another Device can also be connected while being in the main menu the 2nd time)? The problem I am having is that I cant really spawn the same PlayerSetupMenu's the players used the first time they were in the main menu, since they only get created if a new player connects to the InputSystem. Any ideas for a good solution?
You might be able to accomplish what you are describing by making the level load additively so the UI scene is still alive along side the level, then you can add logic to handle displaying the UI or the level scene.
its late but the way i personally would do it is to create a load function on the playermanager to loop through the configs and spawn the objects then i would run this function whenever a duplicate of the playermanager is detected (so when you return to the menu this would happen) you can just run the function right before you delete the duplicate, but make sure you run it on the actual static instance of the singleton and not on the duplicate one if you want to be extra safe you could nest an extra if statement to also check the scene that youre currently in so that it can only happen in the menu this method just works for me because the awake of the playermanager wont run when changing scenes, but the awake of the duplicate one will
Not sure why, but when a new controller joins, the old one stops working. Does anyone know why this might be? Apart from this, I've gotten everything else working. Great tutorial.
That was an easy fix. For anyone encountering this: I had a separate map in Player Input (PlayerConfiguration object) for UI Input. The default map was getting set to Player, which did not have bindings for UI navigation.
I know this is a fairly old video so don't know if Ill get a response. I have rewatched and retraced my steps a handful of times, but for some reason only one controller controls both players. The first player uses the control map then the second is using a clone of it. I am using the player input manager, the Input system UI module, and the multiplayer event system. Not getting any errors in the code. Any places I should look in particular?
Found my issue. input.uiInputModule was reading null on the SpawnPlayerSetupMenu. Had to access the event system and get it from there. Now when a new player joins however, the button of the first player is having its disabled color applied for some reason 🧐
@@chickenfrenzy9096 I am having this exact same issue. I was trying to understand what you meant by saying to access the event system and how to go about that. Also I don't know if this happened with yours but the player clones weren't spawning in the level initializer game object but instead inside of my configuration manager. Maybe I messed up somewhere else along the line, but like you I've spent many hours making sure I did everything correct, even downloading the github repo.
Great Videos. I am getting a NullReferenceException: Object reference not set to an instance of an object PlayerInputHandler.Awake () (at Assets/Scripts/PlayerInputHandler.cs:20) I am trying to compare file and they do not look the same as the first video. What changes did you make to get the code to work?
Hi I am assuming you are comparing to the completed solution project. If you look at line 20 in the awake function it's grabbing a mover component from the game object that player input handler is on. If you are getting a null reference exception from that, then your game object doesn't have the mover component attached to it.
Hi, thanks a lot, that helped me a lot! Could you help me with a one more thing? Anywere i click with the mouse, it automaticly recognize as a palyer and set it to the player list. How can i set the mouse to be one with the keyboard?
Dude this is very cool ! I was just wandering if there is a way of unlog players in case of a game over.? I was thought about destroying or clearing the player configs which kind of works but if there is a better wat it would be great :D
Thank you for making one of the few videos on this topic! Q: My menus are spawned for both controllers in the hierarchy, but I can't see the 2nd Player's menu. Did anyone else have this problem?
Fixed it! my "Rect Transform" on my "PlayerSetupMenu" was the size of my display. Lowered the numbers and now both are visible, though the text is crunched bad. I'll work on that.
I have a degree in computer science and I am a software engineer by trade, so I write code on a daily basis, it takes lots of practice but I think lots of people can do it too. Things that help; break the problem down into small simple steps, google all the things, and keep on trying even when you are struggling with getting something to work. Once you can break through a problem you will become a better programmer and harder goals won't seem as insurmountable.
@@brokenknightsgames7966 Thanks! I just started with c# and have been doing lua. And since I’m only 14 years old this language seemed so hard. But I am learning slowly!
hey so in the tutorial when you click play and add the players in the panels stand side by side how do you do that? because mine overlap over each other
Great tutorial but I get an error after following it. "There are 2 event systems in the scene. Please ensure there is always exactly one event system in the scene". Is that not the point with multiplayer eventsystem that you can have more than one? You need one for each menu right?
Sounds like there was a change in unity 2020 and/or the input system package since this video was made. This sample was originally created in unity 2019.x .
How do I make the player choose a character (fighting game) in the startup menu with specialized attacks instead of just choosing color? Essentially: 1. Should I just modify the PlayerConfigurationManager class to have different attacks as methods? If so, how can I distinguish between the characters they're choosing? 2. How do I modify the menu to have one screen that both players pick from for their characters? Thanks if anyone helps
I have an scriptable object player with references to each attack that character has, in select screen i assign the character to the player and it kinda works. The characacter scriptable object is referenced in playerConfigurationManager.
I got very confused in the movement part I already have a player movement that works with both keyboard and mouse and with 2 local players but you just not really show it so I'm stuck EDIT: I figured out most of it but for some reason i have 2 multiplayereventsystems from the UI and that messes up everything
Exactly what I needed, except I have 1 issue. no matter what I try Unity does not recognize playerIndex which is a fairly key ingredient to making this all work. does anyone else have this problem or know how to fix it? the error i get reads: PlayerInput does not contain a definition for playerIndex.
Nope.. I think you most likely found something unintentional on my part. I generally follow the convention of any private members, variables, or functions will start with a lowercase letter and anything public will start with an uppercase.
When u make this for 4 players it would be nice if the 3th and 4th PlayerSetupMenu would spawn below the first and 2nd. Anyone knows how to to this because they all spawn on a horizontal line now
Thanks to the update of the unity package this tutorial won't work with the 1.0.3 and upper versions of the input package. I've figured out why and here is how to deal with the latest update : - Modify the SpawnPlayerSetupMenu script to look like this : public class SpawnPlayerSetupMenu : MonoBehaviour { public GameObject playerSetupMenuPrefab; public PlayerInput input; private InputSystemUIInputModule module = null; private void Awake() { var rootMenu = GameObject.Find("MainLayout"); if (rootMenu != null) { var menu = Instantiate(playerSetupMenuPrefab, rootMenu.transform); module = menu.GetComponentInChildren(); input.uiInputModule = module; menu.GetComponent().SetPlayerIndex(input.playerIndex); } } public IEnumerator WillResetModule() { yield return new WaitForSeconds(0.25f); StartCoroutine("ResetModule"); } public IEnumerator ResetModule() { module.enabled = false; yield return new WaitForSeconds(0.25f); module.enabled = true; } } - Change the HandlePlayerJoin fonction in the PlayerConfigurationManager to this : public void HandlePlayerJoin(PlayerInput pi) { Debug.Log("Player " + pi.playerIndex + " joined"); if (!playerConfigs.Any(p => p.PlayerIndex == pi.playerIndex)) { pi.transform.SetParent(transform); playerConfigs.Add(new PlayerConfiguration(pi)); foreach(SpawnPlayerSetupMenu menu in FindObjectsOfType()) { menu.StartCoroutine("WillResetModule"); } } } That worked for me and I hope it will help some of you here
@@friesarecool4777 I just followed the tutorial but I added a reset on the module : public IEnumerator ResetModule() { module.enabled = false; yield return new WaitForSeconds(0.25f); module.enabled = true; } Because unity decided to desactivate it when another joined so I just did it manually and put it on again after It is not a great solution but it is the best I could fine to keep these scripts after the MAJ
I couldn't find anything else like this in any form anywhere to help with this - I have no idea how this has so few views/likes. Thanks for doing this it covers everything needed to setup local multiplayer!
I realize it is kinda off topic but does anyone know a good place to stream new movies online ?
@Keegan Karsyn Definitely, I have been using flixzone for since april myself :D
@Keegan Karsyn Thanks, I signed up and it seems like a nice service :D I really appreciate it!!
@Keegan Karsyn Thanks, I signed up and it seems like they got a lot of movies there :) I really appreciate it!
@Keegan Karsyn thanks, I went there and it seems like a nice service :) I really appreciate it !
I don't normally comment, but I'm just really thankful for you taking the time to explain something that has absolutely no explanation from Unity.
I spent a lot of time breaking my head over how to use the C# events with PlayerInput and I came to the same solution as you did. I couldn't find anything better either. Good to get some validation from another fellow developer. Thanks. Exactly what I was looking for.
This tutorial was amazing! Your videos on the new input system are far better than any others that are currently available. In your code, you clearly show care for good software practices which many tutorials lack. You've saved me countless hours and frustration. I'm subbed and looking forward to future videos!
Not a lot of info out there for this kind of thing with the new input system so thanks for all these videos you're doing
This is one if not the one best tutorial about local multiplayer coop input setup. Pitty you didn't make anymore videos
This is an absolute Life-Saver! Wonderful Tutorial! I hope you come back and make more Vids!
@49:55 I found a good way to do it! In PlayerConfigurationManager don't add DontDestroyOnLoad. In the sample scene keep the player input manager but change the join behavior to join players manually. When you instantiate the players in the LevelInitializer they are instantiated in the order of player number and replace the PlayerInput.PlayerIndex of the now deleted PlayerConfigurations.
i cannot express how much u sir have just saved my life thank u so much
to all others of this issue, if you download the scripts from his github, DO THIS IT WORKS
WOW you are such a small channel with great content especially around the new input system!
Awesome video as always! I love that you make videos about topics that almost no one else talks about. Keep up the good work!
I don't usually make comments on videos but I seriously appreciate this tutorial so much. Have been searching for a while to find a tutorial for this exact thing and I'm glad I found your video! Liked and subscribed! :D
I have a problem with “playerInput.playerIndex”
PlayerIndex doesn’t work/exists, can you help me?
@@twopieces8154 Where in the code is this?
Great Tutorial everything worked out fine, It took me a day to figure this out, but I'm GLAD that you stuck with it until the end, to deliver such quality.
I do have an issue when returning to the main menu and trying to join players again (only new devices can join) , but you got me this far I think I can handle that much...
If there was a way to clear all devices from the input manager that would work swell.
*Edit* well it seems the code from the PlayerSetupMenu worked perfectly. I just told the menu (via for loop) to Instantiate playerSetupMenuPrefabs based on the number of connected devices and connect it to the corresponding device.
I realise you posted this comment a year ago, but I'm just running up against the same issue.
I don't suppose you'd be able to go into a little more depth or share the code you used for for solution. Im struggling to loop through the connected devices & connect them to the corresponding inputs.
Great tutorial! I did something similar, but decided to put my PlayerInputHandler on the PlayerConfiguration object that gets created instead. This way, I still have direct access to the PlayerInput component and can subscribe to events (or just use SendMessage) instead of comparing the string name of the class in Controls with the string name of the fired event. This also fixed a problem where controls were playing twice, as both regular and cancelled presses would fire the action event.
To get it working, i just had to find the reference to my Mover, which I did by dispatching an Event when a player joins in which is received by the object that contains the game boards. If playerconfig[0] doesnt exist, then it gets the first board's mover, and if it does, it goes the second. Works flawlessly so far, and I can subscribe to each press/cancel/hold event separately.
I like the improvements to the approach!
this seems to be my case, but i still dont get it thoroughly. would you please kindly elaborate the second paragraph, oh how it works by pseudocode? that would mean a lot. Thanks!!
I´m curious about what you did with the LevelInitializer in order to assign the mover I managed to do it with avery convoluted referance but yours seam a bit more clean
@@foundtexas5424 did you figure this out?
Great content, so good to have someone to look for when i'm lost
Appreciate u
Aye I was the 700th subscriber lol, thanks for the tutorial!! Very Helpful!
Your tutorial was amazing ! Thank you for sharing this and the sources ! They helped me when it doesn't work in my use case, by comparing the configuration diff !
Great Tutorial, I have always wanted to make a local multiplayer game but the old unity system made it so confusing. Thank you so much really needed this. :D
Really good tutorial man, its so thorough and I cant wait to finish implementing it :D
Thanks, mate! Great tutorial that makes for a super modular system! Using this in my aetherpunk rpg, thanks again!
Really appreciate this tutorial! So few people are covering the new Input System.
If you're taking suggestions, I'd love to see a tutorial building on this one that demos the automatic split-screen feature in Player Input Manager. I haven't found any good resources covering that feature yet.
Great idea! I'll keep that in mind, thanks for the suggestion 👍
I've literally found the exact thing I've been looking for, Thanks!
Thank you, this video was extremely helpful.
Great tutorial, will sure help me with my project. Thanks for such effort even with few views (by now)!
You saved my life! Thank you for this video :)
Thank you for your tutorial! It's not what I exactly needed, but it is a really good foundation!
Great tutorial! Still hold up even with the new updates
Incredible tutorial. Learned a lot.
Really high quality content, thx ;)
Super helpful, thanks so much my dood
Man, you just nailed it
I loved this! Thank you for putting this information together in an easily digestible video! I have one question, have you tried this on mobile? Gamepads work, even keyboard and mouse, but when I run on my iPhone the menu doesn't initialize when I tap the screen. It's as if the Touchscreen is disabled. Appreciate any ideas you may have, keep up the great work!
Really, really great job ! I've learned a lot thank you :)
Great vid! Really helped a lot! I am making a simple game with 1 vs 1 local multiplayer. I got that working (thanks to this tutorial) and have been trying to implement an online 1 vs 1 multiplayer using mirror but i can't get it to work. I would like to use the basics you showed in this vid but then have it work online with mirror as well. Is there a simple way of doing it or is it another 1h video on that topic?
Works beautifully if using a Gamepad and a Keyboard; however, if I use 2 keyboards they both read as the same input. Any Advice?
Excellent tutorial. Thanks.
Great tutorial. Tried to make player jump. The problem was that both of my players jumping with both controls. Anyone knows how to make Jump function work for each player?
How did you add the jump feature?
How does leaving work? Disconnect a controller. Or if you joined with a controller for example. being able to leave. And later Join again.
Firstly, great video! been looking for one that explains 2 player set up on one screen. Question - do you know why my UI works for my controller player but not for a keyboard and mouse player?
not sure if u figured it out, but i assume u need to set up your control scheme to allow for keyboard specifically as well as controller! hope that helps!
I have a problem with this. 43:26 I get an error saying ""ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"
ya, same problem. Did anyone solved?
@@Chen-pf7wc I solved it (I don't know if you had the same problem). In the player configuration manager I had if (playerConfigs.Any(p => p.PlayerIndex == pi.playerIndex)) instead of if (!playerConfigs.Any(p => p.PlayerIndex == pi.playerIndex)) I was missing the !
@@wildBcat I had the same problem and realized I forgot the "!" and then saw your comment :) so hopefully others will read our comments
@@wildBcat Thank you so much! Was looking this up everywhere! You sir are amazing!
There are 2 event systems in the scene. Please ensure there is always exactly one event system in the scene
UnityEngine.InputSystem.UI.MultiplayerEventSystem:Update ()
help
I'm having exactly the same problem, i have downloaded his unity project and it doesn't happen to him, so maybe is the unity version? idk cause i have done this tutorial like 3 times.
The navegation works, buti dont like this warning.
he has warnings turned off it even says that in his version
Is the last tutorial necessary to follow this one? He uses his past movement script but idk
Thank you sir, this tutorial was very helpful! I'm now trying to reset the player inputs when returning to the main menu. The way I'm doing it is simply to destroy the Player Input Manager object. However, I'm now having a problem that the players can't select their color at the set-up screen. The player index are successfully being resetted, so I'm not sure what the problem might be. Did anyone here manage to make it work?
This was super helpful. Thank you!
Got no problem for the first part, however, for the second part, around 43:00, when you remade the PlayerSetupMenuPrefab, some stuffs broke.
I tried remaking it and linking everything, but unfortunately I cannot control the movement on the buttons.
I get a "ArgumentException: method arguments are incompatible System.Delegate.CreateDelegate".
I think it might have something to do with the event system but I'm not sure what.
If you have any clue I would appreciate it. Thanks!
EDIT : Fixed my mistake by accident!?
First, the colors of the button were set at the wrong place (on the Image component instead of the Button component).
Second, I did try to mess around with everything, relinking stuffs etc and now it works... don't ask me how.
If you have the same kind of issues, I suggest you look at the github and try replacing some of your prefabs with the prefabs from the github.
*subscribed*
Great work on this.
Struggling to get beyond 15mins or so with:
''PlayerInput' does not contain a definition for 'playerIndex'.
Everywhere where this is referenced. Any insights?
Cannot figure out how to make jumping work T.T
I created an OnJump, pretty much replication how OnMove works. I figured out to pass context.ReadValue() instead of context.ReadValue(). But inside my Jumper.cs I have no idea to make the acutal Jump work.
IO know this is 3 years old but I encounter an issue.
If the first player is keyboard controlled and the second is a gamepad controlled, after the loading of the second scene, player 1 is stildd controlled by the keyboard and player 2 is still controled by the gamepad.
But in the first scene, if the player 1 is controlled by a gamepad and the second player by the keyboard, when the second scene is loaded, the first player is now controlled by the keyboard and the second player is now controlled by the gamepad.
And finally, if in the first scene the player 1 is controlled by a gamepad and the scond player is controller bu a second gamepad. When the secon scene has loaded, the first player can be controlled by the first gamepad but the second player doesn't move at all (keyboard or gamepad do nothing)
If I use the keyboard for player one, and gamepad for player 2 and gamepad for player 3, all is working very well.
Like it seems that unity NEED a player controlled by a keyboard and it NEED to be the player 1 (index 0).
Some one to help me ?
Hi, I have a weird bug.
after selecting the colors. When both players have the option to press "Ready", if only either one of the player presses ready, the SampleScene is loaded.
It does not happen when one player presses ready first and then a second player joins.
Can anyone tell me what I might be doing wrong?
Edit: Found the problem and solved it. It was a logical error. I feel so stupid
Solution: In "PayerConfigurationManager.cs", in ReadyPlayer function, instead of using the correct lambda expression to check the condition, i was setting it up in a wrong way. So for example, instead of p=>p.IsReady==true, it was p=>p.IsReady= true.
i know this video is a little over 2 years old but, can you possibly do a tournament fighter tutorial with auto combo feature with unity's new input system.? unity barely has tutorials on TH-cam for just a tournament fighter let alone a good auto combo input system and the majority of those tutorials if not all of them use the old input system. if you decide to do this tutorial series can you show us how to set up single player, local multiplayer and online multiplayer ?
ion know if anyone still sees this but whenever i load into the sample scene, the player configuration loads with me and it takes up controller, how do i delete it upon loading the scene?
how would you make it work in a single Canvas? like a character selection screen? thanks for the help until
Hey the tutorial helped me a lot, but I got a question for you: Lets say you have a main menu where you setup the players like in the video. Then you enter the game and play a bit and then return from the GameScene to the main menu. Is there any good solution to make the players able to re-change their color (and make it able so another Device can also be connected while being in the main menu the 2nd time)? The problem I am having is that I cant really spawn the same PlayerSetupMenu's the players used the first time they were in the main menu, since they only get created if a new player connects to the InputSystem. Any ideas for a good solution?
You might be able to accomplish what you are describing by making the level load additively so the UI scene is still alive along side the level, then you can add logic to handle displaying the UI or the level scene.
@@brokenknightsgames7966 Thank you for the answer. I will take a look at that.
its late but the way i personally would do it is to create a load function on the playermanager to loop through the configs and spawn the objects
then i would run this function whenever a duplicate of the playermanager is detected (so when you return to the menu this would happen)
you can just run the function right before you delete the duplicate, but make sure you run it on the actual static instance of the singleton and not on the duplicate one
if you want to be extra safe you could nest an extra if statement to also check the scene that youre currently in so that it can only happen in the menu
this method just works for me because the awake of the playermanager wont run when changing scenes, but the awake of the duplicate one will
I am in 10 min and i so like this tuto ! :D
Not sure why, but when a new controller joins, the old one stops working. Does anyone know why this might be? Apart from this, I've gotten everything else working. Great tutorial.
That was an easy fix. For anyone encountering this: I had a separate map in Player Input (PlayerConfiguration object) for UI Input. The default map was getting set to Player, which did not have bindings for UI navigation.
OMG I COULD KISS YOU RIGHT NOW!! HOLY ... THANK YOU!!
Does this account for if ur controller dosconects? And if so where is the part that fixes it?
I know this is a fairly old video so don't know if Ill get a response. I have rewatched and retraced my steps a handful of times, but for some reason only one controller controls both players. The first player uses the control map then the second is using a clone of it. I am using the player input manager, the Input system UI module, and the multiplayer event system. Not getting any errors in the code. Any places I should look in particular?
Found my issue. input.uiInputModule was reading null on the SpawnPlayerSetupMenu. Had to access the event system and get it from there. Now when a new player joins however, the button of the first player is having its disabled color applied for some reason 🧐
@@chickenfrenzy9096 I am having this exact same issue. I was trying to understand what you meant by saying to access the event system and how to go about that. Also I don't know if this happened with yours but the player clones weren't spawning in the level initializer game object but instead inside of my configuration manager. Maybe I messed up somewhere else along the line, but like you I've spent many hours making sure I did everything correct, even downloading the github repo.
thanks for the amazing video!!!
How to do the same with ToolkitUI?
Great Videos. I am getting a NullReferenceException: Object reference not set to an instance of an object PlayerInputHandler.Awake () (at Assets/Scripts/PlayerInputHandler.cs:20)
I am trying to compare file and they do not look the same as the first video. What changes did you make to get the code to work?
Hi I am assuming you are comparing to the completed solution project. If you look at line 20 in the awake function it's grabbing a mover component from the game object that player input handler is on. If you are getting a null reference exception from that, then your game object doesn't have the mover component attached to it.
well done! :thumbsup:
Awesome! Thank you!
how can i get a list of my controllers and assign them to the right player input?
hidden gem indeed
Hi, thanks a lot, that helped me a lot!
Could you help me with a one more thing? Anywere i click with the mouse, it automaticly recognize as a palyer and set it to the player list. How can i set the mouse to be one with the keyboard?
Dude this is very cool ! I was just wandering if there is a way of unlog players in case of a game over.? I was thought about destroying or clearing the player configs which kind of works but if there is a better wat it would be great :D
Thank you for making one of the few videos on this topic!
Q: My menus are spawned for both controllers in the hierarchy, but I can't see the 2nd Player's menu. Did anyone else have this problem?
Fixed it! my "Rect Transform" on my "PlayerSetupMenu" was the size of my display. Lowered the numbers and now both are visible, though the text is crunched bad. I'll work on that.
Do you have any tips on how to learn scripting in the same grade as you? Like how did you learn to get that good?
I have a degree in computer science and I am a software engineer by trade, so I write code on a daily basis, it takes lots of practice but I think lots of people can do it too. Things that help; break the problem down into small simple steps, google all the things, and keep on trying even when you are struggling with getting something to work. Once you can break through a problem you will become a better programmer and harder goals won't seem as insurmountable.
@@brokenknightsgames7966 Thanks! I just started with c# and have been doing lua. And since I’m only 14 years old this language seemed so hard. But I am learning slowly!
Keep at it and don't give up, making games in unity and c# is a great way to learn the fundamentals.
@@brokenknightsgames7966 yeah thanks!
hey so in the tutorial when you click play and add the players in the panels stand side by side how do you do that? because mine overlap over each other
Having the exact same issue.
Great tutorial but I get an error after following it. "There are 2 event systems in the scene. Please ensure there is always exactly one event system in the scene". Is that not the point with multiplayer eventsystem that you can have more than one? You need one for each menu right?
Samething in your completed sample scene on github. Running it in Unity 2020.2.1f1
Sounds like there was a change in unity 2020 and/or the input system package since this video was made. This sample was originally created in unity 2019.x .
@@brokenknightsgames7966 I reported this problem to Unity and it was indeed a bug. It should be fixed in the upcoming releases.
Get an ArgumentOutOfRangeException: Index was out of range error when I press the ready option. Any help would be appreciated!
Found that I changed the PlayerMenuSetupController to reference a null (missing or empty) value.
@@NickHazrd can you show yours code or explain more , i have same problem and i dont get how to solve it
Thank you so much
Thank you!
How do I make the player choose a character (fighting game) in the startup menu with specialized attacks instead of just choosing color?
Essentially:
1. Should I just modify the PlayerConfigurationManager class to have different attacks as methods? If so, how can I distinguish between the characters they're choosing?
2. How do I modify the menu to have one screen that both players pick from for their characters?
Thanks if anyone helps
I have an scriptable object player with references to each attack that character has, in select screen i assign the character to the player and it kinda works. The characacter scriptable object is referenced in playerConfigurationManager.
I got very confused in the movement part I already have a player movement that works with both keyboard and mouse and with 2 local players but you just not really show it so I'm stuck EDIT: I figured out most of it but for some reason i have 2 multiplayereventsystems from the UI and that messes up everything
9:35
Same time i will try to add the new input system company with the old input system
Exactly what I needed, except I have 1 issue. no matter what I try Unity does not recognize playerIndex which is a fairly key ingredient to making this all work.
does anyone else have this problem or know how to fix it?
the error i get reads:
PlayerInput does not contain a definition for playerIndex.
Is have the same problem, helppp
Me too
I solved the problem in my project i haven't inport all sample.
Now i have import all sample and the except have disaper
Is there some standard you are following when using capital first letter on variables or no? I don't see the pattern, maybe someone could help?
Nope.. I think you most likely found something unintentional on my part. I generally follow the convention of any private members, variables, or functions will start with a lowercase letter and anything public will start with an uppercase.
Is it normal that my controller controls all players?
Thank you
Legend
thanks :D
When u make this for 4 players it would be nice if the 3th and 4th PlayerSetupMenu would spawn below the first and 2nd. Anyone knows how to to this because they all spawn on a horizontal line now
You can use different layout groups. I think you can use a generic 'canvas layout group' and decide whether to split vertically or horizontally.
Thanks to the update of the unity package this tutorial won't work with the 1.0.3 and upper versions of the input package.
I've figured out why and here is how to deal with the latest update :
- Modify the SpawnPlayerSetupMenu script to look like this :
public class SpawnPlayerSetupMenu : MonoBehaviour
{
public GameObject playerSetupMenuPrefab;
public PlayerInput input;
private InputSystemUIInputModule module = null;
private void Awake()
{
var rootMenu = GameObject.Find("MainLayout");
if (rootMenu != null)
{
var menu = Instantiate(playerSetupMenuPrefab, rootMenu.transform);
module = menu.GetComponentInChildren();
input.uiInputModule = module;
menu.GetComponent().SetPlayerIndex(input.playerIndex);
}
}
public IEnumerator WillResetModule()
{
yield return new WaitForSeconds(0.25f);
StartCoroutine("ResetModule");
}
public IEnumerator ResetModule()
{
module.enabled = false;
yield return new WaitForSeconds(0.25f);
module.enabled = true;
}
}
- Change the HandlePlayerJoin fonction in the PlayerConfigurationManager to this :
public void HandlePlayerJoin(PlayerInput pi)
{
Debug.Log("Player " + pi.playerIndex + " joined");
if (!playerConfigs.Any(p => p.PlayerIndex == pi.playerIndex))
{
pi.transform.SetParent(transform);
playerConfigs.Add(new PlayerConfiguration(pi));
foreach(SpawnPlayerSetupMenu menu in FindObjectsOfType())
{
menu.StartCoroutine("WillResetModule");
}
}
}
That worked for me and I hope it will help some of you here
what namespaces are you using here?
i have an error with the SetPlayerIndex and i do not know if this is a missing variable or a namespace issue
@@friesarecool4777 I just followed the tutorial but I added a reset on the module :
public IEnumerator ResetModule()
{
module.enabled = false;
yield return new WaitForSeconds(0.25f);
module.enabled = true;
}
Because unity decided to desactivate it when another joined so I just did it manually and put it on again after
It is not a great solution but it is the best I could fine to keep these scripts after the MAJ
very complicated for me (new to unity)