@@maxacan8532 I don't understand why he did not tell us that. Btw all the coding is unnecessary. All you have to do is just put your player in the network manager. It saves a lot of time.
OMG I HAVE WATCHED THE VIDEO 50 TIMES NOW TO FIND OUT WHAT'S IN THE FIRST LINE I STARTED ANALYZING THE VIDEO 6:00 PM AND NOW IT'S 10:48 PM THANK YOU SO THANK YOU !!!!
Great Video! I switched to mirror a while back at work when we needed a replacement for the traditional UNet and I just then found out about it, and I'm glad to see it get some love :) Keep up the great work.
@@alipk2633 thats true, although pretty much all info /tutorials on UNet apply to Mirror as well. And the Discord is a good source as well, I would recommend that too
Nice tutorials man! I'm really looking forward for a tutorial on server authoritive movement and dedicated server, It will be really cool! Thanks for the good content!
when you mark a function with [Server] if anything tried to call it you'll receive a error message that's why the [ServerCallbacl] exists its basically the same as [Server,] but with no error, so you can use it on stuff you have no control over not getting it called like a update()) the main difference between hasAuthority and isLocalPlayer is that the server by default has authority over all objects so hasAuthority will return true in the host even though the object is not the local player so if you tried to move with has authority the player that is hosting the game will move all players when he moves because he has hasAuthority
@@Change-jy1rl So if i create a object in scene and in it's script if i use hasAuthority that mean only host gonna interact with it right? Cool, with it i would know only host is interacting with it
When i tried to change from monobehaviour to networkbehaviour it doesn't show up. Anyone got a fix for this? Edit: Nvm just put using Mirror; to the top.
After i use "Command" and "ClientRpc", the host and the client dosn t sync anymore and if i try to move one player then all the players in that window start to move without sync with the other windows. Any solution?
Ok for some reason everything was working but only if i was the server and the client. When using the program only as a client it was not showing the updated position on the server, but only on the client itself. What i did to fix that was to change the "network manager" with the "authority network manager script", and now everything is working. I think it has something to do with the "network transform" component, not having the checkbox for the client authority anymore.
Great video, are there easier ways to test multiplayer other than build and run every time? It is becoming slower when the project grows larger, sadly Uecho does not work anymore and I did not find an alternative
If i understood correctly when we use CmdMove() with the command tag we're basically setting the method to work on the server. Then inside the server method we call the RpcMove which is a Client method since there's [ClientRpc]. Then what happens is On the update method if we're the owner of the gameobject, and if we're pressing space, we call the CmdMove() method which has the RpcMove() method inside it, which is eventually gonna move our gameobject in your client. My question is, where are we syncing the movement between the client and the server?
Answer to my question should be: When a client presses "spacebar" it executes the CmdMove() and then broadcasts RpcMove() to all clients. However only the gameobject owned by the client that pressed the space bar will execute rpcmove and perform the movement. This ensure that the movement is synchronized across all clients, but only affects the gameobject owned by the initiating client
So I have a self balancing ragdoll setup with player controlls, so I I want to sync the ragdoll joints and the parts and stuff, do I need to add the network transform and the network identity component to every single child in the player hierarchy?
There is a bug that if I move one sphere (client A) to the point that it will touch second sphere (client B) then I can move second sphere (client B), not the original one. So client A moves client B instead of his sphere. I've reproduced the same issue after downloading your project from github on my PC. It is about the version of Mirror?
Nah i didn't Found Such Bug i even tried to recreate the scenario u are talking about but i was not able to remake that one so i am pretty sure u did something wrong
No, it's not necessary, of course. He just checked all reasons for leaving the method right at the beginning in order to get them out of the way/head. In this small piece of code, it might look weird, but it's a good style for bigger or more complex methods
if (input.getKeyDown(KeyCode.Space)) means if the key pressed is space, then do this code. The ! makes it NOT so if key entered is NOT space, then do this code. It is necessary for logic
how do u put the networkBehaviour, I can't mine just appeared red. But if I used Using UnityEngine.networking, it said that the network behaviour will be depreciated
I don't really see why Photon would be any better necessarily. Have a look at github.com/vis2k/Mirror and assetstore.unity.com/packages/templates/systems/ummorpg-51212
Thanks for the answer. I used to struggle a lot when talking about unity's multiplayer assets without ever understanding what differentiated every of these networking systems. Do you have any documentation for that ?
@@GymCritical Assuming someone can't do something is quite close-minded. I'm not saying the odds of one person finishing an entire MMORPG are high, but flat out stating it's impossible is a little excessive don't you think?
Will be great if some one can answer this question.. When you say the method CmdMove will be run on the server, where exactly will the code be placed. All the script files will be in available on both the server and client . So do we check using the code to see if this is a server or will this script be only placed on the server physical machine?
if (!hasAuthority) { return; } makes it so that the Cmd is only for one user, then the client rpc tells all the clients to move. But the script is on each one of the players, so on the client rpc it should tell one object on each client to move. I'm not sure what your question is.
the object is teleporting on the map because you're telling it to teleport by resetting it's Vector3 position. instead try and set it's rigidbody2d.velocity in the direction you want it to move; `rigidBody.velocity = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")) * speed * Time.fixedDeltaTime;`
Deltatime only needs to be multiplied when changing things over time. Here you are instantly setting the velocity to a value, meaning the body will now move at that speed (position change over time), but you are multiplying it with deltaTime, which makes no sense. Like saying it should now go at X meters per second per second, which sounds more like an acceleration and not a speed, but you are setting the speed to this value. Hope I make sense. :) To put it another way, the physics engine will already move the object at its velocity multiplied by the relevant deltaTime in the physics step, so no need to multiply by deltaTime when setting velocity. The deltaTime might even be different in the physics step than here.
Hi ! Nice video ! Just wanted to make sure, event if I use a client hosting kind of server, I still can have a full authorative server even tho the server is the host client or its better to have dedicated server when we want to have everything ran on the server ? Thanks
Nice tutorial! Just wonder what sort of project setting you used for the graphics? Mine is just in default 3d, the lighting and skybox doesn't look as good. Thx!
Thanks for that very informative tutorial. I just got one question: With the ClientRpc function "RpcMove" you said that this method runs on ALL the clients, but why is only our client moving since we don't pass any Network Id to the server?
I'm a bit confused, mostly out of ignorance. So creating the CmdMove function makes sense but why implement it within the player script if it's server code? Am I understanding that right? CmdMove method is executed as if it were the server? Why not create a method within the server code that validates and is called by the player and the player sends as a parameter a callback of RpcMove? And as for RpcMove I get that the server executes this method but what is the sequence of events here? When one player wants to move they call CmdMove which then tells the server to "move me" and then the server calls RpcMove but is RpcMove being called on every single player script in the scene at the same time or is it only calling RpcMove for the player script that initiated? How does this tie into syncing player positions?
movement script btw: using System.Collections; using System.Collections.Generic; using UnityEngine; using Mirror; public class PlayerMovement : NetworkBehaviour { [SerializeField] private Vector3 movement = new Vector3(); [Client] void Update() { if (!hasAuthority) { return; } if (!Input.GetKeyDown(KeyCode.Space)) { return; } transform.Translate(movement); } }
Quick question! I want to use the new input system and I'm using bools for button input and for some reason the bool isn't changing not sure if you covered this but how would I implement it into the game?
I just solved it, add 'using Mirror' (without the quotes) to the top of your player script, for example: using System.Collections; using System.Collections.Generic; using UnityEngine; using Mirror; public class Player : NetworkBehaviour { [SerializeField] private Vector3 movement = new Vector3(); [Client] private void Update() { if (!hasAuthority) { return; } if (!Input.GetKeyDown(KeyCode.Space)){ return; } transform.Translate(movement); } }
@@acfgcnbjh actually I saw this clip yesterday, I think that "use mirror" added itself when he changed to NetworkBehavaiour ... But thank you anyway :)
If I change my player and input scripts from mono behavior to network behavior will they still work on offline mode? I have a PVE option and a local co op option also and I don’t want to break them.
Moving with RPCs brings a latency, of course. A better approach could be to still allow the client to move locally, but let the server decide if the position change was correct and to change the position back, if a cheater teleported, for instance.
Watch out if you are using the new input system!! (see below) Problem: You can't put the "PlayerInput" component on every Player Prefab you want to spawn and move, it won't work if you have more than 1 PlayerInputs My solution: 1) Create a new GameObject with the PlayerInput component 2) Create a new script to overwrite the Network Manager Script (to do that, just make a new c# script and replace "MonoBehaviour" with "NetworkManager") 3) Override the OnServerAddPlayer() method 4) Instantiate the players as a child object from a GameObject with the PlayerInput component 5) For new user joins, you need to check in the start method of Player.cs if the current players are already a child of this gameobject: if (!gameObject.transform.parent) { gameObject.transform.parent = FindObjectOfType().transform; } I hope this helps, thanks to DapperDino for the great video!
Can someone help me? When I type anything having to do with mirror, visual studio isn't recognizing it and underlining it in red. I said using Mirror and yes the game works but visual studio says its wrong... I'm not on visual studio community, just vs
I'm trying to make my own thing from scratch, right now I have an issue where the client never has authority. Is there something you do in this tutorial to give the client authority? if so I can't find it. Edit: I figured it out, but im keeping the comment here so if other people get this issue they can see how I fixed it. It was literally just that I had "NetworkManager List Server" as my component instead of "NetworkManager". I'm dumb.
hi man when i did the same code of the clientRpc Movement but i just changed it to rigidbody movement the players movement didnt synced can u help me with that ?
I tried changing the MonoBehaviour to "NetworkBehaviour" but it was underlined in red when I did that. I have added "using Mirror;" but that just gets underlined too. Why is this?
@@alfenstein6356 yeah I did that, might have missed my other message that explained what I did wrong. Basically I was running an old build, I had to delete it and build from scratch because just building wasn't overriding the old build for some reason. Thanks for trying to help anyway!
i don't understand the RpcMove() part, i've already used Rpc with photon, but now you called RpcMove() for every client, but why not every player move at the same time then? because of authority?
Can somebody explain what the server is? Is it the hosting client itself or a second instance running on the hosting client? And technically can't the hosting client then easily cheat?
hi im working on a small project its a unity2d topdown 4 directional movement and shooting multiplayer game i got the movement and faceing right but still have problem on the client tho i cant make him shoot in diferent direction it only shoot in the default direction is any one here good at unity networking i dont know how to make the direction var works on the client public int direction????
whenever i put if(!hasAuthority) {return;} it just disables all of my script below except for movement and turning around!!! Does anyone know what to do to fix this?
If by not "on the same WiFi connection" you mean across the internet then you'll probably need to setup port forwarding on your router. Unless you use a network transport that can do Nat punchthrough.
I want to create a simple multiplayer card games for 2-4 players. Is there a way I can use mirror to make such games with random matchmaking and other stuff?
Make sure to put at the top using Mirror;
thanks :D. i was trying to get the "NetworkBehaviour" working but couldn't figure out why it was not working
@@maxacan8532 I don't understand why he did not tell us that. Btw all the coding is unnecessary. All you have to do is just put your player in the network manager. It saves a lot of time.
Thanks Man! you saved my alot of time. :)
@@Jordofentdealer right, this is the most important thing for the script and he didn't tell in the video. Maybe he forgot.
so, when im putting it at the top, it doesn't shown up and "using mirror" doesnt work
When using *networkbehaviour* you will need to add "using Mirror;" at the top of the script, for example, directly below "using UnityEngine;"
u saved my life
OMG I HAVE WATCHED THE VIDEO 50 TIMES NOW TO FIND OUT WHAT'S IN THE FIRST LINE I STARTED ANALYZING THE VIDEO 6:00 PM AND NOW IT'S 10:48 PM THANK YOU SO THANK YOU !!!!
you're a saviour
Great Video! I switched to mirror a while back at work when we needed a replacement for the traditional UNet and I just then found out about it, and I'm glad to see it get some love :)
Keep up the great work.
same here
however there are not alot of tutorial about mirror :(
@@alipk2633 thats true, although pretty much all info /tutorials on UNet apply to Mirror as well. And the Discord is a good source as well, I would recommend that too
this series is so helpful. I love it, u really deserve more subs
You should make more mirror videos theyre really helpful :)
Yep I will be making plenty more :)
make sure to put Using Mirror; just below where it says Using UnityEngine or your script wont work at all
Nice tutorials man! I'm really looking forward for a tutorial on server authoritive movement and dedicated server, It will be really cool! Thanks for the good content!
what is the different of [Server] and [ServerCallback]
Also what is the difference of hasAuthority and isLocalPlayer
when you mark a function with [Server] if anything tried to call it you'll receive a error message
that's why the [ServerCallbacl] exists its basically the same as [Server,] but with no error, so you can use it on stuff you have no control over not getting it called like a update())
the main difference between hasAuthority and isLocalPlayer is that the server by default has authority over all objects so hasAuthority will return true in the host even though the object is not the local player
so if you tried to move with has authority the player that is hosting the game will move all players when he moves because he has hasAuthority
@@Change-jy1rl So if i create a object in scene and in it's script if i use hasAuthority that mean only host gonna interact with it right? Cool, with it i would know only host is interacting with it
behavior vs behaviour ....people separated by the same language :D
Great work here, thanks!
Very good tutorials, explanation 1000 and understanding and cover many things
When i tried to change from monobehaviour to networkbehaviour it doesn't show up. Anyone got a fix for this?
Edit: Nvm just put using Mirror; to the top.
Very detailed in describing how this how thing works. THanks
This is a really clear tutorial, Thanks!
After i use "Command" and "ClientRpc", the host and the client dosn t sync anymore and if i try to move one player then all the players in that window start to move without sync with the other windows. Any solution?
It is Work?
Problem "The name 'hasAuthority' does not exist in the current context" is update to => hasAuthority = isOwned
0:12 "and stole it ,aaaaa, sorry open in Unity" XD
Yeah bro is is brilliant like always!!
Awh, thanks :)
Very well explained!!
I tried export to android and i have one bug "A connection cannot be established as the target computer expressly denied that connection."
Ok for some reason everything was working but only if i was the server and the client. When using the program only as a client it was not showing the updated position on the server, but only on the client itself. What i did to fix that was to change the "network manager" with the "authority network manager script", and now everything is working. I think it has something to do with the "network transform" component, not having the checkbox for the client authority anymore.
Awesome! Just what I hoped for
Glad you found it awesome :D
I love it!
Thank you for this amazing tutorial!
Great video, are there easier ways to test multiplayer other than build and run every time? It is becoming slower when the project grows larger, sadly Uecho does not work anymore and I did not find an alternative
You can use UnityProjectCloner from hwaet on github. It's the as Uecho. I really recommend it instead of building your project each time
@@goldytack I'll try it out, thanks a lot!
Why does the networktransform component not sync anything AT ALL for me? I don't understand what I'm doing wrong...
personally i use parents object to separate an categorize my project
Ok now I followed the tut as exactly as I could, but when I disable NetworkTransform, my player doesn't sync with the server anymore
fuck this series is so good man, thanks for your time
Thanks for your video, great explanations, great rythm
Nice video! Is there a video of you where you show how to check the player authority on the server? Would be super helpful.
If i understood correctly when we use CmdMove() with the command tag we're basically setting the method to work on the server. Then inside the server method we call the RpcMove which is a Client method since there's [ClientRpc]. Then what happens is On the update method if we're the owner of the gameobject, and if we're pressing space, we call the CmdMove() method which has the RpcMove() method inside it, which is eventually gonna move our gameobject in your client. My question is, where are we syncing the movement between the client and the server?
Answer to my question should be: When a client presses "spacebar" it executes the CmdMove() and then broadcasts RpcMove() to all clients. However only the gameobject owned by the client that pressed the space bar will execute rpcmove and perform the movement. This ensure that the movement is synchronized across all clients, but only affects the gameobject owned by the initiating client
plz can somebody help me i got stuck unity tells me that !hasAuthority isnt known
So I have a self balancing ragdoll setup with player controlls, so I I want to sync the ragdoll joints and the parts and stuff, do I need to add the network transform and the network identity component to every single child in the player hierarchy?
The Telepathy Transport uses TCP. Isn't UDP better suited to face paced games like shooters?
Thank you very much for this effort👍
Thanks for this amazing tutorial bruh
how did you do the server stuff did you created it alone or you bought a amazon cloud server or google cloud server?
whenever i connect a client, the host and client use that new player?How do i keep the host using the original player?
If each player prefab has it's own camera, you need to write a script that disables it if it's not the localPlayer.
I'm thinking of creating a multiplayer fps for LAN hosting - mirror or photon?
Just for LAN? Regardless, I'd say Mirror since you don't have to pay and it's a lot simpler in my opinion
@@DapperDinoCodingTutorials Ah okay, will you be covering how to set everything up and implement it into games?
There is a bug that if I move one sphere (client A) to the point that it will touch second sphere (client B) then I can move second sphere (client B), not the original one. So client A moves client B instead of his sphere. I've reproduced the same issue after downloading your project from github on my PC. It is about the version of Mirror?
Nah i didn't Found Such Bug i even tried to recreate the scenario u are talking about but i was not able to remake that one so i am pretty sure u did something wrong
Why can't you just do if(input.getkeydown()) for movement? Is the ! Necessary
No, it's not necessary, of course. He just checked all reasons for leaving the method right at the beginning in order to get them out of the way/head. In this small piece of code, it might look weird, but it's a good style for bigger or more complex methods
it's always better to check against something than checking for something, don't ask me why but I see it alot, I'm sure I'll learn why eventually :P
if (input.getKeyDown(KeyCode.Space)) means if the key pressed is space, then do this code. The ! makes it NOT so if key entered is NOT space, then do this code. It is necessary for logic
Thanks for amazing video.
No problem :) Glad you enjoyed
how do u put the networkBehaviour, I can't mine just appeared red. But if I used Using UnityEngine.networking, it said that the network behaviour will be depreciated
add using Mirror to the list of libraries at the top
@@ballboy2.029 it says Mirror cant be found. do i need to get the library from somewhere else?
@@slime8045 Yes, download Mirror from the asset store and import it to your project.
I have the same problem where I have imported mirror however when I write “using mirror” at the top of the script it doesn’t work
have you guys got multiple visual studios downloaded? i think i may be that i have 2016 and 2019
Is mirror really that great when talking about a larger scope ?
Like, if i want to create an MMORPG shouldn't I switch to photon networking instead ?
I don't really see why Photon would be any better necessarily. Have a look at github.com/vis2k/Mirror and assetstore.unity.com/packages/templates/systems/ummorpg-51212
From stress tests it has been shown to hold 400+ players in a really small map
Thanks for the answer. I used to struggle a lot when talking about unity's multiplayer assets without ever understanding what differentiated every of these networking systems.
Do you have any documentation for that ?
Nawlian - Mat also. You can’t make an MMORPG. It is literally nearly impossible as a solo indie dev, which I assume you are.
@@GymCritical Assuming someone can't do something is quite close-minded. I'm not saying the odds of one person finishing an entire MMORPG are high, but flat out stating it's impossible is a little excessive don't you think?
Will be great if some one can answer this question.. When you say the method CmdMove will be run on the server, where exactly will the code be placed. All the script files will be in available on both the server and client . So do we check using the code to see if this is a server or will this script be only placed on the server physical machine?
Wont the client rpc tell ALL the clients to move? Why is only one client moving?
if (!hasAuthority) { return; } makes it so that the Cmd is only for one user, then the client rpc tells all the clients to move. But the script is on each one of the players, so on the client rpc it should tell one object on each client to move. I'm not sure what your question is.
@@spidernh honestly i dont even remember lmao
the object is teleporting on the map because you're telling it to teleport by resetting it's Vector3 position.
instead try and set it's rigidbody2d.velocity in the direction you want it to move;
`rigidBody.velocity = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")) * speed * Time.fixedDeltaTime;`
Deltatime only needs to be multiplied when changing things over time. Here you are instantly setting the velocity to a value, meaning the body will now move at that speed (position change over time), but you are multiplying it with deltaTime, which makes no sense. Like saying it should now go at X meters per second per second, which sounds more like an acceleration and not a speed, but you are setting the speed to this value. Hope I make sense. :) To put it another way, the physics engine will already move the object at its velocity multiplied by the relevant deltaTime in the physics step, so no need to multiply by deltaTime when setting velocity. The deltaTime might even be different in the physics step than here.
You are making my dreams come true :D
"Weaver: stop because compile errors on target"
Most likely you made a error with the script.
Hi ! Nice video ! Just wanted to make sure, event if I use a client hosting kind of server, I still can have a full authorative server even tho the server is the host client or its better to have dedicated server when we want to have everything ran on the server ? Thanks
To stop hackers from moving your character can you not just check if the input came from localPlayer ?
Nope, because that localPlayer check is being ran on the client so it can still be hacked
@@DapperDinoCodingTutorials I'm still working my way through your videos but do you cover the validation logic for these scenarios at any point?
By adding command tag the ball jerks and moves when I press space. host one works good but the client one jerks. Not sure if its a problem or not
If ClientRPC calls that translate method on all the clients, why pressing space didnt move all the objects.
Nice tutorial! Just wonder what sort of project setting you used for the graphics?
Mine is just in default 3d, the lighting and skybox doesn't look as good. Thx!
Thanks for that very informative tutorial. I just got one question: With the ClientRpc function "RpcMove" you said that this method runs on ALL the clients, but why is only our client moving since we don't pass any Network Id to the server?
"RpcMove" runs on all the client applications, but only applies for the single object where "CmdMove" was called.
@@luisjs thanks!
@@luisjs thanks!
o.o
Why not using Unity Netcode with Dots? That would be nice to see.
hi thsnkd for the video
any tips on how to connect vr headset to a network using steamvr and mirror ?
steamVR please and also how to use DOTS with mirror ???
I'm a bit confused, mostly out of ignorance. So creating the CmdMove function makes sense but why implement it within the player script if it's server code? Am I understanding that right? CmdMove method is executed as if it were the server? Why not create a method within the server code that validates and is called by the player and the player sends as a parameter a callback of RpcMove? And as for RpcMove I get that the server executes this method but what is the sequence of events here? When one player wants to move they call CmdMove which then tells the server to "move me" and then the server calls RpcMove but is RpcMove being called on every single player script in the scene at the same time or is it only calling RpcMove for the player script that initiated? How does this tie into syncing player positions?
Hey! Love the Vids! I was wondering how do I get the Github Documentation of mirror onto Visual Studio or Visual Studio Code?
movement script btw:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
public class PlayerMovement : NetworkBehaviour
{
[SerializeField] private Vector3 movement = new Vector3();
[Client]
void Update()
{
if (!hasAuthority)
{
return;
}
if (!Input.GetKeyDown(KeyCode.Space))
{
return;
}
transform.Translate(movement);
}
}
Quick question! I want to use the new input system and I'm using bools for button input and for some reason the bool isn't changing not sure if you covered this but how would I implement it into the game?
network identity dosent work for me my playre script says there no such thing as networkBehavior
Did you ever get this fixed?
I just solved it, add 'using Mirror' (without the quotes) to the top of your player script, for example:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
public class Player : NetworkBehaviour
{
[SerializeField] private Vector3 movement = new Vector3();
[Client]
private void Update()
{
if (!hasAuthority) { return; }
if (!Input.GetKeyDown(KeyCode.Space)){ return; }
transform.Translate(movement);
}
}
@@scottdarcy6062 Ok thx
@@scottdarcy6062 yeh i got it fixed
@@scottdarcy6062 Thx
Please tell how i can implement validate Server Authoritative Movement? please i really wanted to know it somehow
How did it work with you without "Using Mirror;" ??
He's using a namepsace, I think that's why.
@@acfgcnbjh actually I saw this clip yesterday, I think that "use mirror" added itself when he changed to NetworkBehavaiour ...
But thank you anyway :)
holy potato you are a life saver, thank you so much, i was stuck on that for soooo long :))))
great now how do i assign a camera to use just the client but its not the parent in the prefab.
If I change my player and input scripts from mono behavior to network behavior will they still work on offline mode? I have a PVE option and a local co op option also and I don’t want to break them.
I am doing everything like you did but for some reason the last player that joined controlls all players
Moving with RPCs brings a latency, of course. A better approach could be to still allow the client to move locally, but let the server decide if the position change was correct and to change the position back, if a cheater teleported, for instance.
I'm stuck in implementing this, any help?
Watch out if you are using the new input system!! (see below)
Problem: You can't put the "PlayerInput" component on every Player Prefab you want to spawn and move, it won't work if you have more than 1 PlayerInputs
My solution:
1) Create a new GameObject with the PlayerInput component
2) Create a new script to overwrite the Network Manager Script (to do that, just make a new c# script and replace "MonoBehaviour" with "NetworkManager")
3) Override the OnServerAddPlayer() method
4) Instantiate the players as a child object from a GameObject with the PlayerInput component
5) For new user joins, you need to check in the start method of Player.cs if the current players are already a child of this gameobject:
if (!gameObject.transform.parent)
{
gameObject.transform.parent = FindObjectOfType().transform;
}
I hope this helps, thanks to DapperDino for the great video!
Can I multiply movement with time.DeltaTime to make it smooth?
Mobile joystick not working after applying this. Can you help ?
i'm getting this error in unity "NetworkBehaviour namespace could not be found" and i'm stuck right here
just add a library in your script: Using Mirror;
@@muskito doesnt help
Anyone get "The type or namesapce name "Steamworks" cannot be found (are you missing a using directive or an assembly reference)?
For me, the [Client] Tag produced an "Invalid IL code" error. I had to remove it!
Are you using Unity 2020.2? I think that's an issue that is yet to be solved so I'd recommend using 2020.1 for Mirror at the moment
Thanks for saying this! i couldn't work out what the issue was but it was this! still an issue today on 2021.1.13f1
Can someone help me? When I type anything having to do with mirror, visual studio isn't recognizing it and underlining it in red. I said using Mirror and yes the game works but visual studio says its wrong... I'm not on visual studio community, just vs
Hey Dino. Command in client, client can remove Command ??
I'm trying to make my own thing from scratch, right now I have an issue where the client never has authority. Is there something you do in this tutorial to give the client authority? if so I can't find it.
Edit: I figured it out, but im keeping the comment here so if other people get this issue they can see how I fixed it. It was literally just that I had "NetworkManager List Server" as my component instead of "NetworkManager". I'm dumb.
hi man when i did the same code of the clientRpc Movement but i just changed it to rigidbody movement the players movement didnt synced can u help me with that ?
I tried changing the MonoBehaviour to "NetworkBehaviour" but it was underlined in red when I did that. I have added "using Mirror;" but that just gets underlined too. Why is this?
i just typed it in at first and it wouldnt work. i started retyping but i let it finish the word for me and it worked.
I was using Unity 2019.3.12f1 and it had the same issue for me, try using older unity like Unity 2019.1.5f. This did the trick for me.
@@kaloczikvn Thanks mate!
change the namespace to Mirror i.e wrap your NetworkBehaviour with: namespace mirror {class goes here}
The player on the client will not move for me. Any ideas?
You have to give Client Authority 5:47
@@alfenstein6356 yeah I did that, might have missed my other message that explained what I did wrong. Basically I was running an old build, I had to delete it and build from scratch because just building wasn't overriding the old build for some reason. Thanks for trying to help anyway!
i don't understand the RpcMove() part, i've already used Rpc with photon, but now you called RpcMove() for every client, but why not every player move at the same time then? because of authority?
Exactly my question
i need an answer for this question.....
ikr, how??
Hey, I have a problem. Everytime I use Mirror, it adds CapsuleCollider and Rigidbody to my character. Anybody knows what the cause of this may be?
7:06 Why Dont We Use isLocalPlayer?
Can somebody explain what the server is? Is it the hosting client itself or a second instance running on the hosting client? And technically can't the hosting client then easily cheat?
If you make the server validate ALL player movement, wouldn't that make player movement have massive input delay based on ping?
Need to implement client side prediction which is difficult but prevents cheating
hi im working on a small project its a unity2d topdown 4 directional movement and shooting multiplayer game i got the movement and faceing right but still have problem on the client tho i cant make him shoot in diferent direction it only shoot in the default direction is any one here good at unity networking i dont know how to make the direction var works on the client public int direction????
whenever i put if(!hasAuthority) {return;} it just disables all of my script below except for movement and turning around!!! Does anyone know what to do to fix this?
Wait! I appreciate that you already have a NetworkManager, but how did you add it in the first place?
I guess you've figured it out by now, but it was in his previous tutorial. You add it on 'Add Component' in the Inspector tab.
Thanks!!!
how to play sound on client and server ?
would you be able to connect using the port "localhost" even if you aren't on the same wifi connection as the server host?
If by not "on the same WiFi connection" you mean across the internet then you'll probably need to setup port forwarding on your router. Unless you use a network transport that can do Nat punchthrough.
I have a problem, when i run, the ball doesnt move, but makes a clone that moves and stays the same place, someone know how to fix it?
idk if anyone has asked yet, but why did you use a namespace here? new to coding, just asking cuz I don't think you mentioned it
In your patrons, you didn't say the Russian guy's name lol :). But I don't get something.... Why the 1 dislike though???
How do I validate?
What is it that you want to validate?
When I input your tutorial folder into my unity I immediately get errors and cant run anything. Is there a typo in the script?
u tried using the same unity version? also i havent importerd his tutorial
How can we change HUD ui ?
I want to create a simple multiplayer card games for 2-4 players. Is there a way I can use mirror to make such games with random matchmaking and other stuff?
yes
Sir Multiplayer game has 100 players and if you want to play a game with 100 players of 4 friends, how can you invite 4 friends?
hi how i can put cameras for every player and everyone see their own camera?
Edit: i watched tutorials and problem is solved