Check out example codes for "how to make a patroling enemy in c#". It will help you in understanding the concepts better.

Code Example 1

public float speed;
    public float startWaitTime;
    public Transform[] moveSpots;

    private float waitTime;
    private int randomSpot;

    void Start()
    {
        randomSpot = Random.Range(0, moveSpots.Length);
        waitTime = startWaitTime;
    }

    void Update()
    {
        transform.position = Vector2.MoveTowards(transform.position, moveSpots[randomSpot].position, speed * Time.deltaTime);

        if(Vector2.Distance(transform.position, moveSpots[randomSpot].position) < 0.2f)
        {
            if(waitTime <= 0)
            {
                randomSpot = Random.Range(0, moveSpots.Length);
                waitTime = startWaitTime;
            }
            else
            {
                waitTime -= Time.deltaTime;
            }
        }
    }

//Make sure to create empty gameobjects and call them MoveSpots, and drag them
//into the Move Spots float on your enemy!

Learn ReactJs, React Native from akashmittal.com