Monday, February 3, 2014

Prototyping Odds and Ends

Over the past week, we've been deciding what last-minute features we really want to make sure get into SunBots and get incorporated into the entire scope of our gameplay. We're looking into new mechanics that can add depth to our gameplay and level design without drastically increasing the scope of our project. We've also begun testing our game in the QA labs, and have tester feedback to begin responding to as well.

With both these general goals in mind, I did two main things. First off, I built a prototype for a system suggested by designer Remy Vogler. He suggested that planets do more than simply generate energy if charged; instead, he felt their gravity should increase proportional to how charged they were, giving an extra layer of dynamism to the gameplay. Making a proof of concept for this was not too difficult; our code architecture is set up quite well, making it easy to change one or two things without upending everything else. In this case, I wrote some extra functionality for the planet's energy generator script that fired a message to the gravity script telling it to change its base gravity value when the energy value hit certain thresholds. We've already begun using this feature in a new level, albeit in reverse (more energy = less gravity), since the gravity values at different thresholds are all customizable in editor, allowing for positive, unintended functionality.

QA feedback was generally positive, as is often the case with a game featuring a unique mechanic such as ours; since most of our players are first-timers, the uniqueness of the concept carries the experience. However, it was generally observed that players had a hard time knowing when they ran out of energy to shoot, or even that they could run out. We currently have a GUI with an energy bar graphic representing how much a player has in reserve, but it's up in the corner of the screen, and easy to miss if you don't know to look for it. To solve this we looked to Mario for inspiration. In recent games, certain collectibles turn into white dots that zoom into their respective GUI element to show the player the connection between their on-screen actions and the important stats they change. A good example would be the Star Bits from the Galaxy games, or the reserve power-ups in 3D World. 

I made a prototype to do the same thing for energy in our game. The biggest challenge was setting up their path. I wanted to create a white object with a trail renderer to approximate the Mario effect, meaning this needed to be a gameObject that moved in world space. However, its target was the upper left corner of the screen, meaning I would have to translate between screen space and world space. Unity thankfully has some built in calculations to help smooth out this process, but when you add in the complication of the camera moving during this object's lifetime (changing the world-space position of the object's goal) and you can get some inconsistent behavior. Right now the system works generally as intended, although the paths have some small variance depending on how much the player moves during the lifetime of the object. If testers respond positively to the prototype I'll sit down and figure out a solution to the camera translation problem, but it could prove exceptionally tricky, since I don't think there's a painless way to 'convert' a gameObject into a GUI object. If this system is kept and iterated on I'll post an update.

Monday, January 27, 2014

The challenges of tablet

Last week we removed our most complicated input system and successfully got something playable onto tablet. However, we've spent an entire semester with PC as our target platform; it stands to reason that we'll run into more hurdles as we further explore our new platform. This week's challenge was managing our newly restricted resources. On tablet, you have both less memory and less processing power than on PC, which means you get frame-rate slowdown with a lot less going on. However, on the tablet build some of our levels began to noticeably chug after a few minutes of play.

I looked at the offending scenes using Unity's profiler and found out the problem was with all of our energy units. Currently, planets will produce energy pellets at a set rate if charged, and will produce them indefinitely while charged. Although we had never ran into issues before, it stands to reason that a system forever increasing in complexity will eventually hit a ceiling; we had simply been lucky enough to avoid it on PC. So, I spent the week looking into ways to make this energy generation take fewer resources.

