Door open with RayCast

Hi I made this to simple scripts it’s not ideal don’t know how to make door close when use Input.KeyDown on it again but open state works good, for this in Animation Controller I used Triggers.

Here is RayCast script it go on a camera or else.

using UnityEngine;
using System.Collections;

public class DoorRayCast : MonoBehaviour
{
    public float Doordistance = 1.5f;
    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void FixedUpdate()
    {
        if (Input.GetButtonDown("actButton"))
        {
            CheckRayCast();
        }

    }
    private void CheckRayCast()
    {
        Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5F, 0.5F, 0));
        RaycastHit data;
        if (Physics.Raycast(ray, out data, Doordistance))
        {
            GetComponent<DoorsActAnim>();
        }
    }
}

And Scrip that starts animation when Input button is presed

using UnityEngine;
using System.Collections;

public class DoorsActAnim : MonoBehaviour {
    private Animator DoorAnim;
    private AnimatorStateInfo BaseLayer;
    private AnimatorStateInfo currentBaseState;
    static int idleDoor = Animator.StringToHash("Base Layer.apartment_door_idle");
    static int openDoor = Animator.StringToHash("Base Layer.apartment_door_open");
    static int closeDoor = Animator.StringToHash("Base Layer.apartment_door_close");
    public float Doordistance = 1.5f;

    // Use this for initialization
    void Start()
    {
        DoorAnim = GetComponent<Animator>();
    }
    void FixedUpdate () {
        currentBaseState = DoorAnim.GetCurrentAnimatorStateInfo(0);
        if (Input.GetButtonDown("actButton"))
        {
            DoorAnim.SetBool("Open", true);
        }
        else if (Input.GetButtonDown("actButton"))
        {
            DoorAnim.SetBool("Close", true);
        }
    }
   
    }

You need to set the Animator “Open” bool to false when you close the door.

      if (Input.GetButtonDown("actButton"))
        {

           if (DoorAnim.GetBool ("Open") == false){
            DoorAnim.SetBool("Open", true);
            DoorAnim.SetBool("Close", false);
           }

         else
             {
   
            DoorAnim.SetBool("Open", false);
            DoorAnim.SetBool("Close", true);

              }
        }

A tidier way to do this would be to use Animator Triggers