|
| 1 | +--- |
| 2 | +title: Stacking Rigs |
| 3 | +description: Learn how to stack rigs on top of each other to create dynamic models. |
| 4 | +--- |
| 5 | + |
| 6 | +# {$frontmatter.title} |
| 7 | + |
| 8 | +{$frontmatter.description} |
| 9 | + |
| 10 | +## Introduction |
| 11 | + |
| 12 | +"Stacking" is a term used to describe the process of mounting multiple entities on top of eachother. |
| 13 | + |
| 14 | +Using [Locators](/docs/the-blueprint-format/locators) and their [Use Entity](/docs/the-blueprint-format/locators#use-entity) and [On-Summon Commands](/docs/the-blueprint-format/locators#on-summon-commands) properties, you can stack multiple rigs on top of each other to add dynamic parts to your model. |
| 15 | + |
| 16 | +## Tutorial |
| 17 | + |
| 18 | +Let's take an existing rig (`body`) and stack our head rig (`head`) on top of it. |
| 19 | + |
| 20 | +1. Inside of your `body` rig, create a new [Locator](/docs/the-blueprint-format/locators) named `head_locator`. Position this Locator where you want the head to be mounted. |
| 21 | +2. Open up `head_locator`'s config and configure the following properties: |
| 22 | + |
| 23 | + 1. Enable `Use Entity` |
| 24 | + 2. Set the `Entity Type` to `minecraft:item_display` |
| 25 | + 3. Set `On-Summon Commands` to |
| 26 | + |
| 27 | + ```rust |
| 28 | + function animated_java:head/summon {args:{}} |
| 29 | + ride @n[type=item_frame,tag=aj.head.root] mount @s |
| 30 | + ``` |
| 31 | + |
| 32 | +3. Save and [Export](/docs/getting-started/exporting-your-blueprint) both rigs. |
| 33 | +4. In Minecraft, reload your Data Pack and Resource Pack. |
| 34 | +5. Run `/execute rotated 0 0 run function animated_java:body/summon {args: {}}` to summon your body rig. |
| 35 | +6. You should see the head rig mounted on top of the body rig. |
| 36 | + |
| 37 | +From here, you can use your own commands to adjust the `head` rig's rotation as needed. |
| 38 | + |
| 39 | +:::admonition type=info title=Example |
| 40 | +To match the `head` rig's rotation to the `head_locator`'s rotation, you can add the following command to the `head_locator`'s [On Tick Commands](/docs/the-blueprint-format/locators#on-tick-commands): |
| 41 | + |
| 42 | +```rust" |
| 43 | +rotate @s ~ ~ |
| 44 | +``` |
| 45 | + |
| 46 | +Or, if you wanted it to face the opposite direction: |
| 47 | + |
| 48 | +```rust" |
| 49 | +rotate @s ~180 ~ |
| 50 | +``` |
| 51 | + |
| 52 | +::: |
| 53 | + |
| 54 | +## Common Issues |
| 55 | + |
| 56 | +### The `head` rig falls behind the `body` rig when moving. |
| 57 | + |
| 58 | +1. Open up the exported Data Pack, and locate `datapack/animated_java/data/animated_java/tags/function/global/root/on_tick.json`. |
| 59 | +2. Make sure the `head` rig's `on_tick` function is listed _after_ the `body` rig's `on_tick` function. |
| 60 | +3. You can manually reorder the functions in this file, or rename the `head` rig to `z_head` to force it to be listed last. |
0 commit comments