void Update()
{
if (Input.GetButtonDown("Use"))
{
StartCoroutine(Interaction(true));
}
}
public IEnumerator Interaction(bool state)
{
if(state == true)
{
Check = Physics2D.Raycast(new Vector2(transform.position.x, transform.position.y), RayDirection, RayLength, Mask);
if (Check.collider != null)
{
if (Check.collider.tag == "Dialogue")
{
state = false;
yield return new WaitForSeconds(0.5f);
Debug.Log("is work");
}
}
}
}
The console displays the message twice “is work”;
Please tell me what is the error? I need the message to be displayed only once.