Next you will instantiate the prefab when the flower is picked. Your ObjectLookup script is already set up to allow for instantiating prefabs. Let’s finish setting that up and test with the updated prefab.
1. Open the ObjectLookup script.
2. Add the following variable to hold an array of prefabs:
3. In the special cases section for case “p,” replace //add guts here with:
This time, because most action objects won’t have any prefabs to instantiate, you will tell the game engine which prefab to use by setting the second character of the three character special cases to the element you want to instantiate.
4. Save the script.
5. Select the Flower.
6. Near the bottom of the ObjectLookup component, set the Size of the Prefab array to 1.
7. Drag the Vial Animated into Element 0.
8. Add the p0_Flower,0 to the Lookup State 0, Element 0 to read as follows: