Hi everyone, om making a open door script with a collider and staytrigger event, when player walks off, the door gets closed, but i see when player stay on the collider more than 2 seconds, the stay function stop working, this is the code for trigger
void OnTriggerStay2D(Collider2D col)
{
if(col.gameObject.tag =="Player")
{Debug.Log(Time.time);}
if(col.gameObject.tag == "Player" && Input.GetKeyDown(KeyCode.Z) && !isUp)
{
Debug.Log("Col");
transform.localPosition = new Vector2(transform.localPosition.x + moveOnX, transform.localPosition.y + moveOnY);
isUp = true;
}
}
void OnTriggerExit2D()
{
if(isUp)
{
transform.localPosition = new Vector2(transform.localPosition.x - moveOnX, transform.localPosition.y - moveOnY);
isUp = false;
}
}
thanks