Unity3D and Fungus Tutorial: PickUps

marcosecchi
9,161 views

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

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.

Open Source Your Knowledge: become a Contributor and help others learn. Create New Content