Back
Close

Unity3D and Fungus Tutorial: PickUps

marcosecchi
16.1K views
Previous: Introduction Next: Managing the PickUp Logic

Creating the GameObject

Open tht Scene

First of all, let's open the scene we worked on last lesson (or we downloaded).

The Starting Scene

Creating the Coin

Let's create and empty gameobject (GameObject > CreateEmpty), posizioniamolo in (0, 0, 0) and rename it PickUpCoin.

The Empty GameObject

From the Standard Assets > Prototyping > Models folder, drag PickupPrototype01x01x01 inside PickUpCoin, so that it's a child element.

Adding the Mesh

We are not adding the coin prefab because we are only interested in the model. We will add the Collider later on.

Select PickupPrototype01x01x01, and rename it Coin, position it in (0, 1, 0) and scale it to 30% (0.3, 0.3, 0.3).

With Coin selected, click Add Component in the Inspector panel and select Scripts > UnityStandardAssets.Utility > AutoMoveAndRotate to add a rotation effect to the coin.

Open the Rotate Degrees Per Second field and change Y to 100.

As a last step, change the Mesh Renderer from Pink Smooth to Yellow Smooth.

The final result should be similar to the one shown in the image below.

Improving the Coin

Playing the scene should start the coin rotation.

Save the scene.

Add the Trigger

Select the coin parent del coin (PickUpCoin): we are going to add a Collider so we can activate a trigger when the character enters inside it.

Let's click Add Component and select Physics > Sphere Collider: change it in a Trigger checking the Is Trigger value and, in the Center field, change the Y value to 1, so that it will be in the same position as the coin element.

We are using a Sphere Collider as it is pretty good for the ritating coin.

Improving the Coin

We are now ready to add some interactivity the the coin.

Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants