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

public class SensorBinario : MonoBehaviour
{
    public float valor = 0f;
    public float amplitud = 80f;

    public Image aguja;
    public InputBinario input;

    private float currentRotation = 0f;
    
    void Update()
    {
        apretado = input.apretado;

        var r = 90f - 45f * Mathf.Clamp(Mathf.Log(valor, 2f), 0f, 4f);
        currentRotation += .3f * (r - currentRotation);
        aguja.transform.localEulerAngles = new Vector3(0f, 0f, currentRotation);
    }

    public bool apretado
    {
        set
        {
            valor = amplitud * (value ? 1 : 0);
        }
    }
}
