Production > Animation > Gaming Guidelines > 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 out. 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.

To set a target to a part of your character, first add a new Game Object to extract the position, rotation, and scale of the target. Select Game Object > Create Empty.

Now drag and drop the new object so that it's a child of your character. It will become indented. You should also rename it, in this case it is named Hook Gun.

In the Inspector of the target object, select Add Component > Scripts > Harmony Locator.

There’s only one parameter that needs to be entered here, and this is the name of the drawing layer that you want to attach to.

To find the exact name for the Locator Name, take a look at the skeleton.xml file located in the Streaming Assets folder. You can find it in Streaming Assets > Harmony Resources > Name of Harmony File > skeleton.

This lists all the drawing layers and peg layers. In our case, we have one that we’re looking for called space_duck_hook_gun. This is why it helps to name drawing layers with distinctive names, so you'll recognize them when you need to retrieve them later on.

If you copy the name of the layer into the Locator Name, then you should see the Transform information updating dynamically as you run the simulation.

Now you can attach anything as a child of this Locator Object. For testing purposes, you could attach a cylinder for example. In a real example, you’d want something to shoot out of the end of the gun, so you can see the Callback example to verify how that works.

Bounding Boxes and Collisions
Working with Audio