Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        x = transform.position.x;
        y = transform.position.y;

        if (wait > 0)
        {
            wait -= Time.deltaTime;
        }

        if (destinationPoint < pathToFollow.waypoints.Count && destinationPoint >= 0 && wait <= 0)
        {
            mover.FacePoint(new Vector3(pathToFollow.waypoints[destinationPoint].x, pathToFollow.waypoints[destinationPoint].y));
            mover.MoveToFacing();

            float distanceToWaypoint = Mathf.Sqrt(Mathf.Pow((x - pathToFollow.waypoints[destinationPoint].x), 2) + Mathf.Pow((y - pathToFollow.waypoints[destinationPoint].y), 2));
            if (distanceToWaypoint < pathToFollow.waypoints[destinationPoint].radius)
            {
                HitWaypoint();
            }
        }
    }