The obvious solution (well, second most obvious, but we'll get into that in a moment) was to disable the rigidbody physics on energy that didn't need it. Our energy pellets have rigidbodies attached because they use physics forces to move when fired, and are affected by gravity, another physics force. However, when an energy pellet is sitting on the surface, it doesn't need physics to affect it until it leaves the surface. Disabling the rigidbody while energy was on the surface seemed a simple solution.

However, this caused a few complications. First off, rigidbodies can't be directly disabled, unlike most other Unity components. To another man this might have seemed a pertinent warning, but I plowed on ahead. Rigidbodies could be removed entirely using the RemoveComponent command. Although it might make re-adding a challenge, this would at least work for a baseline test.

Something funny happened with this test, though. Under normal conditions, we found that on the PC it took about 600 energy pellets in our test scene to get slowdown. Once we started removing rigidbodies, however, that number plummeted to 200. I'm still not sure why removing the calculations Unity has to perform on an object made it significantly less efficient; perhaps there was some code somewhere else referencing a now non-existent rigidbody in a way that didn't throw an exception but still messed things up, or perhaps Unity optimizes rigidbodies very well already behind the scenes. Regardless, it seemed like this was not going to be a fruitful avenue of research.

Thankfully, not every technical problem needs a technical solution. We already had a function written that prevented charged planets from producing more energy if they had a certain amount already on their surface. By using this on every planet, we could set a hard cap of the amount of energy allowed in any given level. By setting this cap lower than the amount that caused problems, we could prevent those problems entirely. So, that's exactly what we did. Another victory for simple solutions.

Friday, January 17, 2014

New Control Scheme Adventures

One of the biggest problems SunBots had at the end of last semester was its control scheme. The game used a dual stick setup, with the left stick controlling movement and the right aiming energy shots. Although our primary testers (~20 year old gamers) largely found this setup intuitive, we got significantly different feedback from the professors who played our game during greenlight deliberations, who generally found the setup a bit unwieldy. A dual stick setup requires a very high level of hand-eye coordination, which clashes conceptually with the rest of SunBots, which is generally casual-friendly.

Additionally, our game very strongly gives off a tablet vibe, due to its colorful aesthetic and simple concept. However, our movement alone made our controls too complex to work on tablet. On a planet, the player can only move one of two directions, clockwise or counterclockwise. However, simplifying this to a binary input is problematic. Left, right, up, and down mean different things depending on where on the planet the player is. On the north pole right is clockwise and left counter, but the opposite are true on the south pole. This led to us creating a sophisticated series of checks to properly translate the left analog input to what makes sense based on the player's general position, taking 8 different possibilities and condensing them into the two real outputs.

Since tablets don't have any buttons or tactile feedback, their range of input is limited. You only have so many discrete actions possible before they begin to blend into one another. Taking our complicated movement system and porting it to tablet would leave us with a mediocre product. So, we simplified, and cut direct movement entirely. Movement on planets wasn't ever a core part of our game; it was more a means to an end, the end being solar system movement. Now, the player has a constant velocity when on a planet's surface. They can press a single button (an easy input to port to tablet, once we begin seriously building tablet controls) to swap directions. This system works great; it never feels like you aren't in control, since the important control takes place in space. It just goes to show the power of simplification and outside the box solutions.

Sunday, January 12, 2014

SunBots Second Semester Funtimes

It's been a very exciting development process so far for SunBots. Ever since settling on a concept we've been off to the races, and it's somewhat amazing how solid of a product we have after only 3 months and 4 people. But now it's time to really get going; we've double in size and with an extra 4 months, SunBots could be amazing. We've already got some cool ideas about how to expand on our premise from our new members. I don't want to talk about them now since we don't know what we'll pursue and what we won't, but suffice to say we're going to be doing a lot of cool new things.

Since we've just started our second phase of development, there's not much to talk about so far; we're still figuring out what we want to do and who will be responsible for what. We've been doing some housekeeping; cleaning up code, cleaning up our repository, basically making things easy for newcomers to get into and work with. Expect some fun updates next week. I'm very confidant we'll have lots of cool updates.

Monday, December 9, 2013

Final reflection

            Wow. This semester’s been quite the journey. I’ve spent so much time and energy working on Sunbots it’s easy to forget it’s only been about 3 months since the game’s inception, and that for the first 3 weeks it wasn’t even clear Sunbots would be our game. But through this whole process I feel like I’ve learned quite a bit about the process of game development, what makes ideas successful (or not successful) and much more.

            When our team first formed in late April, we had a couple meetings to try and brainstorm ideas for our upcoming Senior Capstone project. Unfortunately, we were in the final stretches of work on our Production II games, in addition to high end-of-semester workloads in our other classes, and were thus unable to come up with any ideas whatsoever. This was to be expected, and wasn’t particularly concerning; after all, we had months before the class even began; surely we could come up with something good during that time.

            We proceeded to hold several Skype meetings over the summer, and we had plenty of ideas then. Unfortunately, almost all of them were terrible. We seemingly had the opposite problem from April; with so much time, our ideas were overthought. They were all too cute high concept pieces that sought to say something important about the human condition or redefine what games could accomplish artistically or some other lofty goal, but no attention was paid to the basics of play. These ideas focused on interesting environments, or narrative settings, but a game needs to be fun to play, first and foremost.

An argument can be made that a game does not necessarily have to be fun, but simply engaging, and examples of such certainly exist in the wild (Spec Ops: The Line, Every Day the Same Dream, etc.). However, pulling off something like that takes a lot of skill, and requires an especially strong artistic vision. Quite frankly, I don’t think a team as relatively inexperienced as us would be able to pull it off. We can learn vicariously here; two years ago, a senior team produced The Return, a game which is often derided amongst the game cohort for being thematically overblown and mechanically unsatisfying; the Flash game Don’t Look Back delivered on many of The Return’s goals much more strongly, with a release several years before The Return. However, a team comprised largely of the same members made the puzzle game Loc during the same timeframe. Loc is based in interesting and engaging puzzle mechanics first and foremost, and although it has a (largely unnecessary) narrative component, by focusing on the mechanical play Loc delivered a very engaging experience, significantly more so than The Return.

With an acute awareness that our concepts were more The Return than Loc and with summer swiftly drawing to a close, we staged a brainstorm session with specific restrictions. Each idea presented must be mechanically based, and if the idea was agreed to be strong it must be possible to create a prototype within a week demonstrating the core mechanic. The ideas that came from this process were much stronger. Of particular note was an on-rails platformer idea with a focus on “shifting”. This idea went through several iterations even before the semester began: it was fun, simple, but with great potential for expansion. It seemed for a few weeks that this would be our team’s game.

 However, the rail prototype had one main failing; rail platformers are HUGE right now, and it was hard to find a point of differentiation. Our game was engaging, sure, but it wasn’t particularly memorable. We’d avoided the trap of being pretentious, but being bland is similarly disastrous. I feel that if we had stuck with the rail idea we might have been able to come up with an interesting twist at some point; looking at VXT, that game has some similarities to the red-blue shifting prototype we made, and it’s not hard to imagine a parallel universe where that game evolved from our prototype.  But we at least weren’t feeling the creative spark with that idea, and we might have been doomed to mediocrity without a savior.

The game that would eventually become Sunbots did not have a very auspicious start. During the first week of the semester, Melissa had a vision for a game where a robot jumped between planets in space, with fully realistic gravity affecting their movement. She began prototyping, and the initial iterations were none too promising. They were in full 3D, mirroring actual planetary systems as one might expect, but actually navigating this space was incredibly difficult and confusing. It was hard to tell where planets were in relation to one another, how fast and in what direction the player was moving when they were jumping, and the prototype was generally not all that fun. But it was unique, and as the rail prototype’s derivative nature became more and more apparent with each passing week, we were desperate for another route.

So, we decided to try a radical alteration of the planet prototype to see if the idea was in any way workable. Mainly, we decided to shift the game from 3D to 2D. This severely limited the player’s movement options, and could have left the concept stale and uninteresting. But it was instead exactly what we needed. The removed dimension took our camera problems with it, as the singular plane of play meant we always knew the optimal viewing angle for the player. With our camera problem solved, we could easily show the players their movement relative to other planets since we could keep many planets in view at a time.

It’s not like this one change magically created Sunbots, or even solved all of the prototype’s main flaws (the controls in particular would take another week or two in order to be presentable) but its importance cannot be overstated. After the shift to 2D, it became significantly easier to see where the game could go in the future, and to be assured that it could be realized. Without the shift, we could not feel assured that our concept did not have inherent fatal flaws.

            Ultimately I think it’s fitting that our best idea had such an unassuming origin. It wasn’t the product of a specialized brainstorming session or some carefully honed high concept. Melissa had a vague idea of something that sounded like it might be fun, but it took a lot of iteration to get into an enjoyable shape. I think that iterative process is key to what made Sunbots work so well, especially when contrasted with our other ideas. Because we had no preconceived notions about how this was supposed to work, we were able to go wherever made the most sense in the moment, creating a stronger end product.

            As Sunbots came together, we began targeting two different demographics, as mentioned many times throughout the various presentations and stage challenges we’ve made over the semester: the young, and the young at heart. This is most clearly demonstrated via our art style, which is colorful, cute, and playful. Over the course of the semester our team’s received a lot of great positive feedback from testers and colleagues, and we were ultimately rewarded with a green-light for second semester. Clearly we were doing something right, and I believe our aesthetic direction is a key contributing factor. There were a lot of strong candidates this year, with many potentially good games getting cut in the interest of logistics. Any game wishing to avoid this fate needed to stand out, and visually nothing quite looks like Sunbots, especially amongst our peers. The game is like a storybook come to life; to my knowledge, only Kirby’s Epic Yarn has a similar aesthetic.

            However, this visual style has also caused complications. Sunbots has moderately complex controls, utilizing both analog sticks and all four shoulder buttons. Although it can be played with mouse and keyboard, it’s a game that’s been designed with a gamepad in mind. During QA testing, this control scheme has met with near universal positive feedback. Players required a few minutes of unstructured messing around to get the hang of things, but once they did they were lost in the game, controls no longer being a barrier.

            But our QA testing was limited in a way we didn’t quite realize until late into the semester; namely, every last one of our testers was a college student, age 18-22, with an interest in video games large enough that they’ve elected to spend $40,000 a year in order to learn how to make them. These are people steeped in the language of gaming, with entrenched muscle memory. They understand how a dual-stick game works; using the left stick to move the avatar and the right to aim shots makes complete sense to them.

This built up gaming knowledge sometimes colored the feedback we would receive. For instance, when I first built the gamepad controls for Sunbots, I assigned jumping to the A button. This is the default in gaming, especially for games related to platformers. Pressing A to jump is like understanding that a cut in film doesn’t break the continuity of a scene, a skill internalized to such a degree that it can be hard to imagine the medium without it.

Of course, this only applies to gamers who play on consoles; PC players do not internalize this. Therefore, we would occasionally get a tester with minimal console experience who found our jump controls lacking; namely, you use your thumb to reach the A button but both thumbs are often occupied by the analog sticks. These players would generally recommend the jump command be remapped to one of the shoulder buttons, which are accessed with your index finger. Their critiques made sense, and so we altered our controls, remapping jump to RB. We removed all mention of the A button being the jump command, and put the game in front of new testers.

They generally liked it, but more than a few felt the jump controls were counter-intuitive, and requested they be mapped to A. Even though there was no real difference between the two inputs in terms of how they impacted play, and even though RB was more easily accessible during play, pressing A to jump was so ingrained in players that they wanted to do it anyway. We found a very easy compromise in this situation, mapping jump to both buttons so that either preference was accounted for.

However, we also encountered another issue, one which we still have yet to fully resolve. During the green-light demo night, our game was played by the EGD and COR faculty responsible for determining what games would go forward. These players fell into a completely different demographic than the ones we got through the QA lab. They weren’t hyper coordinated 20-somethings, and some of the COR faculty had limited familiarity with gamepads in general. They found our game significantly harder than we had intended, and had difficulty understanding the controls.

Well, so what? We were still green-lit, and we could simply argue that a lack of familiarity with gaming conventions puts one outside of our target demographic, removing the need to cater to people who don’t understand how to use two analog sticks simultaneously. However, our aesthetics told a different story. They were inviting, accessible, and told people that this game was for everyone. In fact, we’ve been told many times that, because of our artistic style, we should really consider a mobile release, possible even making it our target platform.

The idea that brightly colored, up-beat games belong on tablets is fairly powerful right now. With dark, gritty games like Call of Duty and Grand Theft Auto breaking sales records on consoles, it can feel like only those types of games belong on a gamepad. For years, people have been calling for Nintendo to release their stable of brightly colored, friendly looking games on mobile devices. Noted games industry analyst Michael Pachter has gone as far as to call for Nintendo president Satoru Iwata to be fired for not porting Nintendo content to tablets (Peterson).

But let’s look beyond the impressive stats of Angry Birds and Candy Crush Saga. There is in fact a very good reason why you won’t find Mario games on iPhone, even ignoring that Nintendo owns the competing 3DS. Tablets are a very limiting platform for game development, and it has everything to do with controls. There’s only so much you can do by poking and swiping at a screen, and secondary input methods (such as gyroscopes) are often too imprecise to use in a game which requires precision, which is sometimes true of Sunbots. So far, no one’s been able to make a traditional platforming game with a traditional range of motion work on mobile. Sure, there have been great successes when the genre’s been reinterpreted (Temple Run, Rayman Jungle Run) but a game where you can go in any direction and jump at will has so far not materialized. Ports of games like Sonic the Hedgehog exist, but work quite poorly, since they utilize a virtual controller, which simply doesn’t work without tactile feedback. Since Nintendo games tend to require precise input, their games belong on traditional platforms, with analog sticks and physical buttons galore.

I feel the same way about Sunbots. There’s a lot of pressure for us to think about mobile, even from within the team, but I’m ultimately hesitant to pursue that platform. Although our game certainly has a “mobile” look, what makes our gameplay fun and unique is our movement system. Figuring out how to manipulate the gravity of all the planets in a system in order to travel is a hard but rewarding process; with an imprecise mobile control scheme this would be lost. Even games specifically made for mobile, such as Angry Birds, can suffer greatly (or even be crippled outright) by the imprecise nature of poking and swiping as input. Try making the same exact shot twice in a row in Angry Birds and you’ll see exactly what I mean.

Making Sunbots has been a great learning experience for me. I’ve learned what makes ideas good and not-so-good, although the greatest lesson there was that you sometimes can’t get the complete picture without a little digging. I’ve learned the importance of aesthetics, and how they can sell your game, and sometimes even sell a different game entirely. I’ve even learned a little about myself; during the course of this project I’ve really enjoyed the work I’ve done as a makeshift second programmer. I like the problem-solving aspects of that job; you have a specific goal in mind, and you work to accomplish it. In contrast, I haven’t enjoyed the design work nearly as much, since it can so often be a game of guess and check, where you don’t know if you’ve done something right until you get a bunch of other people to play it and gauge their reactions. This is reflected in our team composition moving forward; we acquired two new designers but no new programmers, sine I’ll be transitioning to full-time programming work next semester. I’m very happy with what we’ve accomplished so far, and I can’t wait to see what we’ll accomplish in the future.

Works Cited
Peterson, Steve. "Pachter: "I Don't Know Why Iwata Is Still Employed" Gamesindustry.biz.

GamesIndustry International, 05 Dec. 2013. Web. 09 Dec. 2013.

Wednesday, December 4, 2013

AI demonstration

I chose to research obstacle avoidance steering. This technique is basically what it sounds like: it involves steering a moving object such that it will never collide with obstacles. We do this via the use of raycasting. The moving object casts the rays; one straight forward, on angled above, and one angled below. If none of these return a collision, than it’s business as usual. However, if a ray returns a collision, the player moves parallel to the collision point’s normal, away from the obstacle.

Fig 1: The bottom ray has returned a collision. The green line is the normal to the collision point, and the gray line is the parallel the player will travel along.


However, this wasn’t quite enough to achieve the desired effect. When the AI unit isn’t avoiding obstacles, it’s moving towards a goal on a linear path. Therefore, if the AI encountered an obstacle it was because said obstacle was in between the AI and its target. What this lead to was a stuttering effect; one frame, the AI would detect a collision and steer to avoid it. Now the AI wasn’t facing the obstacle anymore, so next frame it would turn to face its target. But since it’s only moved one frame’s worth of distance, it would be right back to facing the obstacle, repeating the process. Since it got that frame of movement in the AI eventually made its way around the obstacle, but it was an ugly process.
            To circumvent this, I implemented a buffer for defaulting to target seeking. Before switching to the target seek steering, the AI would raycast in that direction, with the same spread as a normal cast. If the raycast returned a hit, the AI kept on its avoid steering, but if it returned nothing, the AI switched back to target seek steering. This cast was a little longer than the obstacle detection cast, since otherwise the AI got out of range prematurely and would stutter similar to how it would stutter without the check at all.
Fig 2: The player is avoiding the blue planet.  Although the obstacle detection (red rays) is giving the all clear, the buffer (blue rays) is telling the player that a switch would be premature. Therefore the player will keep avoiding the obstacle until they have fully cleared it.



            Over the course of my research I used 3 main sources. I first looked at an article by Craig W. Reynolds of Sony Computer Entertainment America discussing various AI behaviors (found here http://www.red3d.com/cwr/steer/gdc99/). Of particular interest was his section on obstacle avoidance steering. He discussed the common method of avoiding obstacles based on bounding spheres, as well as the general theory of only caring about objects in the AI’s movement path, and only caring about the closest object at that.
            From there, I found a forum discussion on gamedev.net (http://www.gamedev.net/topic/632735-help-with-obstacle-avoidance-behavior/) that brought up the alternate method of raycasting. The users “slicer4ever” and “IADaveMark” discussed the benefits of bounding spheres vs. raycasting. Although I intended to demonstrate this technique using spherical obstacles regardless of my approach, I decided to use raycasting since it was the more general solution, working for any convex shape. Finally, I found a great starting point for my work using the pseudo-code found in “Artificial Intelligence for Games” by Ian Millington and John Funge.

            This technique has uses for many action-based games, since it solves a very common problem. Many games require AI to successfully navigate around obstacles, and if said obstacles are constantly moving or being dynamically created or destroyed, A* pathfinding becomes wildly impractical. This technique relies on raycasting, an expensive process, meaning that it is unsuited for platforms with constrained processing time, such as mobile.   

Thursday, October 24, 2013

Lessons learned from Cookie Clicker

Earlier this year, the browser game Cookie Clicker swept the internet. It's an absurdly simple game: you click a giant cookie to get cookies, and then spend those cookies to get more cookies via upgrades. You quickly reach an absurd number of cookies, but there is by design no grander goal. Your entire purpose is to make more cookies. This is a game that sounds monumentally stupid on paper, almost like a parody. And yet, it's been a huge legitimate success. Many people play it and derive enjoyment from doing so, despite (or more likely because of) how silly it is. It's easy to simply write this game off as a novelty or a fluke, something that gained popularity simply through audacity that cannot be replicated.

However, if you look beneath the surface there's actually something here worth studying. At its heart, Cookie Clicker is a game about resource management. Your goal is to maximize your production of cookies, but you can spend cookies now to make more cookies in the future, and you can choose whether to spend them quickly on cheap items, or save them for something that will have a greater effect. Lots of games feature more complex versions of this same interaction, usually involving an additional variable, such as damage (do I spend 100 sun for a peashooter now, or save 200 for a repeater later?) or some other consideration (do I use star power to survive the tricky solo or on an easier section I know I can keep a good score multiplier through?).

This basic idea has applications for Sunbots. Currently, our game features only one resource: sun energy. You collect sun energy from planets, and use it to expand the sun and fight its decay (avoiding one of our game's lose states and achieving its win state) but also use it to more easily maneuver your character. A more recent feature involves using it on the planets as well, charging them to allow them to produce more energy over time. This is where Cookie Clicker comes in. Where Cookie Clicker first gets fun is the first moment you produce an 'absurd' amount of cookies. Where this point lays is different for everyone, but around 1,000,000 is a good benchmark. Progress in Cookie Clicker starts out very slowly; one cookie per click, no automatic production. Your first improvement (for your average first-time player, anyway) will be a cursor, which produces 0.1 cookies per second. From this slow production, you can build up auto-clickers, getting your automated production up to the point where you no loner have to obsessively click yourself, before you reach critical mass and revel in how many cookies you are now producing. From humble beginnings, you have wealth, an embarrassment of cookies. This is the fundamental emotional underpinning of the Cookie Clicker experience, the feeling of going from rags to riches entirely through one's own work.

This is what can be applied, not just to Sunbots, but any game about maximizing and managing resources. Starting small, making growth start slowly, but increase faster over time until you have more resources than you know what to do with; this is the core of an inherently enjoyable resource system. Cookie Clicker exemplifies it so well because it consists of the entirety of gameplay. It is a distillation of a common design element, all the more potent for the lack of filler. By looking at the fun in Cookie Clicker, we can apply a similar mentality to our burgeoning resource system. In general, all games can benefit from knowing what their individual elements contribute in a vacuum and how they best work on their own, so they might also know why and for what purpose they might be utilizing said elements.