How To Make A Game With Unity Multiplayer Netcode | Network Animations & Player Controller #2

  Рет қаралды 31,098

Dilmer Valecillos

Dilmer Valecillos

2 жыл бұрын

Today I continue with Netcode For GameObjects by showing you how to handle character animation states so that we can synchronize them with other clients connected to the server or host. Some of the Unity Multiplayer features we will cover today are:
- NetworkAnimator component
- NetworkVariables Vector3 and permissions
- NetworkVariables with enum type for player state
- Using CharacterController to control the player
- Using ServerRpc to keep track of player state
- Animation state based on NetworkVariable player state
Helpful documentation for Unity Multiplayer Netcode For GameObjects:
docs-multiplayer.unity3d.com/...
The Unity Multiplayer demo shown in this video can be freely downloaded from GitHub at:
github.com/dilmerv/UnityMulti...
Recommended and very populate Multiplayer solution for Unity: (Photon 2 Unity Networking)
assetstore.unity.com/packages...
Support me in Patreon so I can keep doing stuff like this for free!
/ dilmerv
Get realtime indie development tips from me in Twitter
/ dilmerv
Subscribe to my indie development videos & game releases newsletter
www.dilmergames.com
Blog about Indie development and startup
www.dilmergames.com/blog
#unity3d #multiplayer #netcode

Пікірлер: 55
@FishPogx
@FishPogx 2 жыл бұрын
Thanks so much for the series so far. I am relatively new to unity but I absolutely love making games so far, it’s so fun! If it’s possible to make requests for future videos I would really appreciate a camera + wasd movement tutorial for netcode since I tried to do it myself but couldn’t get it quite right. Ty if you do it 😊
@dilmerv
@dilmerv 2 жыл бұрын
Thank you and you could easily have the camera inside one of the player game objects, there are also other ways to smooth the camera movement so that it looks more natural.
@lichuntak5143
@lichuntak5143 2 жыл бұрын
Thank you for making these high quality tutorials.
@dilmerv
@dilmerv 2 жыл бұрын
Thanks a lot this means a lot to me !
@danielyde187
@danielyde187 2 жыл бұрын
I am working on a multiplayer projekt for highschool exam, and even though I am fairly new to making games, this tutorial is so easy to follow and understand! Got a sub from me!
@dilmerv
@dilmerv 2 жыл бұрын
Thank you Daniel and your feedback is super appreciated 🙏 welcome as well :)
@yanivavrahami842
@yanivavrahami842 2 жыл бұрын
Thank you for making these videos they are great!
@dilmerv
@dilmerv 2 жыл бұрын
Cool thank you I am glad you are enjoying the series, there is a lot more coming ;)
@vitaliizurian4193
@vitaliizurian4193 2 жыл бұрын
Thank you!
@nemethszabolcs9239
@nemethszabolcs9239 2 жыл бұрын
Thank You !!! Working everything! Liked & Sub!
@dilmerv
@dilmerv 2 жыл бұрын
That’s great news 🎉 I am glad you got it working and also welcome to the channel ! Thank you 🙏
@mostafamostafa-fi7kr
@mostafamostafa-fi7kr 2 жыл бұрын
thank you . keep recording bro
@dilmerv
@dilmerv 2 жыл бұрын
For sure thank you for your support !!!
@blackturn
@blackturn 2 жыл бұрын
Hi I don't know what your final goal is for this series of tutorials, but on my part there are two parts that I would like to see. The first is to create a server list and lobby to find games without having to enter the IP. Example With the Steam service. The second would be to show how to choose a map, the type of game, (DM, TDM, or other), make the player choose his team, his equipment, his character from all of that from the lobby and ingame. In short, how to manage information through scenes. I love your tutorials! Keep the good work
@dilmerv
@dilmerv 2 жыл бұрын
Thank you and honestly I love your feedback, I have in my list a Lobby feature and also ability to send events to specific clients, I am going to keep this series for beginners but later on I may work on more complicated experiments. Thanks for your comment !
@ppreshh
@ppreshh Жыл бұрын
Really appreciate this content man. I've got a question: I'm trying to figure out what to do when the controls are physics based (ie. a driving game or a flying game where forces are applied rather than the transform being directly modified by client input). The docs led me to ClientNetworkTransform which allows the client to have authority over the transform. With this both host and client are moving like how I'd like, the issue is that I lose server side physics simulations (vehicles don't react to each other when they collide; when I run into another player they're essentially a static obstacle, no budge). Any chance you'll do a physics controls based rendition of networking player controls with Netcode for Gameobjects? Or any tips?
@djt-lex3962
@djt-lex3962 2 жыл бұрын
Thanks man!
@dilmerv
@dilmerv 2 жыл бұрын
Anytime my friend !
@rx2316
@rx2316 2 жыл бұрын
That's a surprising new serie
@dilmerv
@dilmerv 2 жыл бұрын
Thank you !
@krabbenkiller
@krabbenkiller Жыл бұрын
Thank you for that series, big help. But shouldnt we use Time.deltaTime for movement and rotation?
@manolov4074
@manolov4074 2 жыл бұрын
NICE !!
@dilmerv
@dilmerv 2 жыл бұрын
Thank you 🙏
@iashokk
@iashokk 2 жыл бұрын
Sir I imported a New character and i cant able to change its animation what to do to change the walk gesture for the new character that i have imported in your project
@HaeriStudios
@HaeriStudios 2 жыл бұрын
Thanks for making this series! Questions: 1. If you are are manually sending position and rotation vectors to the server with ServerRPC and also manually setting the position and rotation, what does the NetworkTransform component do then? 2. Since the NetworkVariables dictates your position and they can only be set by the server, is the movement not going to be super janky with a bit of latency and precise movement impossible, since you always will have to wait for the answer of the server to update your own position?
@dilmerv
@dilmerv 2 жыл бұрын
1- You are correct, I left the NetworkTransform in the player controller by mistake and my latest implementation should work fine without it (just tested it) since I am using the NetworkVariables with Vectors as you mentioned. 2- There will be a delay as you mentioned, how much latency I am not sure unless I do more testing, I would suggest perhaps also testing it out with ClientNetworkTransform authoritative client which allows you to capture input and it updates all the clients automatically.
@dilmerv
@dilmerv 2 жыл бұрын
Also check out my latest commit in the GitHub project in case you like to see the latest changes, I appreciate you mentioning this problem which is now addressed in GitHub github.com/dilmerv/UnityMultiplayerPlayground
@HaeriStudios
@HaeriStudios 2 жыл бұрын
@@dilmerv ok thanks for the reply. It's a bit frustrating that Unity themselves don't publish useful guides or examples how to use their API. Their docs only show very rudimentary hello world examples. But there are no good examples on how to use the NetworkTransform for an fps controller. I think the main reason you would want to use it is to benefit from their interpolation implementation which NetworkVariables don't offer. However, since they made NetworkTransforms Server write only, I was expecting for them to also publish at leas some simple client side prediction, such that the client could directly react on a players input, send the rpc to the server and then decide afterwards if the move was valid. This way you have instant reactions on you own player which makes the movement feel more responsive. However, the NetworkTransform does not allow any modification to your own transforms if you are not the host, so I have no idea how I would implement my own simple client prediction System. Is this something that you will cover in this series?
@iashokk
@iashokk 2 жыл бұрын
I have imported a new character and i have it as a main character now my character is not walking its just sliding over the environment can u tell me what to put in the network animator or tell me what to do to make my imported character walk.. thank you
@willpetillo1189
@willpetillo1189 2 жыл бұрын
How do you rotate a child object of the player? I am trying to make a networked first-person controller where the root player object rotates on the Y axis and a child object with a Camera component rotates on the X axis. I am able to get the host player to move and rotate left/right/up/down fine and the client players can move and look left/right, but the clients cannot look not up/down. Attaching a NetworkTransform object to the camera child object yields an error and I am not sure if Netcode has an equivalent to UNet's NetworkTransformChild. Thanks for the series!
@MrYanissab
@MrYanissab Жыл бұрын
Hi there ! GReat series ! Having a strange problem. Why is my Host moving twice faster than my client ? :( Any help is much appreciated !
@hrirks
@hrirks 2 жыл бұрын
Hi Dilmer, your videos are great. Can you please use the new Input System and work on a Netcode Project and make a Video about it. Thank you :)
@dilmerv
@dilmerv 2 жыл бұрын
Yes that’s a great idea thanks for your suggestion and time !
@hatrer2244
@hatrer2244 2 жыл бұрын
Thanks for the tutorial, quick question, why dont you use the Animator that comes with the Third Person sample? Seems like I am able to drag it from the components list of the PlayerArmature to the NetworkAnimator component.
@Sohneg
@Sohneg Жыл бұрын
It is possible. But you have to do three things: 1. Edit update: private void Update() { if (!IsOwner) return; _hasAnimator = TryGetComponent(out _animator); JumpAndGravity(); GroundedCheck(); Move(); } 2. Edit Start: _playerInput = GetComponent(); if (IsOwner && IsClient) _playerInput.enabled = true; 3. disable Player Input Component on prefab
@beshkekart3909
@beshkekart3909 2 жыл бұрын
I LOVE YOU
@dilmerv
@dilmerv 2 жыл бұрын
Thank you I am glad you liked the video !
@weeborweed683
@weeborweed683 2 жыл бұрын
I was trying to go with the Network Animator Param syncing way and ideally modifying the parameters in the owner client's animator should synchronize it across the network. However it seems that the Network is enforcing my client's animator to be the same as the version on the server rather than the otherway around. Is this a genuine bug of Netcode or I am doing something wrong here?
@weeborweed683
@weeborweed683 2 жыл бұрын
This is very irritating because my project used to work fine with MLAPI 0.1.0 and migrating to Netcode breaks it completely.
@dilmerv
@dilmerv 2 жыл бұрын
📌 Everyone be sure to start from this playlist where everything is organized in chronological order: kzfaq.info/sun/PLQMQNmwN3FvyyeI1-bDcBPmZiSaDMbFTi 💡Also if you like these series let me know by commenting below as it helps me in making more KZfaq videos thank you !!!
@dilmerv
@dilmerv 2 жыл бұрын
Hello everyone ! 📌 This is just a bit of information when using NetworkAnimator since I made a mistake on this video. The NetworkAnimator component is meant to automatically synchronize the state of the animation - you are responsible to set the state by checking for ownership within a game object and once the state is changed it then gets replicated automatically to all clients. In my last video I left the NetworkAnimator by mistake, I am using a NetworkVariable which I use to set the animation state for all clients including the player, in my case I ended up using Triggers and those are supported by the NetworkAnimator just yet as per this doc docs-multiplayer.unity3d.com/docs/components/networkanimator If you have further questions let me know, I also pushed all my changes and fixes to: github.com/dilmerv/UnityMultiplayerPlayground
@Ironcloud7
@Ironcloud7 2 жыл бұрын
I have followed the tutorials and I still find a little delay in the client player animations. I think it is because the animations are synchronized through the network variable and the NetworkAnimation does not work, it seems that this function is already obsolete, is there an alternative way to synchronize the animations to correct this delay? Thank you!
@ninhow_tv5296
@ninhow_tv5296 2 жыл бұрын
It does not spawn randomly. I have been looking into this the whole day and i dont understand why it isnt spawning randomly. I have the same code as you since i looked into your github. I downloaded your project and build and ran on a network connection and the spawn is not random there either. Could you pleas ehelp me where too look about it?
@dilmerv
@dilmerv 2 жыл бұрын
I will look at it tonight and review the code thanks for the info.
@beshkekart3909
@beshkekart3909 2 жыл бұрын
How to make a chat and kill tables on Netcode?
@dilmerv
@dilmerv 2 жыл бұрын
Kill tables? not sure I understand that question. NGO is not meant for transferring strings back and forth, but instead for fast actions such as gameObject transforms, I think you can build a web service / gRPC type webhook to accomplish what you are asking for. Thanks good question.
@Gr8Success
@Gr8Success 2 жыл бұрын
the question is not how you make a game the question is why ... and who would buy your game
@dilmerv
@dilmerv 2 жыл бұрын
Yeap that’s always the first question and a question not everyone ask ;) good point.
@cplshepherd4537
@cplshepherd4537 Жыл бұрын
So I found that there's a brutal issue with this approach. Imagine 2 players (say with one being the host) on a plane with a box in the middle aswell. If one player moves around the box repeatedly, the physics calculation might come out different on both sides and the models will then desync.
@cplshepherd4537
@cplshepherd4537 Жыл бұрын
I personally fixed this using a combined approach. I added a network variable for the player's position, which I update when the model is not owned by the player.
@dilmerv
@dilmerv Жыл бұрын
Thanks for your feedback and I will look into this to further clarify how to best handle this scenario.
@muchbuild
@muchbuild 2 жыл бұрын
Basically...
@dilmerv
@dilmerv 2 жыл бұрын
Nooo I said it again 😅 thanks for watching !
@darkoprod9744
@darkoprod9744 9 ай бұрын
Bug Alert 21:54 🧐
@dilmerv
@dilmerv 9 ай бұрын
I will look into it thanks
I Paid Fiverr Game Developers to Make the Same Game
10:25
BadGameDev
Рет қаралды 652 М.
Эффект Карбонаро и нестандартная коробка
01:00
История одного вокалиста
Рет қаралды 9 МЛН
100❤️
00:19
MY💝No War🤝
Рет қаралды 24 МЛН
Can AI code Flappy Bird? Watch ChatGPT try
7:26
candlesan
Рет қаралды 9 МЛН
We Need to Rethink Exercise - The Workout Paradox
12:00
Kurzgesagt – In a Nutshell
Рет қаралды 4,7 МЛН
Multiplayer Game Architecture in Unity
15:21
Shrine
Рет қаралды 151 М.
Hoverboards and Stylized Environments - OVERRIDER Devlog
7:32
Dreamteck
Рет қаралды 125 М.
3 Hours vs. 3 Years of Blender
17:44
Isto Inc.
Рет қаралды 4,3 МЛН
How I learned Unity without following tutorials (Developing 1)
18:11
Game Maker's Toolkit
Рет қаралды 2 МЛН
Как удвоить напряжение? #электроника #умножитель
1:00
Hi Dev! – Электроника
Рет қаралды 1 МЛН
Худшие кожаные чехлы для iPhone
1:00
Rozetked
Рет қаралды 1,7 МЛН
ВАЖНО! Не проверяйте на своем iPhone после установки на экран!
0:19
ГЛАЗУРЬ СТЕКЛО для iPhone и аксессуары OTU
Рет қаралды 6 МЛН