Archives for posts with tag: 5SD037

Network is both fun and frustrating. This week I continued working with the networking code, the problem however is that it is going slow. You need go about coding in a bit different way than you do when  you code otherwise. Because when you code for singleplayer you don’t have to take into consideration what happens to the object when other people see it. In a network however you need to send the location of your player to the others, but at the same time enable the code to be able to get the movement input from the other players as well.

That I can tell you is a pain to get right. I’m not completely there when it comes to wrapping my head around how to fix this, but I’m slowly getting there. Right now we have a way to update the players position on the other clients, the next thing we need to do is to synchronize the creeps which we call soldiers with the other clients, that means we need to implement a way that only one player is setting the positions of the creeps and updates whether or not they are alive. This is however the problem, the code needs to be reachable by all clients, so they need to know that a creep have spawned, where it spawned, what team it belongs to, how much hp it has and what its current action is.

Sounds simple when it is put it like that, however getting all that into a script, that we already have made is not that easy. Firstly I wasn’t the one that wrote the original code, so I need to first look into the code, understand what happens, then rewrite the whole thing so that the script that spawns creep only gets called once, so that the game objects that represents the creeps is spawned locally but are controlled from the host. This needs to be done for every single object on the playing field. Right now that is what happens with the players, so that the players can see each other.

At least I got that to work at last, we had the weirdest bug that made 1 player see the other and see all movements, but when another player connected and selected a different team, they couldn’t see anyone else than the players belonging to their team. The other team could still see everyone. That said, I solved the bug at last, simply just one integer that was different, once I put the integer to the same for both teams, it worked fine.

In anycase, here’s what the client and “server” looks like at the moment, graphics are just placeholders right now, so it doesn’t look good, but at least we have something that is somewhat playable.

ingame

server

 

I say “server” because right now the server actually shows what is on the screen, reason for it being blue is that while connecting the clients the camera scrolled into something that doesn’t contain anything and it gets blue. The little disconnect window is the server window.

In any case, the work goes forward, although slowly, but we’re getting there. Next week I’ll get some help with the networking, which I need, that said, we also need to set up a plan on how we want the game to work. As I see it, we should maybe make connection and server boxes in a different scene, so that we need to load a new scene then wait a little bit before the game starts so that all clients have a chance to load the game before it begins.

This week I’ve been looking at how we can get the networking to work and started working on a start menu so that we can get the different clients to connect to eachother. To test this and to get that to work I started working on a chat room. Right now it’s just a basic chat room so that everyone can talk to each other. It now works, it doesn’t look that good however but it’s just a temporary interface.

chatscreen

 

As you can see I’m able to communicate through a server by sending message and you get a notification that someone has joined the channel. All of this however is more or less based on a pre-existing chat. I have changed that you don’t write in a nickname in the chat window and select that in the start menu instead. Reason is to open up for a login system at some point. The start menu doesn’t have all the functionality as it should have, but for the alpha it’s okay, we just need a way to sort the different users apart and have them select the role they want to play. Then we need to sort some kind of priority out so that if 3 people have selected the same role, the one who have the lowest or highest ID gets the role they have selected. Ideally it should be locked, but for the alpha this is not something we want to do. The main focus right now is to get an alpha in a playable state so that we can test the game and modify scale and the feeling of the game.

Anyway, going back to what I’ve been doing, I’m currently looking into how to send custom packets to the server, so that the client can interpret the package received, handle the package and then say that you’re ready or not. Once 4 players are ready the game should start. After that we need to have a way to communicate with the other computers, knowing if the others have loaded the game or not. I’m not sure how to solve this however, in the beginning however what we want to do is to add a timer for when the game starts, so that each client gets into the playing scene, then the game starts after 2 minutes, or if we have a signal that all clients have joined and are ready to play, the timer is shortened to 30 seconds or so. That’s what I want to look into for next week however, this week I need to find a way to be able to send instructions to the other clients, so that we know when we have 4 players ready and get the right scene loaded.

Other than that the game is moving forward, faster than we thought it would at the start, we hope that by the end of next week we will be able to put something together and have something playable, that resembles a moba. Then we need to add the commander interface and actions. Unity is easy to work with, but it takes a little transition to understand all the concepts and I’m still in the learning stage, so coding takes a bit longer than I’m used to.

Tata for now, and next week I’ll hopefully be able to tell you a success story about how we were able to load a level once 4 players are ready.