Operator ">" cannot be applied to operands of type "bool" and "double"

Hello! I made a script for an object to switch to an animation if it is close to an object and if its y coordinate is in a specific range. It gives me the error above however I don’t see a Boolean in my script. Does anyone know what I am doing wrong?

using UnityEngine;
using System.Collections;

public class SVA_Control : MonoBehaviour {

    private Animator animator;
    private GameObject target;
    private float dist;
    private float centerT;
    private double upperTB;
    private double lowerTB;
    private double currentY;

        // Use this for initialization
    void Start () {
        animator = this.GetComponent<Animator>();
    }
   
    // Update is called once per frame
    void Update () {
        currentY = transform.position.y;
        target = GameObject.Find ("STB");
        centerT = target.transform.position.y;
        upperTB = centerT + 1.35;
        lowerTB = centerT - 1.45;
        dist = (target.transform.position - transform.position).sqrMagnitude;
        if (dist < 13) {
            if (upperTB > currentY > lowerTB) {
                animator.SetInteger ("State", 1);
            }
        }
}
}
if(upperTB > currentY > lowerTB)

you can’t do this. Two of those arguments compared makes a boolean, you then are attempting to check if that boolean is > some other value.

if(upperTB > currentY && currentY >  lowerTB)

Thank you! It works now! :slight_smile: