Week 7 – Networking

This week, I started work on networking within Unity. At the recommendation of my adviser, I used Photon Unity Networking (PUN) to achieve a networked connection across game instances. This week is fairly light reading, as I don’t have a whole lot to show, but I think I’ve made decent progress nonetheless.

This process of getting networking to work in a basic form was straightforward, as Photon has a good official tutorial. I had two characters instantiated in the game world in just a couple of hours. Of course, there was nothing to determine which player could move which pieces, so I had to work on that. This proved harder than expected – at first, I made it so only the owner player could move their piece – but what happens when the DM needs to move it for them? Then I made it so the DM could move anyone’s character… but this caused a pretty major desynchronization where a player wouldn’t see their piece move unless they moved it.

I thought that would be an easy fix at first – I made it so that ,when the DM would try to move any piece that wasn’t their own, ownership would be transferred to them for the duration of the drag, and then when the user releases their finger, ownership would be transferred back to the original owner. This took a while to fix, and seemed pretty important, but eventually I got it to a more consistent point, shown below.

Only the left screen is actually the DM.

As it is, if you’re not careful, the players can still be desynchronized, but at this point I believe that is an issue with my touch management that I will have to fix later.

Somewhere in here I ran into a fun little issue where, if I closed the game without pressing “leave game” first, the Unity Editor would crash, and then get stuck in a crash loop where it would crash when I opened the project – that was a mess and a half, but the fix ultimately just wound up being to try and snipe another scene into the editor before Unity could load the lobby scene, but I was worried I was going to have to nuke the project and redo my setup for a while and wound up not having to – so that’s a happy ending, I guess?

I’ve also added functionality for a player occupying a tile to count as rough terrain – this was nothing huge for a single user, but in multiplayer took a little bit of extra learning. Thankfully, the solution was also straightforward for that – Photon’s RPC calls are easy enough to use.

Overall, I didn’t make a whole lot of tangible progress this week, but I feel like I made significant strides in understanding Photon and networking, and hopefully I’ll be able to springboard off of this week into a lot of meaningful work.

Leave a Reply

Your email address will not be published. Required fields are marked *

Theme: Overlay by Kaira
Ann Arbor, MI