void InitiatePizzaReception(DeliveryTruck receiver) { //make sure the truck is going slow enough to deliver pizzas if (receiver.GetComponent <Rigidbody>().velocity.magnitude < speedTolerance) { //it is! wait a sec, then drop the 'zas receivingPizzas = true; launchTimer = delayBeforeReceive; } }
void InitiatePizzaResupply(DeliveryTruck receiver) { //make sure the truck is going slow enough to receive pizzas if (receiver.GetComponent <Rigidbody>().velocity.magnitude < speedTolerance) { //it is! wait a sec, then drop the 'zas supplying = true; pizzasToGiveThisTrip = truck.getMaxPizzas() - truck.HowManyPizzas(); spawnTimer = delayBeforeResupply; } }
void Update() { if (supplying) { //don't spawn em all at once spawnTimer -= Time.deltaTime; if (spawnTimer < 0) { spawnTimer = spawnInterval; GameObject pizza = (GameObject)Instantiate(pizzaPrefab, truck.pizzaSpawnPoint.position, truck.transform.rotation); pizza.GetComponent <Rigidbody>().velocity = truck.GetComponent <Rigidbody>().velocity; pizzasGivenThisTrip++; } if (pizzasGivenThisTrip >= pizzasToGiveThisTrip) { supplying = false; pizzasGivenThisTrip = 0; pizzasToGiveThisTrip = 0; } } }