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
  • РазвлеченияРазвлечения

Комментарии • 122

  • @aryavatan
    @aryavatan 2 года назад +11

    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.

  • @Shahmuradov
    @Shahmuradov 2 года назад

    Amazing tutotiral series! Looking forward to part 5 where we the camera follows each player's character

  • @LeoStaley
    @LeoStaley 2 года назад +1

    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.

  • @taikigrim
    @taikigrim 2 года назад

    Thank you for these tutorials, really looking forward for follow ups :)

  • @ItsTheHolyPotato
    @ItsTheHolyPotato 2 месяца назад +1

    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.

  • @ImNotGam
    @ImNotGam 2 года назад +2

    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.

  • @theus81423
    @theus81423 6 дней назад

    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.

  • @yaaannn8126
    @yaaannn8126 2 года назад

    this is so helpful ty so much

  • @yorimur
    @yorimur 2 года назад

    Amazing explanation ❤ Please continue 💪 So, Can we do animations same way movement ?

  • @robert.thompson
    @robert.thompson 2 года назад +3

    These videos are really good! I would recommend going a little slower maybe, I have to pause a lot!

    • @ZygerGFX
      @ZygerGFX  2 года назад +3

      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.

    • @JohnnyCodes
      @JohnnyCodes 2 года назад +3

      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.

  • @lukakvlogs1478
    @lukakvlogs1478 2 года назад

    Love this series!!

  • @0gameir834
    @0gameir834 2 года назад +1

    Hi, thank you very much, please include a select map tutorial if possible.

  • @studio_gimbap
    @studio_gimbap 6 месяцев назад

    Thank you very much!

  • @pala9983
    @pala9983 2 года назад

    Nice tutorial!

  • @brodiemcilfatrick7911
    @brodiemcilfatrick7911 2 года назад +1

    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 😀

    • @brunoayre2234
      @brunoayre2234 Год назад

      Same question. Not too sure how to implement it though...

  • @halladutchi
    @halladutchi 2 года назад

    Love this series and need it so much! Thank you an please continue! :)

  • @williamrosengren3139
    @williamrosengren3139 2 года назад

    Good Tutorial :)

  • @justinsijbolts
    @justinsijbolts Год назад

    "Previous video" doesn't seem to be working in the description

  • @thoride_
    @thoride_ 2 года назад +1

    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!

    • @itsjstleo
      @itsjstleo Год назад

      I'm trying the same thing at the moment. Did you get any solutions?

    • @ohnepixel_enjoyer
      @ohnepixel_enjoyer Год назад

      @@itsjstleo you fixed it?

    • @olof4476
      @olof4476 Год назад

      Did you find a solution? struggling with the same problem atm

    • @itsjstleo
      @itsjstleo Год назад

      @@ohnepixel_enjoyer nope...

    • @theconfusedllama9405
      @theconfusedllama9405 4 месяца назад

      Create an empty game object and MOVE the SteamManager script from the NetworkManager game object to the new game object.

  • @Chrizzonator
    @Chrizzonator Год назад

    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.

  • @Njoyy-wo9ti
    @Njoyy-wo9ti Год назад

    Just a question, If I want objects getting destroyed over the network or like Vfx show how would I do that ?

  • @Keroyz
    @Keroyz Год назад +1

    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?

  • @zywiiz4729
    @zywiiz4729 8 месяцев назад +1

    Hello, when i change the scene all client are disconneted, why?
    Thx for your answer

  • @tobin7673
    @tobin7673 2 года назад +1

    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.

  • @youtuber9991
    @youtuber9991 Год назад

    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?

    • @ZygerGFX
      @ZygerGFX  Год назад +1

      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

  • @syncronice8070
    @syncronice8070 Год назад +1

    Hey how can i load more then 1 scene, i try it now since days

  • @kristianwant6775
    @kristianwant6775 2 года назад +3

    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?

    • @lilwilly4953
      @lilwilly4953 Год назад +1

      I have the same issue

    • @kristianwant6775
      @kristianwant6775 Год назад +1

      @@lilwilly4953 let me know if you solve it! I gave up after this haha

    • @FedeRzVz
      @FedeRzVz Год назад

      @@kristianwant6775 Some news?

    • @kristianwant6775
      @kristianwant6775 Год назад

      @@FedeRzVz unfortunately not, i stopped following the tutorials after this

    • @FedeRzVz
      @FedeRzVz Год назад

      @@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?

  • @channeltrash6257
    @channeltrash6257 2 года назад

    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.

  • @Keroyz
    @Keroyz Год назад

    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.

    • @ZygerGFX
      @ZygerGFX  Год назад

      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.

  • @Keisuke_Baji
    @Keisuke_Baji 2 года назад

    Ты лучшая! :3

  • @xzcw2953
    @xzcw2953 Год назад

    Does this use the new stem network

  • @ramonhiide
    @ramonhiide 2 года назад +9

    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!

    • @ZygerGFX
      @ZygerGFX  2 года назад +1

      come join my discord and see if anyone can help you!

    • @iamskyrimwarrior
      @iamskyrimwarrior 2 года назад

      Same problem. But how I can see it's like each player has own map.

    • @confus1on723
      @confus1on723 Год назад

      I have the same issue. How did you fix it?

    • @sebastianschafer7751
      @sebastianschafer7751 Год назад

      Did you fix it? For me only the host is visible

    • @FedeRzVz
      @FedeRzVz Год назад

      @@sebastianschafer7751 Did you fix it?

  • @neutron3768
    @neutron3768 2 года назад

    please, make a video on how we can list these lobbies.

  • @t0xangames207
    @t0xangames207 Год назад

    1:16 Why do I need this line if it is already DontDestroyOnLoad ?

  • @simplisticgames2036
    @simplisticgames2036 Год назад

    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.

  • @ashdev
    @ashdev Год назад

    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.

    • @ZygerGFX
      @ZygerGFX  Год назад

      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 :))

  • @quackncheese
    @quackncheese Год назад +1

    With newer versions of Mirror it says ClientAuthority is obsolete.. any ideas on what to do?

  • @krystiangraj9154
    @krystiangraj9154 2 года назад

    Hey, why transform.position for client do not change? All the time is on (0,0,0)

    • @ZygerGFX
      @ZygerGFX  2 года назад

      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.

  • @serefcaliskan4865
    @serefcaliskan4865 2 года назад

    " 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.

  • @YadroGames
    @YadroGames 2 года назад +1

    your tutorials like Brackeys, But not face to face and black background, ;)

  • @KeyatoKT
    @KeyatoKT Год назад

    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

    • @ZygerGFX
      @ZygerGFX  Год назад

      Check my discord there's a channel which explains it :))

  • @Dara-gq6jl
    @Dara-gq6jl 2 года назад

    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

    • @ZygerGFX
      @ZygerGFX  2 года назад

      Are you actually sending the rotation data ? You said you have a script controlling it but do you send this data over the server?

    • @Dara-gq6jl
      @Dara-gq6jl 2 года назад

      @@ZygerGFX not really sure, all my script is in a network, I’ll prob send a pastebin

    • @ZygerGFX
      @ZygerGFX  2 года назад

      @@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.

    • @Dara-gq6jl
      @Dara-gq6jl 2 года назад

      @@ZygerGFX thank you so much, your an inspiration

    • @Dara-gq6jl
      @Dara-gq6jl 2 года назад

      @@ZygerGFX cause mine is really weird as the cameras are switched on the players for some reason.

  • @rabiehaddad1925
    @rabiehaddad1925 Год назад

    I got third person shooter from invector where to assign it its going to work

    • @ZygerGFX
      @ZygerGFX  Год назад +1

      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

  • @meeperhere
    @meeperhere 2 года назад +1

    RUclips: 3 comments
    Me: can i see them?
    RUclips: *n o*

  • @NBGTZ
    @NBGTZ Год назад

    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?

  • @werlig
    @werlig Год назад

    My characters dont sync between clients, I did everything like in the video and still not work :(

    • @werlig
      @werlig Год назад

      Fixed! I had a mirror newer version, now i'm using the 40.0.9 and it work :)

  • @etcoolgame
    @etcoolgame Год назад

    W

  • @carrun0
    @carrun0 2 года назад

    How could i make it that each player gets their own First person character rather than what u did here?

    • @bradymeyerhoeffer3703
      @bradymeyerhoeffer3703 2 года назад

      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!

    • @lol-xc5bz
      @lol-xc5bz Год назад

      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

  • @aonalt
    @aonalt 2 года назад

    When will you make another part?

    • @ZygerGFX
      @ZygerGFX  2 года назад +2

      new multiplayer tutorials next week

    • @aonalt
      @aonalt 2 года назад

      @@ZygerGFX Awesome! What is it going to cover?

    • @ZygerGFX
      @ZygerGFX  2 года назад

      @@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

    • @aonalt
      @aonalt 2 года назад

      @@ZygerGFX Ok thanks!

  • @Duxkd
    @Duxkd 8 месяцев назад

    its telling me hasAuthority couldn't be found how can i fix it ?

    • @cjhw
      @cjhw 2 месяца назад

      Did you fix it? Idk how to fix it either.

    • @Ab1bok
      @Ab1bok 2 месяца назад +1

      isOwned@@cjhw

  • @technobrawlofficial
    @technobrawlofficial 6 месяцев назад

    Why is it that the host can move but the 2nd player cant move?

    • @utkayfirat
      @utkayfirat 2 месяца назад

      did you fix it ?

    • @technobrawlofficial
      @technobrawlofficial 2 месяца назад

      yeah you have to use a client network transform instead of a normal one
      @@utkayfirat

  • @talha_xxl
    @talha_xxl 2 года назад +1

    Kalp at lan bana❤

  • @Shadowkiwi
    @Shadowkiwi 2 года назад

    Anyone else run into an issue where the second player just falls through the world?

    • @ZygerGFX
      @ZygerGFX  2 года назад +2

      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.

    • @Shadowkiwi
      @Shadowkiwi 2 года назад +1

      @@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 :)

    • @FedeRzVz
      @FedeRzVz Год назад

      @@Shadowkiwi How did you fixed it?

  • @EvilTaco
    @EvilTaco 2 года назад

    Movement player? 😳

  • @agoq6829
    @agoq6829 2 года назад +3

    amogus🍉

  • @Taki7o7
    @Taki7o7 Год назад

    I like this series a lot, but unfortunately you teach a lot of bad practices ._. #nohate

    • @ZygerGFX
      @ZygerGFX  Год назад

      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 :)