Last week, we showed how we started on the third assignment and explained the idea that we were gonna work on. We have created a first version of the customer spawning and implemented the grabbing functionality.
This week we continued working on making these functionalities better, while also developing new features. We worked a lot on the customer spawning since it ties in with other functionalities, like displaying what the customer orders, and serving them the food. The first version of it was only spawning the customers on 3 random seats. We have extended that number of seats to 12, meaning we created 12 different spawn points. As for the customers, there are 3 different prefabs.
Customer Spawner component in SpawnerManager |
Spawn method in Customer Spawner Script |
In the Spawn method, we firstly check if there is any spawn available. Then, we choose a random available seat and a random customer prefab. We instantiate the customer object and map the seat and person to a dictionary. This will help for the functionality of finishing an order and making the seat available again. There is also a variable spawnDelay, with which we can set the spawn rate, in seconds, of the customers.
One thing we had to take in consideration was how to approach the spawning of the food. We discussed some options and we decided on having different spawners for each kind of food. The way they would work is that the spawner would check if it is colliding with any food object of the specified type. If the player takes the food from the spawnpoint, OnTriggerExit would call and initialize another food object.
One problem we encountered was that the OnTriggerExit method would be called multiple times and therefore spawn multiple food objects at once. We did not find the cause of the issue, so we tried working around it with a boolean.
The boolean would tell if the objects were colliding or not. If its true, meaning colliding, then it doesnt spawn the food. Because the OnTriggerExit would be called multiple times, we set the boolean to false on the first call so it spawns it on the second call.
For now, what we are missing is displaying the order of the customer and how to serve the food to the customer. We will also try to find the cause behind the OnTriggerExit being triggered multiple times.
Author: Alexandru Jurj
Comments
Post a Comment