Door not closing properly unity3d

Viewed 28

I am trying to make a door in my unity game for testing purposes, but I'm finding that my door doesn't shut completely once it has been opened.

This is most of my code for my door

        {
            unlockedSound.Play();
            locked = false;
            keyOB.SetActive(false);
            StartCoroutine(unlockDoor());
        }

        if (inReach && doorisClosed && unlocked && Input.GetButtonDown("Interact"))
        {
            door.SetBool("Open", true);
            door.SetBool("Closed", false);
            openText.SetActive(false);
            openSound.Play();
            doorisOpen = true;
            doorisClosed = false;
        }

        else if (inReach && doorisOpen && unlocked && Input.GetButtonDown("Interact"))
        {
            door.SetBool("Open", false);
            door.SetBool("Closed", true);
            closeText.SetActive(false);
            closeSound.Play();
            doorisOpen = false;
            doorisClosed = true;
        }


        if (inReach && locked && Input.GetButtonDown("Interact"))
        {
            openText.SetActive(false);
            lockedText.SetActive(true);
            lockedSound.Play();
        }

    }

    IEnumerator unlockDoor()
    {
        yield return new WaitForSeconds(0.05f);
        {
            unlocked = true;
            lockOB.SetActive(false);
        }
    }

I have the animations set to properly close the door, I'm unsure of how to move forward with this.

I have even tried isolating the door and suspending it in the air incase something was preventing it from closing properly

0 Answers
Related