Thanks for watching this Unity Multiplayer tutorial. For project files access, check out my GitHub here: github.com/DapperDino/Mirror-Multiplayer-Tutorials
@tatumleonidas14443 жыл бұрын
i guess it is kind of randomly asking but does anybody know a good site to watch newly released series online ?
@edenty17163 жыл бұрын
@Tatum Leonidas Flixportal :)
@tatumleonidas14443 жыл бұрын
@Eden Ty Thank you, I signed up and it seems to work :) Appreciate it!
@edenty17163 жыл бұрын
@Tatum Leonidas glad I could help xD
@pan43173 жыл бұрын
Dude nice finally a more in depth and updated multiplayer tutorial! Nice!
@DapperDinoCodingTutorials3 жыл бұрын
Glad you liked it!
@marcelopadovan93212 жыл бұрын
For those who need the LocalPlayer, just replace: NetworkServer.Spawn(characterInstance, sender); for: NetworkServer.ReplacePlayerForConnection(sender, characterInstance); maybe can help, works for me.
@talismanskulls2857 Жыл бұрын
Thanks Dapper for the tutorials. I thought I would share a quick and easy alternative to this method. And its WAY less code needed. 1) Bring out you base prefabs used only for representation of the player to be loaded. 2) Create two toggles, one for the ybot and xbot. 3) Create two slots for the On Value Change and place both the male and the female bots from the scene into both slots for both toggles and use the GameObject and SetActive (bool). 4) Under the male toggle/button set the male as active with the check and leave the other unchecked for the female. On the female toggle do the exact opposite. 5) Start scene and test to make sure one is active when the other isn't on the appropriate button. (Note you can add an empty named Button Audio , give it an audio source, and select a button click sound, and use the same method but go down to the audio list and select the play one shot and also giving it a specific click sound. Just make sure on the empty game object audio source you uncheck the play on awake. Now for the script side . using UnityEngine; public class CharSelect : MonoBehaviour { [Header("Character Selection")] public GameObject[] _Char; int _CharIndex = 0; Header("Load Scene Button")] public GameObject[] _Char; int _CharIndex = 0; public void ChangeCharacter() { for (int i = 0; i < _Char.Length; i++) { _Char[i].SetActive(i == _CharIndex); } } public void _Male(bool qualityIndex) { _CharIndex = 0; ChangeCharacter(); PlayerPrefs.SetInt("_CharIndex", _CharIndex); } public void _Female() { _CharIndex = 1; ChangeCharacter(); PlayerPrefs.SetInt("_CharIndex", _CharIndex); } } public void _goToLoginScene() { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); } 6) Create the empty naming it Char Select and add the script. 7) Drag the two actual player prefabs that have your control and movement script on them and into the CharSlect option. 8) Drag the Char Select object into the same part you added the swap sample scene models. and under that look for the appropriate corresponding chacter , IE _Male for Male character, etc. 9) Add the character Select scene to Build settings. 10) Do the same with the Load/Play button by finding in the list the _goToLoginScene in that list and apply it. (For added measure i take audio listener off cameras and put them directly on the player characters so you wont have that issue where the camera is closer to an audio source than the avatar is and creates all sorts of funky issues.) 11) Save things and add the CharSelect Scene to Build settings. 12) Now create the new scene Level1 or LoadPlayer, whatever you want to name it. Add it to the build setting also. as the second in list. 13) Create the UI as show, but also set the AspectRadio at the top next to the button for display and set the UI to Scale with Screen size. The create the UI parts like the text. Now create the LoadChar script. using UnityEngine; using UnityEngine.UI; using TMPro; public class LoadChar : MonoBehaviour {{ [Header("Player Settings")] public GameObject [] player; public Transform playerSpawn; public TMP_Text label; [Header("Spawn CamRig")] public GameObject camRig; // Start is called before the first frame update void Start() { // player spawn locations int _CharIndex = PlayerPrefs.GetInt("_CharIndex", 0); GameObject prefab = player[_CharIndex]; GameObject clone = Instantiate(prefab, playerSpawn.position, Quaternion.identity); clone.transform.position = playerSpawn.position; // character name label label.text = prefab.name; // camera spawn Instantiate(camRig, transform.position, transform.rotation); } } } 1) The player that was selected if set up as explained with its dummy rep in the previous scene used only as an indicator of a selection, the character selected will load once you add those prefabs to this script in the next scene. 2) it has the added option for spawning a camera prefab to loads as well that prevents extra cloning of the camera if you want the UI and LoadChar to persist between other scenes such as when triggering a scene change using a portal or door or whatever. 3) If you simply attach a camera directly to the player or the UI it will often be replicated constantly and replicating the clones X2or more if you dont use this spawn camera method and rather quickly will start killing frame rates and lead to a major crash. As to how to make a camera that follows the player still find it when spawned/instantiated, you have to link the Player script and the Cam script to find one another. How I do that is I create an empty and name it camTarg for the camera target and align it with the eye level area of the player character. I add to it a tag called CamTarg. I then do this (Create parent Object to hold Camera Script, setting all its positions to 0. I create a child object called pivot and also set it to zero. Then I place the MainCamera as a child of the pivot (you can also call the pivot something like tilt)). With the camera, however, I raise it about 1.5 on the Y axis and put it at a -3 on the z axis. I give the parent the name CamRig abd also create a Tag and apply that to the parent which is where you will also place your camera scripting. With all that being done and it having a basic follow player script already added, in the camera script just add this line code: PlayerController player; public Transform tilt; Camera mainCam; // Update is called once per frame public void Init() { player = FindObjectOfType(); mainCam = Camera.main; transform.position = player.transform.position + Vector3.up * camHeight; transform.rotation = player.transform.rotation; } And whatever other parts are needed for your particular camera system. In your Player Script just add this: public void Start() { CameraControl cameraControl = FindObjectOfType(); cameraControl.Init(); } Once you are done with all that, add the CamRig Prefab you made into the LoadChar script. I also create a prefab of the cCamTarg that is inside the player so i can drag it into the Prefab CamRig so it recognizes it, separate from the player characters it is also saved inside the prefabs of. if you dont do it that way, when ever they player and cam load, you will be thrown an error notice of missing something. Now i just have to figure out how to tie character select to a register/login so the right character is part of the authentication process. That's the part I am still struggling with. LOL.
@sasuke1234ization Жыл бұрын
hi bro do you have discord so i can contact you about this? Thanks.
@talismanskulls2857 Жыл бұрын
@@sasuke1234ization Not on it very much but yes. Be aware I am not very good at coding a lot of things. I just figured out how to fix some issues like this. Look for TalismanSkulls using the same avatar as here.
@sasuke1234ization Жыл бұрын
@@talismanskulls2857 Request sent.
@niklaswild2 жыл бұрын
You have helped me so much. I didn't actually watch your video though, just used your idea of multiple prefabs. I always tried to change the material from the player before. But that has only ended in chaos.
@Benjackalope3 жыл бұрын
Thank you soo much! I'm still stuck on making movement sync properly from one of your earlier tutorials, but I'm excited to implement this!
@hazemackle26503 жыл бұрын
try changing the tick rate i think in the NetworkManager from the inspector to like 60
@AlphaLul3 жыл бұрын
I think a PlayFab tutorial about an Among Us style lobby system would be cool, with a list of public games to join and the ability to join a private game with a random code. Also, it would be nice to have the ability to join a random lobby, because with the current Among Us system, it can sometimes be difficult to join a lobby.
@DapperDinoCodingTutorials3 жыл бұрын
The more advanced PlayFab tutorials like matchmaking (and lobbies/list servers) will take a bit longer to make but I will be covering lobbies/list server after we've looked into matchmaking :)
@AlphaLul3 жыл бұрын
@@DapperDinoCodingTutorials Awesome!
@Case-A-Lace3 жыл бұрын
I can't wait to try and implement this!!! thanks for more tutorials!
@DapperDinoCodingTutorials3 жыл бұрын
Have fun!
@generaljk773 жыл бұрын
Awesome tutorial! I have everything working as the tutorial shows, but what would you recommend as being the best way to take the player's character selected and move them into a new scene with the chosen character?
@xxasafxx1 Жыл бұрын
Do you have the answer?
@dudley1562 Жыл бұрын
Make a function like... Public Void StartGame(string sceneName) { ServerChangeScene(sceneName); } ist part of Mirror.NetworkManager
@shadowzack5 ай бұрын
This may be a bit of a long shot, but do you know of any tutorials/examples for trying to change a players character/prefab while the game is already running.
@arisaek77643 жыл бұрын
underrated channel...
@Wavydotwtf2 жыл бұрын
getting this error - NetworkPlayer(Clone) has already spawned. Don't call Instantiate for NetworkIdentities that were in the scene since the beginning (aka scene objects). Otherwise the client won't know which object to use for a SpawnSceneObject message.
@cauejanzinic.62632 жыл бұрын
Right after I associated the Character Selection script in the right and left button, every time I click on the buttons, I get this error "ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index", does anyone know how I can fix it?
@kavindugayanath46292 жыл бұрын
Player spwoner not working and (ignoreAuthority = true) show error. Trying to send command for object without authority. System.Void DapperDino.Mirror.Tutorials.CharacterSelection.CharacterSelect::CmdSelect(System.Int32,Mirror.NetworkConnectionToClient)
@nrmines17542 жыл бұрын
try requiresAuthority=false
@fernandomilans84443 жыл бұрын
Hello, the videos you make are very good and very well explained. Can you tell me if the management with the databases is very complicated, for example, the login system? And also, in the game get the data of all the players, for example, if you type "Shift 'it shows a table with the number of deaths of the players (if it were a shooter). I think for server and database hosting, from what I read, unity has a service for this, right? Thank you very much!!
@harry28033 жыл бұрын
may I make a suggestion for your next video in this playlist. could you go back to your lobby tutorials and add a system where after each game finishes you go back to the lobby and maybe you could add a scoring system which is what i am doing for the game i am currently creating. Im not too sure on how I myself would get this to work beacuse when you start a game you leave the lobby scene to the game scene. so there would need to be some way you could bring your name and score to the game scene then after winning or finishing a game (or in this case just automatically ending the game probably is easiest) you would have to bring your name and score back and then have to set up the whole lobby which could be complicated which is why I am asking you.
@brodakarat63402 жыл бұрын
The next thing on my too list is going back to my lobby and revamping it. I'm gonna add a host only panel for match settings like map selection, max squads, show bullet trails etc. I'm also going to add a pause menu ingame and work on the post death experience (spectating and return to lobby) so I might be able to help once I do that. My first solution I would want to try is to just do a ServerChangeScene back to lobby scene, as my my players are DontDestroyOnLoad I only need to refactor my lobby to accept already existing players and it should work. For your scoring you would just have a DontDestroyOnLoad object which holds your game data like scores (this is how I will tackle my match settings thing). Making it all SyncVar's you can set score on the server and they are automatically synced to clients eg to display it on screen in the lobby.
@rafasplaydzfolowers6145 Жыл бұрын
hey bro i have a problem with the CharacterSelect script :CharacterSelect.cs(54,18): error CS0246: The type or namespace name 'ignoreAuthority' could not be found (are you missing a using directive or an assembly reference? I would be very grateful if you help me
@erwin7732 Жыл бұрын
Same
@SantaGamerYoutube Жыл бұрын
it has been renamed to requireAuthority
@skanda21863 жыл бұрын
Thank you for this content. Wouldn't be safe to include "Mirror" in the video title ?
@dmo2243 жыл бұрын
For some reason I can not tell the Command to ignore authority. [Command(ignoreAuthority=true)] does not work for me, the IDE says that it doesn't recognize the "type or namespace". Maybe I'm using the wrong version of Mirror?
@dmo2243 жыл бұрын
Wrong version, sort of... This error was brought to me by VIVOX and their implementation of Mirror.
@ЧарлиНиен3 жыл бұрын
Whoever has this problem: "ignoreAuthority=true" changed to "requiresAuthority=false"
@daskebabibnahmedal-kohol81192 жыл бұрын
I think you may need to remake this. Many of the functions have been changed
@gabrielmarques86573 жыл бұрын
Is it possible to use mirror networking as a room based system like Photon? For mobas/brawlers for example? Found a couple of things about lobby and server list, but I'm wondering if one server can host multiple game instances concurrently... Thanks for the videos, great content!
@sergeymalyshev27043 жыл бұрын
You're the best, thank you!
@DerperDoing3 жыл бұрын
What if I just want to randomly assign color from a list to a Player Prefab(cube) of Network Manager every time a player joins rather than creating multiple cube prefabs with different colors? The way I'm doing, the color changes only in the host whereas it is not synced when the next player joins the lobby. Whatever color the new player has, every other player has that same color.
@DapperDinoCodingTutorials3 жыл бұрын
You can make it a [SyncVar] and then use the hook call-back to set the colour on clients. Let me know if you need any more help :)
@DerperDoing3 жыл бұрын
@@DapperDinoCodingTutorials I initially thought of doing it that way. But what I am really using is a list of different materials which I want to sync. Is there a way to do so?
@TheUncutAngel3 жыл бұрын
//dino casually writes modulo % and blows my fucking mind
@erwin7732 Жыл бұрын
How Did you Add Character Selection in Create in top of a folder? i can't Find than
@李志-d2p Жыл бұрын
Spawned object not found when handling Command message [netId=0]
@ashdev3 жыл бұрын
Can you also discuss the pricing in a video. Please its complicated.
@daskebabibnahmedal-kohol81192 жыл бұрын
By default, the movement with wasd is based on the direction of the map. using third person with camera at the back, any way to disable that?
@intercooler7293 жыл бұрын
i need help My camera mouselook script wont work i added the networking and every thing its the same as brackeys Mouselook in his first person movement video
@ghostaspirine97843 жыл бұрын
I need help, when i spawn my character, it isnt LocalPlayer and its destroying the controller. Do you have an idea please how can i make it become localplayer please
@rabsfeir3 жыл бұрын
does anyone have a different camera inspector menu from above but me??? some renderer addition i should have maybe?
@blaiseflorendo39673 жыл бұрын
yes, me also my inspector is different from his
@liliansananikone35882 жыл бұрын
Hi ! I'm currently using Mirror Networking to make a multiplayer game. I have a scene when players are all connected, they can choose their characters and set the ready. If all players are ready, I change current scene to arena scene using MyNetworkManager.ServerChangeScene(arenaSceneName). This method sets all player clients as not ready. But After the scene was loaded, my player client is no longer connected to my host and I don't know why. Can you help me please ? Thanks a lot for answers.
@elenavillepreux18422 жыл бұрын
Hi, thanks for your tutorial, very useful ! in my unity project i have a network manager with spawn points and i want to spawn the character I choose at the position of theses spawn points, i put the network player attached to the network manager but it doesn’t seem to work. The player spawns at the position of the prefab and it is impossible to move, the scene camera is still active. Do you know how to solve this problem?
@yeetswa2 жыл бұрын
Would i be able to using visual scripting , e.g game creator asset or playmaker asset with Playfab?
@muratcan1182 жыл бұрын
Video for mobil joystick please
@starlord67433 жыл бұрын
love it
@DapperDinoCodingTutorials3 жыл бұрын
Great to hear!
@pixlabots12332 жыл бұрын
doesnt work with isLocalPlayer. How to resolve?
@TheUncutAngel3 жыл бұрын
What's your opinion on the benefits of mirror vs mlapi?
@XboxPlayerPL2 жыл бұрын
Mirror is production ready
@tmgamer76613 жыл бұрын
TY❤️
@you104962 жыл бұрын
Okay, so is there any way to make the spawn the player as local player instead? Cause in this method we are not spawnih them as local player so we can't use local player functions :thinking:
@Nirvan79410 ай бұрын
Did you find a way to make it work?
@maniksharma97363 жыл бұрын
What about multiplayer sounds...
@Vinet1643 жыл бұрын
How do you make a different spawn point for each character?
@Sulihin3 жыл бұрын
Check out the earlier tutorial in the series "Spawning Players In" tldw; You can make empties with the NetworkSpawnPosition component.
@SahilSingh-hc4fk Жыл бұрын
use "requiresAuthority =false" instead of "ignoreAuthority=true"