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.


No comments:

Post a Comment