Back
Close

Unity3D and Fungus Tutorial: PickUps

marcosecchi
16.1K views

Managing the PickUp Logic

Let's now add some logic that will let our character pick up the coin. We are going to use a Fungus Flowchart, that will be placed inside the PickUpCoin element.

Adding a Flowchart

Select PickUpCoin, click on Add Component and select Scripts > Fungus > Flowchart: click Open Flowchart Window to show the Flowchart.

Adding a Flowchart to the PickUp

Adding a 'Trigger Enter' Block

Create a command block, by using the + button in the Flowchart window and rename it TriggerEnter.

We need the block to become active on the MonoBehaviour > Trigger (FireOn > Enter) event, when an element enters in the GameObject Trigger.

Set the TagFilter field to 1 and, inside Element 0 insert "Player" (mind the uppercase!), so that only the Controller (which we tagged as "Player" in the previous lesson) will activate it.

Adding a Block

Adding Commands

We are now going to add some commands to the block.

Add an Usfxr Audio

First of all, let's add an Audio > Play Usfxr Sound command. In the Settings String field, add:

0,.5,,.0289,.4065,.4227,.3,.4748,,,,,,,,,.5,.5848,,,,,,,,1,,,,,,

You can create your audio effects using the Fungus integrated editor selecting, selezionando Fungus > Utilities > Generate usfxr Sound Effects (for more info, please check the project page on GitHub).

Adding an Audio Effect

Destroying the PickUp

Just after the audio effect, add a Scripting > Destroy command and drag the PickUpCoin gameobject from the Hierarchy panel into the Target Game Object field.

Destroying the PickUp

Playing the scene and moving the character on the coin, will result in the object being removed from game, just after the audio effect.

You are now ready to create a prefab out of the coin object.

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