Wednesday, December 22, 2010
Starfire!
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.
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?
<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
Fraud.
I listed a car for sale on gumtree.com.au 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.
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:
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.
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!
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!
Subscribe to:
Posts (Atom)
Popular Posts
-
These are the robots I've been working on for the last 12 months. They each weigh about 11 tonnes and have a 17 meter reach. The control...
-
This hard-to-see screenshot is a Generic Node Graph Editing framework I'm building. I'm hoping it can be used for any kind of node...
-
So, you've created a car prefab using WheelCollider components, and now you can apply a motorTorque to make the whole thing move along. ...
-
MiddleMan: A Pub/Sub and Request/Response server in Go. This is my first Go project. It is a rewrite of an existing Python server, based o...
-
Why would I ask that question? Python 3 has been available for some time now, yet uptake is slow. There aren't a whole lot of packages i...
-
It is about 8 degrees C this morning. So cold, especially when last week we had high twenties. To help solve the problem, a friend suggeste...
-
After my last post, I decided to benchmark the scaling properties of Stackless, Kamaelia, Fibra using the same hackysack algorithm. Left axi...
-
I'm now using bzr instead of svn. I'm pushing my repositories to: http://exactlysimilar.org/bzr/ I'm also auto publishing docume...
-
Possibly slightly more correct lighting. The rim light is now only applied in the direction of the sun, rather than being purely based on vi...
-
I've just read a newspaper article (courtesy of Kranzky ) from WA Business News documenting the malfeasance, gross negligence and misc...