Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if (path == null)
        {
            return;
        }
        transform.position = Vector2.MoveTowards(transform.position, targetPoint.position, speed * Time.deltaTime);

        var distanceTarget = Vector2.Distance(transform.position, targetPoint.position);

        if (distanceTarget < 0.1f)
        {
            targetPoint = path.getNextPoint();
        }
    }
Exemple #2
0
    void Update()
    {
        if (path == null)
        {
            return;
        }

        transform.position = Vector2.MoveTowards(transform.position, _TargetPoint.position,
                                                 MoveSpeed * Time.deltaTime);

        float Distance = Vector2.Distance(transform.position, _TargetPoint.position);

        if (Distance <= 0.1f)
        {
            _TargetPoint = path.getNextPoint();
        }
    }