I am trying to make a speedo for a car that looks like this…
I want the needle to move according to speed which I currently have. Here is my code.
void Awake() {
rectTransform = gameObject.transform.GetChild(2).GetComponent<RectTransform>();
}
public void FixedUpdate() {
mag = rb.velocity.magnitude;
playerSpeed = Mathf.Round((mag*180)/40);
playerSpeedText.text = playerSpeed.ToString()+"kph";
rectTransform.rotation = Quaternion.EulerAngles(0f, 0f, playerSpeed);
}
Obviously this doesn’t work but I’m not good enough with euler angles and the like to work it out. In my editor the needle starts at Rotation Z is 0 and Rotation Z manually changing it to -245 gets it right on the 360 top speed.
How can I adjust my player speed to add to the Z rotation number to make it react correctly?
Thanks