From the course: Advanced Unity 2D: Platformer Player Movement

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Picking up items

Picking up items - Unity Tutorial

From the course: Advanced Unity 2D: Platformer Player Movement

Start my 1-month free trial

Picking up items

- Now we're ready for our player to start picking up items. In this case, we're gonna have a flower that enables the player to shoot fireballs. To get started, let's go into the Artwork folder and look for the flower. Here, we'll drag this into the scene and place it near the ground. We'll add a Box Collider 2D to the flower, and we're going to set this to "Trigger". This way, it doesn't act like a solid object when the player walks into it. Now, back in our Scripts folder, let's go into the Collision folder and create a new class called "Collectable". Now we'll open it in MonoDevelop. Let's create a public property that'll keep track of the type of game objects that are able to pick this up. We'll make a public string and we'll call this "TargetTag". In this case, we'll just set it to "Player". Now, let's delete the Start and Update methods, since we won't be using them, and we'll take advantage of a built-in method that collider's will automatically trigger, called…

Contents