Production > Animation > Gaming Guidelines > Export Harmony Animations to Unity > Placing a Target in an Imported Animation

Placing a Target in an Imported Animation

It’s possible that after importing the Harmony animation into the Unity scene, you may want to assign a target to some piece of the animation. For example, in the Space Duck scene, the character has a gun. Perhaps you want to attach some other action, such as shooting spheres and cubes out of the end of the gun.

You can see some examples of this in the provided Unity project. The first example in the demo scene is called DemoLocator which shows a simple cylinder attaching to the end of the gun.

The second example called DemoCallback shows the gun shooting spheres and cubes.

When you set up your character in Harmony, you can access any drawing layer in Unity later and use its pivot point to attach things. For this reason, you should set the pivot points on your drawing layers with the Rotate tool.

You can also create an empty drawing layer. Use Create Empty Drawing to create a blank drawing, ensuring that this drawing layer will be exported. Then you can use the Rotate tool to set the pivot point on this drawing layer. In the Space Duck example, an empty drawing layer called hook_gun was created on which you can attach the locator.

When you access the imported Harmony character in Unity, you can access the data with a script.

Bounding Boxes and Collisions

Extracting the bounding box information is useful when you want to make something collide with your character. When you put a 2D character into a 3D scene, you may want to use Physics to make the 2D character collide with the 3D plane. To use the following scripts, you will need Unity 4.3 or higher.

In the Demo scene, open the DemoPhysics example to see collisions and bounding boxes. In this example, there’s a 3D plane and some 2D characters. The 2D characters have a collision defined with their bounding box, and they're also reacting to the physics of the scene to fall with gravity.

Colliders were improved to provide several different types of colliders for use in Unity. You can select polygon colliders and box colliders for a more accurate bounding box.

NOTE: You can also use 3D physics on the imported files.

You can now adjust the variables and see the results.

Working with Audio

When you create scene files in Harmony with audio, the audio is exported into the project folder. However it’s important to understand how the game is built to determine the best way to handle audio.

When a game is built from Unity, it creates its own database for holding the assets. Within the export, the Streaming Assets folder is preserved intact. This is what enables the Toon Boom plugin to access those assets on the fly, and render them in the camera to create the final animation you see on the screen.

However when it comes to audio, the game first looks for the audio in the Unity database. So this is the most efficient place to store the audio for the real game.

If audio can't be found in the Unity database, then the game looks in the Streaming Assets folder to find the audio. When it does, it copies the audio on-the-fly back into the Unity database. Since this action is quite costly, don’t leave the audio in the Streaming Assets folder for the final game. It’s fine to leave it there while you’re testing, but not for the final game.

The audio should be copied back into the Unity database, either manually or by automating this process with a script.