- Home /
Helicopter Speed Gauge Help
I need to make a rotor velocity speed meter UI for my helicopter which does not rely on the in-game physics but rather the speed of the helicopter's rotor (rotor_velocity) that I had scripted on my helicopter object.
I have tried to make a code out of it, but I cant figure how to implement the rotor's velocity from my helicopter script to the Speed Gauge UI script.
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 would be appreciated
Your answer
![](https://koobas.hobune.stream/wayback/20220612234627im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Error with my C# script for my helicopter 2 Answers
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