Unity Multiplayer Game Dev Log #1 – Networking

Unity Multiplayer Game Dev Log #1 - Networking



hi so I'm making a game at the minute using unity it's a multiplayer game so I've been working on the networking code not using any of unities built-in stuff many for a challenge but also so I would have more control over how it works and how I optimize and also for learning experience I'm using sockets to do it not the dotnet socket clients like TCP clients I'm just using the raw sockets at the minute it's not server Authority apart from for loading the scene and responding the players it has a chat box it's not perfect there are a few bugs as you can see there chat box send message area doesn't clear when you send a message and also sometimes the IDs are off also the movement data is sent UDP but it's received on TCP socket well it's sent to the server on UDP and then from the server to the other clients it's sent via TCP which isn't great you'd want to UDP all the way like both ways from the server and to the server the there is you'll notice one of the characters jingling on on the other clients and that'll be because there's a hitbox discrepancy so when you send your position data who thinks you higher than you actually are and then because hitbox isn't touching the floor you'll fall but then you'll receive more movement data and teleport you back up a little bit jiggle up and down so that's just a small book an easy fix easy fix for that the art could deal with it some improvement I put that together in about 15 minutes today just art was nicer than having a capsule there's no rotation at a minute I've had a very bare-bones that want it to be something that can use for other projects and a knack and for hoff and make this and again with different control systems so there is a there's a lot left to do obviously you can see that it's very basic of the minute I want to one of the main things that I want to add is some standard rigging so I can do some motion capture with a Kinect camera I think I'll be really cool it's just not this really not needed but I think it would be a fun project to do with this like I said server authority would probably be the next step to make this better not I'm concerned about hacking but I think that it's important to know these things I'm I'm interested in it other problems I have lined up is because it's multiplayer having people in different scenes unity the minute as far as I'm aware doesn't allow for people like loading multiple scenes you have their load them in an additive way on the server but then a low client you don't really want to be loading more than one scene because it's not optimal for when in the game so that's a hurdle that I haven't I don't know how I'm gonna get past but I'm sure with some trial and error I'll find a way around it there's a lot of code cleanup to do like adding locking on some of my resources because all all the networking code is using async methods I want to convert a message pack which is sent when you send data it's like a data model that you can send with because it's a minute I'm just using the standard C sharp binary converter so it could be a smaller data packet so I mean they're not very large in a minute but I'd like to optimize things I also have that I always want to add poly which is for retry policies say if I send the clients that command to load a scene or to spawn a player if they don't complete that for some reason I want a retry policy or see if your if I tell everyone to spawn their characters and one of your one of the clients fails to spawn their character or another person's character if there's no retry policy enabled then they'll just play the game without being able to see their character or each other's characters which isn't great so yeah it's a lot to do obviously I want to add in I'm aiming for any RPG at the minutes the kind of game idea I've got in my mind so Pat of Exile Diablo ask game so I'll have to think about how I can add in those features but it's going well I'll try and get another video out within two weeks for an update and where I've gone and also if a code review video would be interesting to people I might make one of those explaining my ideas on how I structured my code the principles I followed such as the solid principles and pops up etc sir if that's interesting just let me know and I'll I'll make one looking at the code Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *