Using Empty Game Objects
An Empty Game object is a regular GameObject in which you can load the exported Harmony data. All the individual body parts on the sprite sheet come in as separate elements, but are treated as one whole object with a dynamically created bounding box. If you put a transparency on this object, you would see the overlapping transparencies of all the individual objects. This creates a higher-quality render and should be the default if you’re not animating the transparency of an object. With this option, direct rendering will read the depth information in the scene but not write it. Note that with this option, the rendering cannot be customized.
- Select GameObject > Create Empty.
- Rename the empty GameObject so it's clear in the Hierarchy. Since we're using the SpaceCat demo file, rename the GameObject to SpaceCat by doing one of the following:
- Double-click on the name and rename it in the Hierarchy.
- Select the GameObject and rename it in the Inspector.
- At this point, it’s an empty object. Accessing Harmony data is done through scripts.
- Select the SpaceCat GameObject.
- In the Inspector, go to Add Component > Scripts > Harmony Renderer.
A new section appears in the Inspector called Harmony Renderer (Script).
This will let you load an animation file. You must put the path of the asset relative to the HarmonyResources folder. Before this, you must export from Harmony directly to this folder, or manually copy and paste the data here.
- You exported a scene called SpaceCat. In the Project Folder, place HarmonyResources/SpaceCat under the Transform information at the top, under Scale. Set the values to 0.01 for X, Y, and Z because the default Harmony project is for an HD screen.
- You won’t see anything until you define a few parameters:
- Set the Clip Name Size to 1. A second field will appear, Element 0.
- Enter the clip name for the animation you want to load.
- Double-check on the right Clip Name to put in Element 0; you can check the output you exported from Harmony.
- Double-check the
stage.xml
file, which was exported to the folder you specified when exporting from Harmony. Our default export path is to StreamingAssets, so it will automatically load in the game engine.
- Look in the Project tab, under Assets > StreamingAssets > HarmonyResources > [ExportName].
You’ll find the data that was exported. In this case, we’re looking for SpaceCat. Select the file marked stage
to load the data you want to double-check.
The text data appears in the Inspector.
The name to use for loading the object is the stage name. In this case, SpaceDuck_SpaceCatIdle
.
- If your GameObject has animation in it, and you want it to load the animation data from the Harmony export, add one more component by doing the following:
- Select the GameObject.
- In the Inspector, select Add Component and select Scripts > Harmony Animation.
- To loop the animation, you must set a GameObject to define it:
- Select GameObject > Create Empty and rename it: LoopAll.
- Click the LoopAll GameObject to display its properties in the Inspector.
- Click Add Component > Scripts > Loop All.
When you play the animation, it will loop as it plays back. The Loop All command simply iterates on all GameObjects on runtime and asks them to loop, which is useful when testing the animation. When programming the actual game, you should write additional scripts to control the different elements separately.