Bools always returning true???

Here is my code, in the inspector - once I run the game - Both of the bool’s are checked and true… How can this be. Even by clicking the tick box I can not turn the value to false!? Thanks…

{
    public Transform BodyPosition;
    public Transform ConeA;
    public Transform ConeB;

    public float Speed = 12.0f;
    public bool ATarget, BTarget ;
    public Vector3 HeadPosition , ConeAPosition , ConeBPosition , TargetPosition ;

    void start ()
    {
        ATarget = true;
        BTarget = false;

        ConeAPosition = new Vector3 (ConeA.position.x, 2.25f , ConeAPosition.z);
        ConeBPosition = new Vector3 (ConeB.position.x, 2.25f , ConeBPosition.z);
    }
  
    void FixedUpdate ()
    {  
        HeadPosition = new Vector3 (BodyPosition.transform.position.x, 2, BodyPosition.transform.position.z);
        transform.position = HeadPosition;

        if (ATarget = true)
        {
            transform.LookAt (ConeAPosition);  
        }

        if (BTarget = true)
        {
            transform.LookAt (ConeBPosition);  
        }
    }
}

start isn’t the same thing as Start :slight_smile:

Also in your FixedUpdate you’re trying to compare with =. == is comparison but is unnecessary for booleans anyway.

3 Likes

Oh how embarrassing

I missed the else :frowning:

Thanks mate :smile: