I want to change a bool in 2 separate scripts in Unity but it's not changing OnTriggerEnter
or stay or exit. I've tried everything but nothing helped me.
This is the script where I store the bool and the animator script:
public Animator _T1anim;
public bool Open;
void Awake()
{
_T1anim = GetComponent<Animator>();
_T1anim.SetBool("Open", false);
_T1anim.SetBool("Close", true);
}
public void Update()
{
if (Open != true)
{
CloseDoor();
}
else
OpenDoor();
}
public void OpenDoor() {
_T1anim.SetBool("Open", true);
_T1anim.SetBool("Close", false);
}
public void CloseDoor()
{
_T1anim.SetBool("Close", true);
_T1anim.SetBool("Open", false);
}
and I want to change the "Open" Bool to true with the OnTriggerEnter
in a different script. The T1_1 T11
is the reference to the first script.
T1_1 T11;
void Awake()
{
T11 = GetComponentInParent<T1_1>();
}
public void OnTriggerEneter(Collider other)
{
if (other.tag == "Player")
{
T11.Open = true;
}
}
}
This is the animator controller:
OnTriggerEneter
in the second script. \$\endgroup\$