Oct 24, 2016

Lessons from Suzy Cube: The Camera System, Part 2

#suzycube #gamedev #indiedev #madewithunity 

Welcome to the second of three articles in a series examining the camera system used in Suzy Cube. This series dives into several aspects of the game’s camera system with each describing a particular set of features. These articles also follow the chronological order in which the features have been implemented into the camera system.

You can check them all out here:

In the first article, we looked at the basic setup for the camera rig used in Suzy Cube and went over its core functionality. In this article, we begin to look at those less obvious features which help the camera be more responsive, less intrusive and more helpful for the gameplay, overall.

Reacting to Jumping


Suzy Cube is a platforming game and, as such, involves a lot of jumping. In the previous article, I described the way the camera moves around to follow the player character, Suzy around the level. This is true, along the X and Z axes, parallel to the ground, but when jumping, some special rules come into play. So, why special rules only when along this one axis, wouldn’t simply keeping up with Suzy be good enough? For those who are curious, that would look something like this:

Side view diagram of the camera, parented to the blue diamond, following Suzy up and down perfectly as she jumps.

Yes, this would be serviceable, and was, indeed, how my first implementation worked. It was, unfortunately, prone to two problems: First, it made it hard to see where Suzy might land as the ground would often fall out of view of the camera during high jumps, and second, during short hops, it made the camera too jumpy and made things less pleasant to play as small hops translated into a lot of fast screen movement.

The solution was to intelligently focus the camera’s up and down motion not on Suzy herself, but relative to a point halfway between Suzy’s feet and the ground. In this example, that point is visualized as the green X.

Side view example of the camera following a point between Suzy and the ground.

The camera’s motion in this example is considerably less pronounced than that of Suzy. This less pronounced motion helps to minimize camera motion during small hops and keeps more of the ground in the frame during high jumps. As you can see in the example, however, as Suzy gets farther and farther from the ground, there runs a risk of her rising right out of frame, to keep this from happening, the average between Suzy and the ground is never allowed to be any farther than 3 m. below Suzy.

Camera Relative Controls


In a game like Suzy Cube, it’s common that the player character moves based on what are called, camera relative inputs. This means that a player’s inputs are compared to the angle of the camera so that pressing, say, right on the joystick will invariably cause the character to move toward the right of the screen even if the camera has been rotated a full 180 degrees around the character. Again, a system like this works great, it’s intuitive and common and takes virtually no time for players to get used to. The problem I encountered in Suzy Cube was that of trying to help players “keep to a line” if you will. In 3D platforming games in general, and even more so in a platforming game meant to be played on a touch screen, a frequent issue involves missing landing on small targets like enemies or platforms because of subtle, off axis movements. In order to greatly help reduce these issues, Suzy’s movements are artificially snapped to fewer direction rather than a full analogue circle of 360 degrees. This makes it much less likely that a player might find themselves accidentally running off the side of a narrow platform because they weren’t holding exactly forward on their joystick. With camera relative controls, though, this introduces a bit of a problem.

Say a player is holding right on their joystick but the camera is a at a slight angle, since the controls are relative to the angle of the camera, this means Suzy would actually be running, also, at a slight angle. So, to alleviate this problem, the controls in Suzy Cube aren’t actually relative to the camera’s angle but that of a child object whose rotation is snapped to 45 degree increments. 

The blue diamond represents the camera's parent object smoothly rotating and the arrow represents the snapped angle.

This set up means that even though the camera can be rotated to slight angles, the player’s controls will remain snapped to nice, grid aligned angles. Compare the results of a slightly rotated camera with and without the snapped relative controls.

Comparison of the effect of the camera's rotation on Suzy's running direction with and without snapping.

It’s easy to see that, without snapping the relative angle of the controls, Suzy risks running right off the side of this bridge of blocks. The combination of the snapped inputs and snapped relative controls makes Suzy Cube much more playable on all platforms but especially on a touch screens.

In the third and final article looking at the game’s camera system, we’ll be having a look at the latest additions to the camera’s behaviour which further help to show players more of what they need to see when it’s most important. So check back next week for the conclusion of our three part series.


No comments:

Post a Comment