# Waypoint System - Wait System Logic problem

How do I introduce stops between way points in my following script. So the character will be stop in that point and it need to be activated again from another script, so it will continue its journey through all points.

Any input will be appreciated. Thanks.

``````   private Transform startPos, endPos;

public Transform[] wayPoints;

public float speed = 6.0f;
public float rotDamping = 6.0f;
public float waitTime = 2.0f;

public float curTime;
public int curWayPoint;

private float startTime;
private float length;

public GameObject winnie;

public bool walkComplete;

IEnumerator Start()
{
yield return new WaitForSeconds(3.0f);
setPos();
curWayPoint = 0;
}

public void setPos()
{
startPos = wayPoints[curWayPoint];
endPos = wayPoints[curWayPoint + 1];

startTime = Time.time;
length = Vector3.Distance(startPos.position, endPos.position);
}

public void winniePath()
{
float distance = (Time.time - startTime) * speed;
float Journey = distance / length;

winnie.transform.position = Vector3.Lerp(startPos.position, endPos.position, Journey);
Quaternion rotation = Quaternion.LookRotation(winnie.transform.position - wayPoints[curWayPoint].position);

winnie.transform.rotation = Quaternion.Slerp(winnie.transform.rotation, rotation, rotDamping * Time.deltaTime);

if (Journey >= 1 && curWayPoint + 1 < wayPoints.Length)
{
curWayPoint++;
setPos();
}

if (curWayPoint == wayPoints.Length - 1)
{
walkComplete = true;
}
}
``````

You could just do a coroutine to head towards the position then have a yield return WaitForSeconds

``````foreach (Vector3 pos in m_PatrolRoute)
{
yield return StartCoroutine(GoToDestination(pos));

yield return new WaitForSeconds(m_PatrolWaitTime);
}
``````