Saturday, January 25, 2014

New Perspectives

Working on the game lobby.


Before I get started on this topic, I wanted to let everyone know that with the new year comes a new blog schedule!  Initially, we tried to do a post once a week and, well you saw how that worked out. We didn't really hold ourselves to it and it ended up being more like once a month instead. With the new year we've decided to change up how we're doing posts to hopefully keep us more on track! We're still going to strive for once a week, but Becca and I are going to alternate weeks. Neither of us are really used to logging our lives on the internet like this, so it's taken some getting used to, but we've been getting more used to it and I promise 2014 will be a better year! Now back to the original topic at hand, New Perspectives.


Developing Andrecca Adventures has been a real eye opener to me. I've started looking at games in ways that I didn't really before. Take lag for instance, as a gamer I was always aware of lag and the basics of what it is. I knew it was more than that thing I could blame more online misfortunes on, but I never really appreciate the art of how to handle that lag as a game developer. As a gamer, I guess I never really cared. I just wanted seamless gameplay with someone a thousand miles away from me. How it got done was irrelevant to me for the most part.

I call lag handling an art, because just like with programming in general, it can be done in so many different ways and some work great and some don't. It all comes down to your strategy on how to deliver the experience you want to. Just like a painter using certain, but subtle, brush strokes to draw your attention to where they want it drawn to. Or a composer adding the perfect supporting notes that change the whole tone of the music to give you the emotions they're looking for. Just like those things, if done right, you don't even notice lag compensation. You just know it works great and don't give it much thought as to why it works since you're too busy enjoying the game. If done wrong though, you can get the player notices. Countless times I've seen droves of players complain about lag. Whether it's just a momentary hiccup or a major issue, anything that limits a player's gameplay or downgrades it in any way, is noticed.

So when I set off to work on Andrecca Adventures, I knew that I wanted to include an online component, so I set off to do as much research as I could. I've heard that if you want online in your game, you should start development with online in mind. Taking it on later is usually a messy and labor intensive process and, as I'm sure many of you have encountered at one time or another, the online just feels tacked on. Not willing to risk that, I started off developing online. In fact, I haven't even tested local multiplayer yet! I quickly read through some guides to see how I could setup the networking. I was still pretty new to Unity (our game engine) as well, so a lot of what I read went way over my head at first. Eventually, I pieced it all together and figured out how to get it to work for Andrecca.  Everything worked great, aside from some specific gameplay mechanics, I was done! Well not quite.

While it was working in tests, it just wasn't going to pan out in the real world. Initially I was just going to use Unity's built in networking, where players would host the games themselves, not quite peer to peer as it was still server/client based, but for a variety of reasons Unity wasn't ideal. Plus I was testing my "working" networking between two computers on the same LAN, which meant almost zero lag. I wasn't naive enough to think that 100-200ms ping wasn't going to make a difference, but again, you don't realize how wrong things are until you see it first hand.

I didn't get to experience that latency until I implemented my current network solution, Photon Cloud. Cloud allowed me to test latency exactly as people in the real world will, as the connection has to go through the cloud before coming back to the other computer on my LAN. Another perk of this is that I could test higher ping by using the cloud based in Asia or Europe. This gave me TONs of insight! Now I could see how the low, normal and especially higher latency plagued my setup with lag for actions.

Actions in Andrecca are very dependent on timing, as a core component of it is pushing around enemies and players by sliding tiles. With movement delays (from latency and to smooth out input received by packets - another fun thing I learned about in this journey) and normal latency for actions, it was very difficult to hit anyone that wasn't standing still. This lead me to read many many documents and watch videos on lag compensation. It's gotten to the point where I feel like I could give you an overview on how to setup lag compensation on your FPS. I learned to appreciate the art behind it. A lagless game is really an illusion you can give and no something you can ever achieve. Much like how a painting can always seem like it's looking at you regardless of where you're standing. Until we invent time travel, there will always be delays in communications, whether they're big or small. So until there's time machines to give us simultaneous gameplay or magic ink to make eyes move, you need to master the art of creating that illusion.

I learned many strategies to give that illusion, but so much of the material was on FPS's. Don't get me wrong, I got so much out of learning about how the FPS online genre is handled, it really opened my eyes, but it took a while for me to realize how to relate these concepts to Andrecca. After all, we're not creating an FPS, so tricks like hiding lag off screen, just didn't apply, everything is always on the screen for everyone to see. The lag has to be handled though, and thankfully the materials I read and watched gave me the tools and inspiration to do that. I won't go into details of how it works in Andrecca, but I found there are basically two ways to deal with lag, hide it or leave it showing. You have to find that perfect mixture to stay below the radar of what the player notices and tolerates.  I've learned (and am still learning) the different things that players will tolerate or not even notice, so far it seems like a tricky game of misdirection.

With all this said, I've gone through quite a few different iterations of networking and I'm sure I'm going to have to go through more.  For now though, I've found the one that works best, so far.  It's definitely not perfect, nor am I even sure perfection can be attained at all, but I'm proud of what I've been able to put together.  I'm shooting to have an open beta, to test the networking further, sometime in March.  I'm very eager to see how Photon Cloud will pan out.  I think that it's a great service where dedicated/self-hosted servers are not needed, but I am going to keep an eye on the ping level that goes with that since less variety of servers means the server could potentially be farther away.  Results have been promising so far though!

No comments:

Post a Comment