Ashore Dedicated Server: Part 1
Attempt #1 - Day: 1. Part 1- everything 1. one 1. 1. one.
PART !: The plan.
I’m not used to writing blogs or documenting what I do/go through so...
*Nailed the intro*...
Let me start by mentioning that
I tend to do things a bit differently when I work alone, so you might notice the following:
1-I try my hardest to never go with the "Standard" way
2-I don't search online for a solution if the problem was created by myself
3-I try the "worst" methods if I don’t know how to do the "Good" ones
Question 1: What exactly am I trying to do?
Well, this is what I know:
I want to create an application that runs the game and starts a server without actually playing the game. I did not look this up but I have a feeling that what I'm about to try doing is not the correct way to do a dedicated server (I'm sure). But I'd like to do it anyways, cause why not.
Question 2: Why make a dedicated server?
I believe it would help take some of the load from the player (the host);
I think of it like hiring an assistant that does all the hosting for you, so you get to enjoy the party and let the assistant worry about the rest.
The other reason is: I believe it’s much easier/faster/lighter to run an application to have your server up and running 24/7 than to have the game playing in the background.
Final reason: I think it’s an exciting challenge, and it’s something new for me to explore and learn from. I want to learn everything. literally everything. I mean it. ok you can go now.
Question 3: Any ideas in-mind?
As a starting point, I'm thinking; since the game already has all the code + UI necessary to run the server, why not remove everything in the project and leave the code.
So instead of viewing main menu UI > Start game > Multiplayer > Browse / Create option, it skips all of that and goes right to Create Server Menu.
Run application > View Create Server Menu UI.
Sounds fairly simple and easy thing to do, right? right? right?
Right but not really. See the way I’m doing the whole server creation thing is by storing all the selected server options from the main menu scene, take the variables to the island (Game) scene and before starting, set everything that needs to be set such as: offline mode? new save? game mode? etc... then connect + start.
so, the connecting actually happens in another scene.
Still seems like an easy fix.
Few solutions come to mind:
s 1- Disable the camera and Enable UI instead, so you run the game normally but save on performance. Which is true but that means the performance will be better but the project size will be the same. if I deleted files from the project it will result in removing something from the scene, and removing something from the scene might cause an error += disconnecting the server.
So, for this solution to work properly = the application size will = full game size. (I don’t like that)
s 2- drag all the code from the game scene to the main menu scene and have it create the server there.
This solution is ok but it gets much much complicated.
Let’s pause here and do something I ALWAYS like to do when things get complicated:
LET’S ZOOM OUT FOR A SECOND...
I’ll quickly go over a couple of questions and answer them to make sure I’m on track and did not lose focus:
Why do I want to remove/delete things?
I want the application to be as small (in size) as possible.
To make the app run quicker.
According to the game’s profiler; rendering + some scripts are slowing down the game.
Since the application will not render anything other than the UI.
I can delete every 3D object from the project because I won't really see it so...
I’ll zoom back in now.
So, to conclude all the previous gibberish this is what I’ll do right now:
0-I’ll use unity to create the application + I’ll use the main menu scene since it has everything already.
1-I’ll rename the main menu scene to “DDK” (I don’t know why)
2-I’ll remove all the game objects in scene + UI buttons and keep the Server creation Menu Displayed.
3-I’ll merge the scripts from other scenes to the “DDK” scene (To avoid changing scenes)
4-I’ll modify the code to have it connect + host after clicking on Create server instead of changing scenes
5-I’ll Delete all files except for scripts and Textures from the project