Adding a weapon pick up

Now, we can move on to adding the logic that will run the player pickup of the weapon object. This will be very similar to the other player pickups except that the weapon will need a few special considerations. For one, the weapon will need to be in the same screen location as the player at all times so that it can animate appropriately.

Let's begin by opening up the Player.cs script where the current player pickup logic exists. We are going to add a few new variables that will hold references to our weapon and some of the images that we will use to make the display icon. As stated earlier, we will create a display icon on the screen that will show the weapon that the player has in their inventory. Add the following lines ...

Get Procedural Content Generation for Unity Game Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.