private void Update() //wywoływana w każdej klatce gry { float distance = Vector3.Distance(transform.position, player.position); //odległość przedmiotu od postaci if (distance > pickUpDistance) //jeśli jest za daleko od przedmiotu { return; //przerywa funkcję Update() } transform.position = Vector3.MoveTowards( //przesuwa transform.position, //przedmiot player.position, //w stronę postaci speed); //z takim krokiem (deltaTime to czas klatki gry) if (distance < 0.1f) { if (GameManager.instance.inventoryContainer != null) { GameManager.instance.inventoryContainer.Add(item, count, GameManager.instance.inventoryContainer); Debug.Log("Liczba przedmiotów zebranych: " + count); //*************Wykonanie questa 0************** if (item.name == "Carrot") { FableController fableController = GameManager.instance.fableController; if (GameManager.instance.fableController.GetCurQuest() == 0) { fableController.NextQuest(); } } //********************************************* } else { Debug.LogWarning("No inventory container in game manager!"); } Destroy(gameObject); } }
void Start() { fableController = GameManager.instance.fableController; saveLoad = GameManager.instance.saveLoadController.saveLoad; }