Hi all, I know this is a vague question, but I didn’t know what else to name it.
I have a monster that is supposed to follow the player when the player is in range of the box collider attached to the monster. When in the range of the box collider i want the monster to follow the player unity the player is out of range (the monster will still chase the player for ten seconds, and then start to randomly move if the player is not found)
the problem is that the monster only follows the player if the player is in range of the box collider, it doesnt wait ten seconds like i want it to.
private void OnTriggerEnter(Collider player)//when the box collider is seen
{
Debug.Log(“i see you”);//play a sound?
StartCoroutine(“VisibilityTime”);
}
IEnumerator VisibilityTime()
{
transform.position = Vector3.MoveTowards(transform.position, target.transform.position,
Time.deltaTime * speed);
yield return new WaitForSeconds (10);
//check if you can see still see
//only works if in box collider is still in view
}