- Home /
How to make a helicopter speed gauge?
Im trying to build a speed gauge HUD for my helicopter that uses the rotor velocity to indicate the rotor speed rather than using rigidbody to calculate. I want to link the rotor's velocity(which I have the script in my helicopter) to my speed gauge HUD. What code should I use to link the rotor velocity to the speed gauge HUD?
Here is the current code that I have,
var gaugeTex: Texture2D;
var pointTex: Texture2D;
var gaugePos: Vector2;
var topSpeed: float;
var stopAngle: float;
var topSpeedAngle: float;
var speed: float;
var player_gameobject : GameObject;
private var helicopter_throttle : float;
function OnGUI() {
GUI.DrawTexture(Rect(gaugePos.x, gaugePos.y, gaugeTex.width, gaugeTex.height), gaugeTex);
var centre = Vector2(gaugePos.x + gaugeTex.width / 2, gaugePos.y + gaugeTex.height / 2);
var savedMatrix = GUI.matrix;
var speedFraction = speed / topSpeed;
var pointAngle = Mathf.Lerp(stopAngle, topSpeedAngle, speedFraction);
GUIUtility.RotateAroundPivot(pointAngle, centre);
GUI.DrawTexture(Rect(centre.x, centre.y - pointTex.height / 2, pointTex.width, pointTex.height), pointTex);
GUI.matrix = savedMatrix;
helicopter_throttle = player_gameobject.GetComponent( "Heli Flight Script" ).rotor_Velocity;
}
function Update() {
speed = helicopter_throttle;
}
Any Help is appreciated
Your answer
Follow this Question
Related Questions
Script for getting in and out of a tank 2 Answers
Change networkView owner not working 1 Answer
Aligning Camera to Object 2 Answers
Prefabs & scripts 1 Answer
Helicopter Speed Gauge Help 0 Answers