Showing posts with label SpaceStrategy. Show all posts
Showing posts with label SpaceStrategy. Show all posts

Saturday, March 7, 2020

Struggling with new Unity NetCode.

Before pouring out my frustration at the universe I have to say a few introductory words. 

For more than a year now the Unity team is in a process of complete technology stack overhaul. And as a part of this process they are also remastering their multiplayer game packages. They call this new technology stack the "DOTS" (Data-Oriented Technology Stack). Because now it is in an active state of development there is critical shortage of tutorials and documentation. But it is expected that in the near future the DOTS will totally replace old Unity technologies (including networking packages, which are already marked as deprecated).

Now to the sad part. One of the reasons why I switched to Unity from my self-made game-engine was to make Space Strategy into a multiplayer game. When I just started my venture into the Unity networking I thought: "Well, either way, I know nothing about Unity networking, so why should I bother with obsolete technologies? I will just jump right into the new DOTS networking! It is alright that there isn't a lot of documentation and packages are still raw. I will manage somehow".

With that decision made, I:
And even with all that in place I have miserably failed to reproduce the simplest NetCube sample project while following the official tutorial. "Why, oh why doesn't it work?!!! Why there are no error messages anywhere?!", I repeatedly asked myself while comparing my project with the sample one line by line using diff tools.

Long story short, the bug was that entities that were expected to be synchronized between clients and server were not displayed anywhere at all! And the reason turned out to be that I have not installed Hybrid Renderer package into my project as was requested at the very beginning of the NetCube tutorial. That was because when I started the tutorial I thought: "I'll go as simple as possible and concentrate on the networking. Why do I need all the fancy rendering stuff at all?". But who would have thought that this package was absolutely necessary?

Lessons learnt (or reinforced) today:
  1. If one is using someone else's materials and failing, then in 90% of cases the blame is on oneself.
  2. If everyone on the internet except you successfully finished a tutorial, then follow the tutorial more thoroughly.
  3. If tutorial says "Add the A, B, C, and D packages", then, please, add all of them as requested.
Last couple of days I was desperately struggling to reproduce this NetCube sample. I have done it at last. But have I wasted so much time on such a silly mistake. Don't be like me :). Learn on other's mistakes and follow my Unity Space Strategy project on GitHub.


Sunday, January 12, 2020

Now on GitHub!

Hello, everyone!

A few days ago I have published the source code of the SpaceStrategy on GitHub. Feel free to take a look and leave some comments!

I've published the code on GitHub mainly to sharpen my GitHub skills. But don't expect much as the code is pretty old, and now even I am terrified looking at some parts of it. But let's be positive and get some benefits from this situation! It is a great chance to practice some heavy code refactoring and restyling.

First of all, I have decided to bring a code formatting and style into an order:

  • newlines and spaces;
  • ordering of members;
  • naming and typos;
  • etc.

The solution being 130+ files with a style all over the place it is a tough task to accomplish by hand. So I decided to try out some tools.

At first I wanted to try out something new and selected the most recent and the most downloadable tool of the Visual Studio Marketplace for the task. It happened to be the CodeMaid. It was easy to configure and produced good formatting results. The "automatic cleanup on save" feature proved to be quite useful. But in the end, I wasn't able to configure automatic formatting to my liking. Personally, the most troubling was the formatting of properties.

Being a little bit disappointed, I turned back to the Resharper. It not only allowed me minutely configure almost every imaginable setting for automatic code formatting, but also provided a lot of features for manual code refactoring: spellchecking, quick-fixes, recommendations and more. It helped me to automate an enormous amount of tedious work, and I was able to cleanup my code in a matter of hours. Just take a look at recent commits in my SpaceStrategy repository on GitHub and see the results for yourself.

Stay tuned and I will try to provide some new exciting materials about programming my game.

Wednesday, August 28, 2019

Gameplay video

Hello there, dear Guest. SpaceStrategy development is in a stall, but I have prepared a short video featuring game mechanics. Please enjoy it for a time being. Any comments would be appreciated. Also I'm considering to publish source code on GitHub.