Why won’t the "Closed"
bool
turn off?
I have tried putting door.SetBool("Closed", false)
In Start
AND Awake
I but its just not listening I prefer to use OnTriggerEnter
with these things so I don’t know if the script is just outdated but I’ve been struggling with this please help.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Doors : MonoBehaviour
{
public Animator door;
public GameObject crosshair;
public bool inReach;
void DoorOpens ()
{
Debug.Log("It Opens");
door.SetBool("Opened" , true);
}
void DoorCloses ()
{
Debug.Log("It Closes");
door.SetBool("Closed" , true);
}
void Start ()
{
inReach = false;
}
void OnTriggerEnter ( Collider other )
{
if( other.gameObject.tag == "Reach" )
{
inReach = true;
crosshair.SetActive(true);
}
}
void OnTriggerExit ( Collider other )
{
if( other.gameObject.tag == "Reach" )
{
inReach = false;
crosshair.SetActive(false);
}
}
void Update ()
{
if( inReach && Input.GetMouseButton(0) )
{
DoorOpens();
}
else
{
DoorCloses();
}
}
}