One year later
It's been about a year since my last post primarily because I was undergoing some pretty hardcore medical treatment that practically took over my life for 6 months last year. Not that I didn't have spare time to do anything but that time was spent playing video games; to compensate for a horrible medical experience those 6 months were.
The other reason was that, while the prototype in its current form worked, it wasn't efficient enough to my liking and had a glaring flaw that potentially limited the size of the world. So I had to somewhat put the project on hold until I could address these issues:
Efficiency
I was pretty happy with how the server handled the game logic. Everything from the movement of the players, to the placement of a decoration, to being able to have a private conversation inside a house (with closed doors) was all server-authoritative.
This part is super important to me because, as I'm just a single dev, there's no reasonable way for me to handle players cheating with potentially hundreds if not thousands of players. So the server logic CANNOT take shortcuts. So, while most MMOs out there are making themselves more vulnerable in favour of making it more high-octane action combat, I doubled-down on the idea that I want to effectively build a Role-Playing game in a multiplayer setting; so a slower-paced combat system is more fitting in favour of making the server focus on the legitimacy of all of the player actions as well as handling the housing and instancing.
There is, however, one problem: a lot of the logic relied on the physics engine. For those unaware, physics calculations aren't cheap and if I was to make a game where hundreds of people would log in and play, the server would be under a massive amount of stress. I had to find alternatives.
Glaring Flaw
Because of the server's dependency on physics, I was limited by how I could organize the world in "physical" space. There are ways to make collision detection ignore certain "layers" (which is how I handled instancing) but I was nonetheless limited by how I was laying out the various chunks of terrain; they almost all had to be in their appropriate spot related to one another... because the world was potentially so large, I was dealing with coordinates with extremely large numbers. So large, in fact, that a certain point the limitations of the coordinate system loses precision because there isn't enough bits allocated to it. You don't want to lose precision when dealing with moving objects; it's not pretty.
For the technically inclined, Unity has a rather prohibiting limitation where it can only handle its coordinates in floating values. Unreal, for comparison, can handle much larger numbers at the cost of requiring more memory.
Most games with really large world bypasses the number problem by utilizing a technique called "Origin Shifting." If you imagine the limits of the play area as a table (the kind that you can play tabletop games on), as the player gets to the edge of the table, you slide the game board back so that the player is in the center of the table. You shift the origin of where 0,0 in your game world is. Allowing you to work with much smaller numbers.
The problem with THAT is that it's incredibly difficult to pull off when you have multiple players roaming around the world, doing their thing. There are a few existing solutions for this but they're too convoluted for making an MMO.
So, because of all this, I put the project on hold... that is, until a month ago (the 11th of March).
I won't go in detail on what the solutions were but the moment I had that eureka moment I immediately wrote notes down and went to work. I essentially reworked the entire coordinate system, ignoring Unity's built-in system for the server logic and that opened up the possibility of applying Origin Shifting on a per-client basis.
And it works beautifully. I used the power of math to dictate collisions without requiring physics and the performance gains are astronomical. Physics IS math, sure, but what I'm doing are simple operations to handle what I need the server to do. I don't need layers, I don't need objects to bounce around and have friction, I don't need super-precise raycasts, I don't need oddly shaped capsules to be the collision area of wolves (if you remember Chris Spears's explanation he gave on why wolves had odd collision boxes).
I had to gut a LOT of old logic out (to the point where you almost could classify this as a complete rewrite) but it was worth it. Because it was such a massive refactoring, I took the opportunity to set it up so that I could make it playable offline as a single-player game (as it was requested by some).
So that's about 4 weeks' worth of work, I mean... I do it part-time since I have a job and Elden Ring was out so I had to play that too!
The other notable change was a shift from 3rd person to first person. I kind of like the idea to Ultima Underworld or, more to what I'm used to, the Elder Scrolls series. I'm hoping this will enhance the immersion factor. Design wise, this makes the screen that much clearer as I don't cover it up with a body all the time.
So what's next?
There's still a lot to do to ensure that all of the previously established systems work well with the new coordinate system. As soon as I'm done with that, I'm back into implementing the first game-play loop of gathering resources to build a house. That's essentially where I was.
Tell me what you think. This was pretty lengthy so I don't know how often I'll write long posts like this (or whenever or not people like this sort of thing) but I do plan on writing road-map style posts like I initially started.
Comments
Post a Comment