private void Update() { transform.position = Vector2.MoveTowards(transform.position, goal, speed * Time.deltaTime); if ((Vector2)transform.position == goal) { goal = stinkManager.GetStinkiestTile(transform.position, smellRadius);; RotateToGoal(); } }
private void Update() { transform.position = Vector2.MoveTowards(transform.position, currentGoal, baseSpeed * Time.deltaTime); Vector2 direction = currentGoal - (Vector2)transform.position; float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg; angle -= 90f; transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward); if ((Vector2)transform.position == currentGoal) { currentGoal = stinkManager.GetStinkiestTile(transform.position, smellRadius); } }
private void Awake() { stinkManager = FindObjectOfType <StinkManager>(); goal = stinkManager.GetStinkiestTile(transform.position, smellRadius); RotateToGoal(); }