Displaying single object pickups with carrying and not-carrying text
Often, the simplest inventory situation is to display text to tell players whether they are carrying a single item (or not). In this recipe, we’ll script the ability to detect collisions with the star GameObject and add this to the SpaceGirl mini-game. We will also display an on-screen message stating whether a star has been collected or not:
Figure 3.6: Example of text for displaying single-object pickups
At the end of the recipe, in the There’s more... section, we’ll learn how to adapt this recipe to maintain the Integer total for how many stars have been collected, for a version of the game with lots of stars to collect.
Getting ready
For this recipe, we have prepared a folder named _Scripts
in the 03_02
folder.
This recipe assumes that you are starting with the Simple2Dgame_SpaceGirl
project, which we set up in the previous recipe. So, make a copy of that project...