This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
item_pickup_tutorial [2018/03/07 20:10] – justin | item_pickup_tutorial [2018/03/07 20:51] – justin | ||
---|---|---|---|
Line 1: | Line 1: | ||
======Item Pickups====== | ======Item Pickups====== | ||
- | |||
- | (WIP) | ||
- | |||
This tutorial will explain how to set up map [[object|objects]] as [[item|items]] for the [[player_character|player]] to pick up, for example a key that the [[player_character|player]] can pick up by walking into/over it and then use to open a door or treasure chest. | This tutorial will explain how to set up map [[object|objects]] as [[item|items]] for the [[player_character|player]] to pick up, for example a key that the [[player_character|player]] can pick up by walking into/over it and then use to open a door or treasure chest. | ||
Line 8: | Line 5: | ||
=====Creating the Object Model===== | =====Creating the Object Model===== | ||
- | |||
Open the [[New Resource Dialog]] and create a new [[object]]. Once the [[Voxel Editor]] opens for the new [[object]] model, use the [[voxel]] tools to build a key as shown below (or whatever will best visually represent the [[item]]). | Open the [[New Resource Dialog]] and create a new [[object]]. Once the [[Voxel Editor]] opens for the new [[object]] model, use the [[voxel]] tools to build a key as shown below (or whatever will best visually represent the [[item]]). | ||
Line 27: | Line 23: | ||
=====Creating a Sound Effect===== | =====Creating a Sound Effect===== | ||
- | Optionally, you can create a [[sound|sound effect]] for the game to play when the [[item]] is picked up by the [[player_character|player]]. | + | Optionally, you can create a [[sound|sound effect]] for the game to play when the [[item]] is picked up by the [[player_character|player]]. To do so, click the [[Sound FX Generator]] button at the top, then click one of the presets along the left to find a [[sound]] that goes well with the [[item]]. In this example, the " |
{{: | {{: | ||
- | =====Setting Up the Object in a Map===== | + | Once you are happy with the [[sound]], click the "Save Sound" button ({{: |
- | Place object into map in desired location | + | =====Setting Up the Object in a Map===== |
+ | Open the [[map]] where you'd like to have the [[item]] pickup. Select the [[object]] model you created earlier from the resource container on the right, then place the [[object]] onto an open [[tile]] | ||
{{: | {{: | ||
- | Open properties dialog for object and assign an entity | + | Switch into " |
{{: | {{: | ||
- | Open properties | + | Double-click the [[tile]] underneath the [[object]] (or right-click on it and select " |
+ | |||
+ | Copy and paste the [[script]] source code below into the dialog as shown. You may need to make a few adjustments according to the names you chose earlier on, in particular the entity ID for the [[object]] (" | ||
<code lua> | <code lua> | ||
Line 52: | Line 51: | ||
{{: | {{: | ||
- | =====Testing | + | To better understand what the [[script]] is doing, I've included explanations for each line. |
+ | |||
+ | <code lua> | ||
+ | set_entity_script(self, | ||
+ | </ | ||
+ | |||
+ | This line removes the [[script]] from the [[entity]] that activated it (" | ||
+ | |||
+ | <code lua> | ||
+ | remove_entity(entity[" | ||
+ | </ | ||
+ | |||
+ | This line removes the physical key [[object]] from the scene by referring to the unique [[entity]] ID we assigned to the key earlier on in the [[Map Editor]]. The ID inside the quotes should exactly match the ID that was assigned to the [[object]] earlier on from its [[Entity Properties]] dialog. | ||
+ | |||
+ | <code lua> | ||
+ | play_sound(" | ||
+ | </ | ||
+ | |||
+ | This line plays the [[sound|sound effect]] named " | ||
+ | |||
+ | <code lua> | ||
+ | give_item(" | ||
+ | </ | ||
+ | |||
+ | This line puts the [[item]] named "Gold Key" into the [[player_character|player' | ||
+ | |||
+ | Click the " | ||
- | Finished! Save map and export | + | =====Testing the Pickup In-Game===== |
+ | [[exporting_your_game|Export your game]] to try out your new [[item]] pickup. The [[player_character|player]] should | ||
{{: | {{: | ||