- Home /
How Make a Simple Altimeter?
I've been over all the other altimeter and speedometer questions and answers thoroughly and am still in need some help.
I need a very simple altimeter. It needs to be dial on a gameObject and not GUI.
I have a needle and a face.
All that I need it to do is have the needle be placed at 0 when the altimeter is at zero and move accordingly and accurately as you ascend and descend.
I can access the altitude variable which is easy enough and works fine.
I think I need to use something like this:
float needleAngle= Mathf.Lerp(altitudeLow, altitudeHigh, Time.time);
Although Time.time is wrong.
I need to Lerp the needle using the altitude.
What am I missing and how do I do this correctly?
Thanks in advance!
Answer by Kiwasi · Dec 10, 2014 at 03:24 AM
float needleAngle= Mathf.Lerp(altitudeLow, altitudeHigh, actualAltitude/(altitudeHigh-altitudeLow));
Although if you want the altitude needle to move based on angle then you probably want something like this
float needleAngle= Mathf.Lerp(angleMin, angleMax, actualAltitude/(altitudeHigh-altitudeLow));
Thanks so much for your help.
Can you help with rotating the needle?
I tried:
transform.eulerAngles = new Vector3(0,needleAngle,0);
but that doesn't work.
I don't know. If I use:
(angle$$anonymous$$in, angle$$anonymous$$ax, Time.time)
The needle rotates, but when I use the actualAltitude, it doesn't rotate. It jumps to the maxAngle.
Your answer
Follow this Question
Related Questions
Mathf.Lerp not working as expected 2 Answers
How can i pause gradually from timeScale 1.0 to 0.0 over a second? 1 Answer
How the heck does Mathf.Lerp work? 2 Answers
Slide object between two moving points c# 1 Answer
Mathf.Lerp won't stop snapping 2 Answers