private void Update() { float step = speed * Time.deltaTime; Vector3 nextPosition = visionCone.FollowThePlayer() ? player.position : positions[vectorPosition].transform.position; transform.position = Vector2.MoveTowards(transform.position, nextPosition, speed * Time.deltaTime); if (transform.position == nextPosition) { vectorPosition = vectorPosition == positions.Length - 1 ? 0 : vectorPosition + 1; } var heading = transform.position - nextPosition; var distance = heading.magnitude; var direction = heading / distance; if (GameObject.FindWithTag("pushable") != null) { //print("andando"); animation(direction); } visionCone.SetAimDirection(direction * -1); visionCone.SetOrigin(transform.position); }