Wednesday, December 22, 2010


I just played Paul Turbett's first PC game, via DOSBox. Pure Awesome. Paul is now Black Lab Games, and on the side we work together on other secret projects.

When I was much younger, I remember applying for a job at Silver Lightning Software (Paul's company at the time). Hah, I wonder if he still has my resume, or if it went straight into the bin! Funny how, almost two decades later, we end up working together.

Tuesday, December 21, 2010

More Ships.

These ships are all rendered within Unity3D using a toon style shader. No textures are used, just flat colours.

Monday, December 20, 2010

Awesome Cloud Game Library...

Built primarily for cloud games, PySoy offers an intuitive API for managing object behavior in 3D space.

<chortle> I'm pretty sure this sentence (from the main PySoy page) is a joke. Of course it is. Isn't it?

Friday, December 17, 2010


Unity3D Hex Grid.

How to snap world points to the closest hexagonal grid point, where a hexagonal grid point is the center of the hexagon. The Init(size) parameter is the length of one edge of the hexagon.

using UnityEngine;
using System.Collections;

public class HexGridSnap : MonoBehaviour {

static float size,h,r,b,a;

static void Init (float size) {
HexGridSnap.size = size;
h = Mathf.Sin(30*Mathf.Deg2Rad) * size;
r = Mathf.Cos(30*Mathf.Deg2Rad) * size;
b = size + 2 * h;
a = 2 * r;

static Vector3 Snap(Vector3 p) {
var u = p.x;
var v = p.z;
var x = u - u % a + r;
var y = v - v % b + ((x - r) / a % 1) * b / 2;
return new Vector3(x, p.y, y);


Unity3D - Configurable Vehicle Prefab.

Check it out here: The Vehicle Prefab, you will need the Unity3D web player installed as a browser plugin.

You can dynamically change transmission type, differential type, suspension parameters, and vehicle masses. Lot's of fun just in itself! :-)

Tuesday, December 14, 2010


I listed a car for sale on last night.

I've had 4 enquiries via SMS. 5 minutes of research later, I find they are all frauds. Hooray for google and it's knowledge of everything. It is a shame that one has to be a skeptic by default.

Tuesday, December 07, 2010

Unity3D WheelCollider and motorTorque.

So, you've created a car prefab using WheelCollider components, and now you can apply a motorTorque to make the whole thing move along.

But how do you calculate vehicles for the motorTorque which make the vehicle reflect reality?

Here are my current ideas on the best way to do this.

1. Create a "torque curve" for your engine. It should run from 0 - 7000 (which reflects your engine RPM) and the height should peak at the maximum power output (in Newton Metres) of the engine. . The below image shows a torque curve which peaks at around 450 newton metres and then sharply drops off near 6000 rpm, just like a real engine. Use an AnimationCurve for this.

2. Set up your masses. The car should weigh between 1000-3000 kg. Set this in the mass property of your rigidbody component. It is also very important to set the mass of your wheels (WheelCollider.mass) to something reasonable. Most car wheels weigh between 15-30 kilograms.

3. Create another AnimationCurve variable, which we will use for gear ratios. Gear 0 should be neutral, and gear -1 should be negative to enable a reverse gear. A typical(?) set of gear ratios are below. Add another float variable which is the "final drive ratio" and set it somewhere between 3 and 4.

4. Every frame, you need to calculate the RPM of the motor. To do this use this formula:
motorRPM = minRPM + (wheelRPM * finalDriveRatio * gearRatios.Evaluate(gearIndex));

minRPM is usually set to 700-1000, depending on the idle RPM of the engine. You can get wheelRPM from your WheelCollider components.

5. Finally, calculate the motorTorque.
totalMotorTorque = torqueCurve.Evaluate(motorRPM) * gearRatios.Evaluate(gearIndex) * finalDriveRatio * accel;

If you have four drive wheels, set each wheel's motorTorque to totalMotorTorque / 4. If you have only two drive wheels (front or rear wheel drive), set each wheels motorTorque to totalMotorTorque / 2. accel is a float variable which specifies how far the accelerator cable is depressed, and should be between 0 and 1.

6. Fill in the gaps. You need to add a mechanism to change the gearIndex value (which specifies which gear the car is in) and a mechanism to modify the accel value.

7. Tweak the curves. Just like a real car, minor adjustments to weight, torque curves or gear ratios can have a dramatic impact on the car's performance. Don't be surprised if you get crazy behavior from seemingly minor modifications!

Strange Goings-On at Different Methods...

Master Chief rides to the rescue, solving all OSX Server problems in his path...

Popular Posts