Rotating RectTransform Z Axis

I am trying to make a speedo for a car that looks like this…

6212165--682688--upload_2020-8-17_16-31-28.png

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

Line 11: don’t use Quaternion.EulerAngles.

Just use Quaternion.Euler()

3 Likes

Oh wow didn’t realise how close I was, Thanks!