Your OnTriggerEnter and OnTriggerExit callbacks don't control the Collider. Tag your Player as "Player" and do this modification :
void OnTriggerEnter(Collider other)
{
if(other.CompareTag("Player"))
{
inTrigger = true;
}
}
void OnTriggerExit(Collider other)
{
if(other.CompareTag("Player"))
{
inTrigger = false;
}
}
This way you control if the object being entered in Key trigger is player.
↧