How can I rotate this meter arm between the labelled points without the arm passing through the red zone.

In the image above I am trying to make the meter hand rotate around the meter between the “0” position and the “16” position, without passing through the red zone. Problem is that if I was to click on the “16” button, the meter would move from the “0” position to the “16” position by passing through the red zone… how can I stop this from happening?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MeterRotate : MonoBehaviour
{
    public float turningRate;
    private Quaternion _targetRotation = Quaternion.identity;
    public Vector3 initialPosition;
    public Vector3 targetRotation;
    public Transform target;
    public int targetRotate;

    /* Need to work out how to handle rotating meter not using the shortest
     * distance*/

    // Start is called before the first frame update
    void Start()
    {
        // ensures the meter/switch is displayed in the 'off' position on load
        SetBlendedEulerAngles(initialPosition);
    }

    // Update is called once per frame
    void Update()
    {
        var step = turningRate * Time.deltaTime;
        // this rotates the meter, but always takes the quickest route
        transform.rotation = Quaternion.RotateTowards(transform.rotation,
            _targetRotation, step);
    }

    public void SetBlendedEulerAngles(Vector3 angles)
    {
        _targetRotation = Quaternion.Euler(angles);
    }

}

You will have to give it your own rotations every frame –
**
So I’m not sure exactly how your project is set up, but lets say your default rotation for the arm puts your arm pointing straight up, and that 0 is at 100 degrees on the z axis and that 16 is at -100 degrees. You would keep track of your local euler angle and move this angle instead of using quaternion.rotateTowards.

private float localZRot = 100; //Pointing at zero
private float targetZRot = 100;

void Update(){
    var step = turningRate * Time.deltaTime;
    rotStep = targetZRot - localZRot;
    localZRot += Mathf.Clamp(rotStep, -step, step);
    transform.rotation = Quaternion.Euler(0, 0, localZRot);
}

public void SetTargetAngle(float zAngle){
    targetZRot = zAngle;
}