using System.Linq;
using UnityEngine;

public class SolidButton : MonoBehaviour
{
    public BoxCollider area;
    public Transform anchor;
    public Transform a;
    public Transform b;
    public float smooth = 10;

    public bool value;

    private void Update()
    {
        var cols = Physics.OverlapBox(area.transform.position, area.size / 2f, area.transform.rotation);

        value = cols.Any(e => e.GetComponent<SolidButtonActivator>() != null);

        var target = value ? b : a;
        anchor.position = Vector3.Lerp(anchor.position, target.position, smooth * Time.deltaTime);
    }
}