Developing with Unity

Week 1 (up to 31st May)

Pipeline

Divided repository into preproduction and production
Divided production into assets and game source
Game source is the Unity project containing our exported assets, scripts, etc.
Game source assets are divided into:

The project hierarchy is divided into:

Characters: Cow, Pig, Policeman, Aristocrat
Scenes divided into:

Scripting

Created a basic controller for the player and third-person camera
Created a development scene to test the controllers: grid of cubes and a directional light

Issues

Week 2 (commencing 1st June)

Assets

Tested John's environment and Sophie's cow in the engine.
Added some better lighting to make things look nicer.

Controller Scripts

Used the example 3rd-person controller with my camera set-up. Doesn't work so well but allows for gravity, collisions, etc. - good for testing.

Later (2nd June) replaced with my own controller. This still relies on the built-in Character Controller class which means we're stuck with a vertical standing collision body, but at least we now have collisions and gravity working with my custom camera and controls scripts.

Issues

Week 3 (commencing 8th June)

Split Screen

Making a split screen turned out to be very easy, as will the addition of a map utilising the same technique. It is simply a case of creating two cameras and mapping them to the 0.0-0.5 and 0.5-1.0 regions (either in x or y).
Mapped controls for two players to the Axis system:

GUI and Boost

Added item to pick up and detection to the collision checking for objects of this type. Player boost is incremented on each collection.

Menu System

A simple menu system of buttons and text using the built in GUI library.
Probably need to look at skins and custom graphics and events. Looks to be very versatile. Will be able to do quite intereting menus.

Issues

Week 4 (commencing 15th June)

Camera & Controls

Cameras are now limited so that objects falling between the camera and player cause the camera to fall forward until the player is no longer occluded. Also an average position controller allows us to sample sound from an average of the two player cameras. A better solution would be to duplicate and transform all sound emitters so that we get a mix of sounds relevant to each camera.

Split screen now works both horizontally and vertically.

The UniWii plugin provides us with data from the Wii remotes which I have added as an override to the player controls. That is, the keyboard controls still work when no Wiimotes are active.

Map

Added a controller similar to a position constraint but where each channel can come from a different object. This is used to position the X and Z ordinates of the player token at Y=100 above the ground. The map is a view of such tokens hovering above the actual level. A representation can be added later and positioned underground. The camera is set not to clear its background and to draw on top of the existing renders (higher Depth value).

Gestures

Further to using the forces on the Wii remotes to control the animals we also need to use gestures. The simplest is the shake, where an axis is repeatedly taken over and under postive and negative respective thresholds. Each time a threshold is reached the shake counter is incremented. This allows us to reset the count when a player crashes and wait for a particular value before allowing them back on the track - our recovery gesture.

Rigging

Most of this week has been spent rigging the Cow hero so that we can get the animation tests out as soon as possible.

Menus

The menu system has been implemented with character and track selection as well as structure for options and a instant-play (randomised) feature.

Week 5 (commencing 22nd June)

AI

While the animations were being worked on, I set about developing an AI network to allow the cows to navigate their way around. Unity makes it very easy to develop tools and I have ended up thoroughly enjoying what I thought might be a tedious aspect of the development process.

Camera Track

Another tool I have developed is a camera path and constraint. This allows us to create fly-bys and pre- and post-race sequences. Adding an OnPathEndReached event means that other events can be triggered and the game tied together.

Pipeline

We had some issues with the rig and how XSI performs its IK calculations by default. It meant that our rig was drifting so that it could no longer be reset. Having discovered an alternative IK calculation mode, we are now using that, whilst also splitting the three-bone leg chains into two parts. Three-bone chains are not good!

Once this was fixed the animations already done had to be transferred across. I had this in mind while fixing the rig, and thus kept all controller and bone names. Also the relative transforms were kept the same so transfer was fairly straightforward.

Week 6 (commencing 29nd June)

AI

Improvements to the AI system. Asthetics: less clutter in the scene. Nodes now show just their influence radius and spread with a line locus. Blending: agents blend between the current and next node targets to give smoother transitions.

Added speed hints to the AI network to inform the agents as to whether they should slow down for a certain, more difficult, section (eg. through the barn in the farmyard) or to continue at full speed.

Animation

Exported all animations for the cow on the new rig in one fbx file. Seperated out the animation system as it was getting tangled in the controller script.

Sensor Bar

With a trip to Maplin I have built a sensor bar for about £5. Four ultrabright infra red LEDs, a battery box and some wire. Could probably have used a soldering iron but it works fine for now. Might have been good to include a switch too - doh!

Rigging

The aristocrat now has a rig. Upper body is FK lower is IK. Researched how to use both FK and IK in one chain and blend between.

Week 7 (commencing 6th July)

Rigging (...contd.)

After doing some animation atop the cow, Sophie requested that the rig have IK arms. Since I had already researched IK/FK blending, I added the necessary controls. While riding with his hands down, IK is used to hold onto the saddle. When boosting, FK is used to flail the arms.

Scripting

Just found yet another very nice feature of Unity's asset management. Not only does it expose all public fields in an easy to edit Inspector, it also allows you to add functions to the context menu. This I will use to drop items onto the terrain floor...

Looking for a way to simplify the physics calculations I decided we should use box colliders for the wall geometry. Unfortunately the geometry comes with a mesh collider so a script had to be written to replace all mesh colliders with box colliders. This was much easier than I anticipated.

UI

In-game boost bar, lap counter and timers, and final race score display added.

Week 8 (commencing 13th July)

User Interface Library

The GUI system in Unity is designed to work with the static Input class that comes with it. Unfortunately, the UniWii plugin doesn't interface with this class and instead requires constant polling. I have therefore had to develop a UI system of my own, which has ultimately made things more flexible.

The underlying system took just under a day to develop and gives us much more control over what we can display and even has a design-time tool for laying out components visually (WYSIWYG anyone?). Events are triggered by buttons and can be picked up by any component attached to the same object.

Each frame, the cursor position is updated. This position can come from three sources:

Similarly the buttons that are accepted as a click are tested (Wiimote A button, keyboard enter key, left mouse button, etc). If the position falls inside a button it is set to its "hovered" state, providing visual feedback. If a click is detected the button is set to its "pressed" state and an event is fired (events are also fired for other states).

Events can be picked up by any behaviour script on the same object by implementing one or more of the following methods:

During the drawing phase, the state determines which image to display and how to blend that image into the interface (faded, tinted, etc).

Optimisation

Whenever we have everything together in the engine and the frame rate drops, I have taken a quick sample to see what the main causes for the slow-down are.

Tuesday 7th July
Walls placed around track and in background
Full render 17.5 fps
Walls removed 21.9 fps 4.4 fps
Blocks removed 18.6 fps 1.1 fps
Structures removed 20.8 fps 3.3 fps
Terrain removed 86.6 fps 69.1 fps
Friday 17th July
Testing shadow maps and pixel lighting
Full render 16.3 fps
Terrain removed 19.1 fps 2.8 fps
Lighting removed 21.9 fps 5.6 fps
Shadows disabled 38.0 fps 21.7 fps
Characters removed 22.4 fps 6.1 fps

So at the moment we are just above the 30 fps target but will have to avoid the simulated shadows. To solve this we will paint the static shadows on to the terrain and project simple, blurred shadow masks for the animated characters.

The frame rate will continue to be monitored over the coming weeks as we begin to add the final assets.

Week 9 (commencing 20th July)

Week 10 (commencing 27th July)

Week 11 (commencing 3rd August)

Week 12 (commencing 10th August)

Week 13 (commencing 17th August)