How I Started My Multiplayer Journey


THE WHY?

I've been developing using Unity for almost 5 years and the thing I fear the most is multiplayer networking. I tried using UNet back when I was still studying and there was not enough documentation or resources to answer my questions so I gave up. But for the life of me I am always curious about multiplayer mechanics. Since Covid happened and I spend most of my time working from home I decided to fill up my free time to face my fear. Upon using the power of the internet I stumble across a powerful SDK called Photon Engine. It is free for 20 concurrent users. In my opinion it is more than enough to test it out. But where do I even start? I had some assets I bought from Synty Studios a while back so I decided to use it for this purpose. 

THE BEGINNING

In the beginning, it was merely just figuring out how to create a lobby, a room and joining that room, was it easy? It was very confusing at first, but after countless revisits on the tutorial I followed on Udemy by Tevfik Ufuk, I got the hang of it. Naturally it was to test out seeing other players. Of course I was just using a capsule, super excited to see that I'm able to see the other players, then some animations was added. Photon made it easy to make sure all the movements are synchronized throughout the network. And that was it, I now know how to create an online multiplayer experience. Or so I thought. 

NFTs and METAVERSE

I was curious about the NFT scene and decided to keep an open eye on some projects. Most of the projects I am interested in had a roadmap where they planned to make a game/metaverse of their own project. A light bulb appeared on the top of my head. Why don't I create a simple world for these projects where they can have all their collectors hang out in a world of their own? So I made some fan-made concepts that I shared on Twitter that got the attention of some creators. They are interested for me to create a multiplayer experience for their project. I was super excited. 

One project is called Metaforest, it's build for WebGL and it took me about 2 months to develop the Pre-Alpha Stage. At this stage I was still learning the ropes of multiplayer networking and sadly the creator decided to stop the development. The second project I get to work on is Another Dimension, which took me 6 months to develop, previously it was playable on WebGL but the more I progress the more I realize some limitation on WebGL that I had to convert this game into a desktop version. Between these two games, you can see the difference in my progress as I learn. Note:  Both games are free to play.

THE PROBLEMS

The problems I am about to explain is just the gist of it but here we go. On the early setup for creating and joining a room was quite forgiving, and I kind of got the hang of it. It was only when I wanted to interact with object  is when I stumble a certain problem which it only shows only on the players view and not on other clients. That is when I learn about Remote Procedure Calls or RPCs. After countless frustrations I managed to solve it. In the beginning it was  only for picking up objects using Raycast.  (Developer NotesWhen using Photon, keep in mind that Photon View and Photon Transform View are your bestfriend.) Then comes the question what if I wanted the location to be random for each player, so I came up with a system that detects the possible locations that an object can appear and populate those areas randomly. In this demo there are 50 different locations. Crazy! Then there is the issue with timers and game mode which was solved using CustomRoomProperties. The hardest part was creating PVP mechanics. It was hard to synchronize players kill and death counters as well as the damage taken, especially when other players join in later in the game. It was solved using CustomPlayerProperties. When I started the PVP I realized that the current animation I had was not enough, I needed animation that I can simply and quickly adjust. Thanks to Unity's Animation Rigging, it made the process easier. I owe a lot to TheKiwiCoder for making awesome tutorials on his channel. He made really easy to understand on developing your own Third Person Shooter.

REMOTE CONFIG and GAME LAUNCHERS

Something I experienced almost on every project is tiny updates that you had to adjust on your Editor and rebuild for your clients. For Another Dimension I decided it was also time for me to learn how to update the game remotely. Unity had a solution called Remote Config which in theory is excellent for minor tweak in the values in these games that I made. But for some reason I never managed to connect to their services. So I learned how to call and API that holds data for these values that I or the moderator can simply change if it was necessary. Some of the data that I can control remotely are the weapon damage, the amount of items to pickup, what level to be opened and even some messages from the creator that I included in the game. For bigger updates, launchers are what you need. I followed a tutorial by Tom Weiland on how to create a game launcher and it made it a breeze for me to update the game for other players. Anytime there is a major update all I had to do is upload the latest build on my drive and players opening the game will get the latest update. Super!

THE OUTCOME

Throughout the experience I gained from the projects I managed to work on other multiplayer projects and mechanics at the company I am working with. I decided to create The Extension to further push my understanding and experimenting on multiplayer mechanics. I am treating this demo as my own personal sandbox. Why is it on WebGL you asked? I am planning to integrate this demo with blockchain in the future and  I see that WebGL has its own unique roadblocks that I want to understand how to solve.  As of me writing this, I am using the assets from one of the project I worked on. The difference being is that it is a much simpler and tone down version of how I would like it to be. Keep in mind I am doing this all by myself on my free time which is only at night up to 2.00 or 3.00am almost daily, and the only guidance I have to develop these experiences is by searching the right questions on Google or stumbling a similar solution elsewhere. I admit it is not perfect, but I am happy with what I have achieved so far. To any developers out there that could give me pointers, feel free to reach out. I would love to connect and talk more about multiplayer projects.

Play The Extension

Leave a comment

Log in with itch.io to leave a comment.