Today I went into my build looking to accomplish the Golden Apple functionality. At the beginning of the game, you will be presented with three apples the player is able to pick up- I initially wanted these to become part of your inventory, but then realized that it would be much simpler to just have the player destroy the objects and have three apples already equipped to the player, ready to be thrown at any time. With this implemented, I was able to write a script that destroyed the apple after 10 seconds, and another that limits the amount of apples the player can drop to three. I referenced the Unity documentation for GameObject.FindGameObjectsWithTag at one point in the process in order to assign the Golden Apple as a prefab.

I also created a script that makes the character die upon collision with the enemy, which gave me a run around because the player uses the Character Controller rather than a collider, but after rearranging the assets in the inspector I got it to work!

Leave a comment