How To Make Player Movement - Steam Multiplayer Game in Unity
HTML-код
- Опубликовано: 22 май 2024
- In this video I will be showing you how to implement player movement. I will go over how to firstly move every player into the game scene. Then how to spawn players for every connection and create movement that syncs across the server.
-----Tutorial Links-----
Previous Video: www.youtube.com/watch?v=kld9s...
Mirror: assetstore.unity.com/packages...
FizzySteamworks: github.com/Chykary/FizzySteam...
Steam Docs: partner.steamgames.com/doc/home
Source Code: / 62190558
-----My Personal Links-----
Discord: / discord
Instagram: / gabzxd
Twitch: / officialzyger
Twitter: / zygerdesigns
➤WISHLIST MY GAME:
store.steampowered.com/app/16...
----Time Stamps-----
0:00 - Intro
0:11 - Transferring Players to a Game Scene
3:00 - Player Object Modifications
4:13 - Player Movement Script
7:23 - Syncing Movement
8:30 - Testing - Развлечения
Thanks for making this whole series on multiplayer development in Unity. As a relatively beginner game dev myself I still haven't dabbled with multiplayer but your tutorials will finally help me understand how multiplayer development works.
Amazing tutotiral series! Looking forward to part 5 where we the camera follows each player's character
GMTK just asked us to vote for him for the Unity devlog award, andI found you by looking at the other contestants. I voted for him, but I've subscribed to you now.
Thank you for these tutorials, really looking forward for follow ups :)
For everyone who can't get the not host players movement to work, changing Sync Direction in the Network Transform component of the PlayerObject Prefab to "Client to server" worked for me.
I love the tutorial. I use Godot myself, so I have no use for this. But I love seeing how other people program these things. It's also very weird to see that it's a lot easier to do networking in Unity, as a lot more stuff is built in, as it's a more popular engine.
I'll still be watching because it's a great video nonetheless.
If you're following this tutorial and you're making a 2D version rather than a 3D version and one or more of your player prefabs are randomly not appearing
1) Make sure the Main Camera's Z position in your level scene has a smaller value than your player prefab. The player prefab Z position seems random, and the camera is at -10 by default. This means that if your player is spawned with a Z-axis position of -11, your prefab will be invisible. One way to fix this is to set the Main Camera's Z position in your level to be very small (-100 or so).
2) The client's prefab may spawn at an arbitrarily large X and Y coordinate position. It's not that the client's prefab didn't load, it's that it loaded in a position that is not being displayed by the camera.
3) This tutorial seems to work with the latest versions of Mirror and Fizzy Steamworks. You will need to change all references of "hasAuthority" to "IsOwned" as others have already mentioned.
this is so helpful ty so much
Amazing explanation ❤ Please continue 💪 So, Can we do animations same way movement ?
These videos are really good! I would recommend going a little slower maybe, I have to pause a lot!
thank you. noted! i jsut try to make the video not so long as some people just dont want to watch longer videos but i will keep it in mind.
Unfortunately making fast paced videos are a requirement for youtube. If you don't get enough watch time youtube won't share it even though a slower video might have been easier to understand. I struggle with this when I try to make entertaining tutorials too. They end up being more for entertainment rather than tutorial but it is a fine balance. That is why I have heard some creators say it is much easier to make a tutorial on a different site like skillshare or udemy because those algorithms don't reward watch time as much as youtube.
Love this series!!
thank you
Hi, thank you very much, please include a select map tutorial if possible.
Thank you very much!
Nice tutorial!
thanks
Love this series so far. Just curious how you would implement multiple colliders on a moving object. Eg. Character has arms and a sword which move and have their own colliders as well as the body. As you said we have to have physics components on the main player object.
Thanks 😀
Same question. Not too sure how to implement it though...
Love this series and need it so much! Thank you an please continue! :)
Good Tutorial :)
Thanks!
"Previous video" doesn't seem to be working in the description
Once again great tutorial! Looking forward to the next one. Any chance there will be a video on how to quit the lobby and take you back to the host scene? I keep getting an error that the SteamAPI is trying to get initialized twice. Can't figure out how to get around this. Thanks!
I'm trying the same thing at the moment. Did you get any solutions?
@@itsjstleo you fixed it?
Did you find a solution? struggling with the same problem atm
@@ohnepixel_enjoyer nope...
Create an empty game object and MOVE the SteamManager script from the NetworkManager game object to the new game object.
In my case I want to make a turn-based strategie game with multiple characters per player.
Do you have some suggestions how to handle this easily? I mean you choose that the PlayerIdentity keeps as a parent of a character model which I guess is not the solution for my problem.
Just a question, If I want objects getting destroyed over the network or like Vfx show how would I do that ?
Hello Zyger! How I could use my Monobehaviour playermovement script on the network behaviour? For you, you use networkbehaviour on the script but since mine uses Monobehaviour functions and when I switch it to NetworkBehaviour it causes errors, do you or anyone know how to implement the script to work correctly with NetworkBehaviour?
Hello, when i change the scene all client are disconneted, why?
Thx for your answer
I feel like having a tutorial on character customization is like a necessity for these kinds of series imo. I think it would be a nice to have because in this day and age, a lot of devs want to turn their local multiplayer games into an online game.
Great videos! But I'm pretty confused:
1) Is the connection/game actually being hosted through steam? If not, where would it be hosted?
2) How and where does the server logic come into play which would actually monitor and enforce the rules of the game?
The hosting is through steam but the user who starts the host is the owner / admin of the server. Meaning they can change how it works. If you're using mirror there are restrictions on what you can do with the server logic, since most of it is done through mirror. I recommend reading the mirror docs for that. Although there are also server things you can chnage or control through steamworks. Once again just read up on it in the mirror or steamworks docs
Hey how can i load more then 1 scene, i try it now since days
Great tutorial! Following these have been so great, and very impressive. Although, the only issue i have now is when i run the game, one player spawns as per the script intends (in a random but assigned location), and the other player always spawns at x=0, y=0, z=0. I've looked through the video a few times again and im fairly sure everything matches up. do you have any ideas?
I have the same issue
@@lilwilly4953 let me know if you solve it! I gave up after this haha
@@kristianwant6775 Some news?
@@FedeRzVz unfortunately not, i stopped following the tutorials after this
@@kristianwant6775 mhh so sad, do you remember trying something like modifying the spawn position? Something like for example that they reappear at a given height so that it does not appear below the map?
Hey Zyger, or anyone who can help: i watched lobby list video, and if i start a game and the other client tries to join the STARTED GAME then the game craches out.
4:59 doesn't OnLevelLoaded(){} Function work the same? I'm asking because I think that updating to check if the SceneManager is on a currently level each frame sounds performance heavy.
It works similarly yes. The methodbI showed in video isn't really what you shpuld be doing if you actually want to release a game. But for simplicity of the video it's what I showed.
Ты лучшая! :3
Does this use the new stem network
Maybe someone can help me... Everything works, BUT when the game starts only one player is on it. I rewatched the tutorial but didnt get what I did wrong... any ideas?
Thank you! Keep up the good work Zyger!
come join my discord and see if anyone can help you!
Same problem. But how I can see it's like each player has own map.
I have the same issue. How did you fix it?
Did you fix it? For me only the host is visible
@@sebastianschafer7751 Did you fix it?
please, make a video on how we can list these lobbies.
1:16 Why do I need this line if it is already DontDestroyOnLoad ?
I am having a problem with the players that when I switch scene they are losing Authority. Anyone else have this problem? (I know this because I ran a Debug.Log(hasAuthority); ) and in the Lobby it says True as soon as we get into the game it says False.
i can notice a delay between host and client. can it be real time like pubg and other fast paced games where there is no delay? if yes how? most of the tutorials i saw have a delay. i dont know about multiplayer stuff. please help.
delays are in every type of online game, even PubG. But they make it less noticeable with a few tactics. One of which is client side prediction. But there are plenty of solutions to latency so i recommend you read up on it :))
With newer versions of Mirror it says ClientAuthority is obsolete.. any ideas on what to do?
Change everywhere in every script where you have "hasAuthority" to "isOwned"
@Wavescu I love you
Hey, why transform.position for client do not change? All the time is on (0,0,0)
The method I showed in the video shouldn't actually be used. It was a basic implementation for the purpose of the video, so it's janky and doesn't always work. I recommend making your own method to move the players position once in the scene.
" The object of type 'GameObject' has been destroyed but you are still trying to access it.Your script should either check if it is null or you should not destroy the object."
If you are getting similar errors and cannot move, it means that you have done the character setup wrong.
I discovered two solutions to this;
1- Making a regular and simple character
or
2- Using the character in the lobby scene
Description: The character is created with the button in the Main menu scene. It is destroyed "because we don't want it" in the lobby scene. It is reborn with the "Game Scene" and "make a decision!" she revolts.
your tutorials like Brackeys, But not face to face and black background, ;)
I've tryed to figure it out by myself but I don't understand how you create a way to leave the game whenever you are in the lobby or in the game
Check my discord there's a channel which explains it :))
Do you know why my mouse movement wont sync, the only thing that syncs is the x, y and z positions for my player. But my mouse script works, its just the network wont show rotation. It would be great if you could make a video on fps movement! thanks though
Are you actually sending the rotation data ? You said you have a script controlling it but do you send this data over the server?
@@ZygerGFX not really sure, all my script is in a network, I’ll prob send a pastebin
@@Dara-gq6jl sorry but I wont be able to individual look at your code and help you. but look up how to sync rotations, its fairly straight forward. since this tutorial only shows how to sync your x,y and z positions.
@@ZygerGFX thank you so much, your an inspiration
@@ZygerGFX cause mine is really weird as the cameras are switched on the players for some reason.
I got third person shooter from invector where to assign it its going to work
So invector is going to be tricky. Since it's already massive and contains a bunch of convoluted scripts. You'll need to manually convert and chnage the code to be networked and work only with authority
RUclips: 3 comments
Me: can i see them?
RUclips: *n o*
when i tried to test it with my friend we Only the host got a PlayerModal and client didnt have PlayerModel like is still in MainMenu How can I fix it please?
same, any fix?
same, any fix?
I wish but still no luck
@@NBGTZ tell me your discord i fixed it
@@ohnepixel_enjoyer How you fixed it?
My characters dont sync between clients, I did everything like in the video and still not work :(
Fixed! I had a mirror newer version, now i'm using the 40.0.9 and it work :)
W
How could i make it that each player gets their own First person character rather than what u did here?
Im looking for this too, but 3rd person pov but still attached to the character. It would be the same but just the camera in a different position, so let me know if you find anything!
Try to make a function where the camera gets rotated based on the movement of the mouse. The camera itself becomes a child object of the player, so it stays with it when the player walks. You can sync the rotation of the player across the network if you want
When will you make another part?
new multiplayer tutorials next week
@@ZygerGFX Awesome! What is it going to cover?
@@aonalt if you join my discord i do polls where people decide what the next topic will be. just depends what people vote on there :D
@@ZygerGFX Ok thanks!
its telling me hasAuthority couldn't be found how can i fix it ?
Did you fix it? Idk how to fix it either.
isOwned@@cjhw
Why is it that the host can move but the 2nd player cant move?
did you fix it ?
yeah you have to use a client network transform instead of a normal one
@@utkayfirat
Kalp at lan bana❤
Anyone else run into an issue where the second player just falls through the world?
make sure the player actually spawn above the platform. i saw a few people have this issue and it turned out to be their players weren't spawning correctly.
@@ZygerGFX Thanks that was the problem. My set position was not working correctly at first and had tried doing some round about way of doing it. Saw someones comment here about subscribing to the scene change event so looked into that and that has got it working :)
@@Shadowkiwi How did you fixed it?
Movement player? 😳
?
amogus🍉
sus
very sus
I like this series a lot, but unfortunately you teach a lot of bad practices ._. #nohate
yeah I agree, at that point in my life I myself coded with lots of bad practices and a lot of my code was super inefficient. Its much better now, still not 100% but yeah i agree with what you said :)