Creating a new monster service
Since we need a way to track the monsters around the player, what better way to do this than with a new service? The monster service will need to accomplish a few jobs, as follows:
- Track the players location
- Query for monsters in the vicinity
- Track monsters within range of the player
- Instantiate a monster when it is close enough to the player
For now, our monster service will only query and track monsters local to the player's device. We are not creating a monster web service where multiple players will consume and see the same monsters, yet. However, in Chapter 7, Creating the AR World, we will convert our service to use an external service to better populate our monsters. Open up Unity and follow these directions to start writing the new service script:
- In the Project window, open the
Assets/FoodyGo/Scripts/Services
folder. Right-click (press Ctrl and right-click on a Mac) to open the context menu and select Create | C# Script to create a...