speedometer

Hi all.
Can any one please tell how to create a speedometer in unity?

Thanks in advance
raja

Hello,

are you creating a vehicle using Physics engine?

Hello.

I am creating a racing game and I have the same question. This is the code I am using, but it is probably mediocre… :

var car : Transform;
function OnGUI (){
speed = car.rigidbody.velocity.z * speedometerMultiplier;
var speedDisplay : String = speed.ToString();

GUI.Label(Rect(10, Screen.height - 20, 100, 20), speedDisplay);
}

Again, I have only been coding for a few months. This code would in theory work, but it spits out a velocity relative to the WORLD axis. How do i get the velocity relative to a LOCAL axis?

use transform.TransformDirection. Like:

var car : Transform;
function OnGUI (){
var speed : int;
speed = car.rigidbody.velocity.z * speedometerMultiplier = transform.TransformDirection;
var speedDisplay : String = speed.ToString();

GUI.Label(Rect(10, Screen.height - 20, 100, 20), speedDisplay);
}

Or something like that. It probebly wont work, but still :roll:

I would recommend that you download J-Car and see how he has done it.
http://ctrl-j.com.au/pages/jcarsrc.html

edplane, nice signature. i like the javaScript reference.

LOL, do you support that too? Cause Valve is going to Mac, and I fear it will be Intel only… :frowning:

Well thats the thing, Apple is constantly ending support of older products so as to keep the customers moving (like i do, i still have the same iPod for the past 3 years), and keep themselves making money. If all of Apple’s users stayed with the old PPC models instead of moving on to the newer Intel machines, they would make much less money.

So yea, your worst fears confirmed :confused:

I have the Pro 2.6, so this is how I did it:

Make a needle somewhere in the world where the player will NEVER see it. Then have a script on it that changed the needles rotation according to the vehicles speed. Then have a camera pointed at that needle (use orthographic) and set it to a render texture. Then display that render tex on the screen with a GUI.DrawTexture function