Ligamen

Attachments

Bounding box

A bounding box is a polygon that you attach to a bone to mark an area of the character, such as a head, a hand or a whole body. It draws nothing in the final art. Its job is to give a game something to test against: a hit on the head box is a headshot, a hit on the body box is a normal hit, and a box on a sword is the danger zone of a swing. Because the box lives in a slot, it moves with its bone and can be shaped or keyed like any other attachment. This article shows how to create a bounding box, how to select it, how to move its vertices, what the panels tell you about it, how it takes bone weights, and how it follows an animation.

Edit Bounding Box

Creating a bounding box#

In the Tree, open the New... menu on a bone and choose Bounding Box. A dialog asks for a name; the suggestion starts with the bone name, and a number is added when that name is taken. Press Create and Ligamen adds a new slot under the bone, puts the box in it as the slot's attachment (see Slots) and selects it. The slot and the box share the name. You can also right-click an existing slot and choose New Bounding Box: the box is then added to that slot, next to the images it already has, and it becomes the setup attachment of the slot.

The new box is a square of 100 by 100 pixels with four vertices, centred on the bone's origin. Its vertices are stored in the local space of the slot's bone (see Bones), so rotating or scaling the bone turns the box with it. The Tree draws the box in its own row under the slot, with the box icon, and the type filter in the header of the Tree has a Bounding boxes entry that shows or hides these rows. Creating a box is one undo step.

Selecting a box#

A bounding box answers to a click only on its outline. The empty middle belongs to whatever the box surrounds, so the bone, image or mesh inside stays clickable and you do not lose it behind the frame. Hover the outline and the cursor shows the icon and name of the box; a click selects the slot and the box. If another object lies under the same spot, a second click in the same place selects it, and the next click cycles on.

In the Tree, the Display row of the box card has a Select toggle. When it is off, the box can no longer be picked in the viewport, which is useful once the box is placed and you want to work on the art around it. The card also has Options with an Export toggle: when Export is off, the box stays in the project but is left out of the exported files. The Color plate sets the colour that draws the box in the editor; the default is a bright green. The colour is for your eyes only and has no effect in the game.

Editing the vertices#

A new box opens in Edit Bounding Box at once. For an existing one, select its row in the Tree and press Edit Bounding Box in the Tree card or in the toolbar at the bottom of the viewport. A card with the same name appears in the viewport. It works only in Setup mode, and while it is open the vertex handles are drawn on the outline.

Drag a handle to move a vertex; the whole drag is one undo step. Double-click on an edge to insert a vertex at that point, and double-click on a vertex to delete it. Create turns on a mode where every click on empty space appends a vertex at the end of the polygon, and the new vertex is selected. A click on an existing handle still drags it. The Delete button removes the vertex you picked last, and the status bar asks you to click a vertex first if you have not. A box needs at least three vertices, so the last three cannot be deleted. The polygon does not have to be convex, but keep it simple: a few vertices that follow the shape are cheaper to test in the game than many.

New in the card adds one more bounding box to the same slot and asks for its name, and Vertices: shows the current count. Leave the mode with the cross in the card, with Esc in the viewport, or by pressing Edit Bounding Box again. Selecting something else in the Tree or switching to Animate leaves it too.

What the panels show#

The Properties panel (see User interface) has a Bounding box section with the Name of the box and the Slot it lives in, and a Shape section with three read-only values. Vertices is the number of points, Bounds is the width and height of the box in pixels, measured in the bone's own space, and Weighted says whether the vertices carry bone weights. These are facts for checking; to change the shape, edit the vertices as described above.

The card at the top of the Tree repeats the name, the Display and Options toggles and the Color plate, and it has the Edit Bounding Box button. For a box whose vertices are weighted, Bounds shows Weighted instead of numbers, because the vertices no longer sit in one bone's space.

Weighting a box#

A bounding box can be weighted to several bones, the same way as a mesh (see Weights). This is how a box follows a bending arm instead of a single rigid bone. Select the slot of the box and open the Weights panel; its tools work here too, with the box vertices in place of mesh vertices. Auto computes a first set of weights from the nearby bones, and Smooth and the brushes refine it. The Weighted value in Properties then reads, for example, 2 bones (arm, hand).

The vertices of a weighted box stay editable in Setup mode. You drag them in the viewport, and Ligamen works in world space: the dragged vertex keeps its weights and is rebound at the new position, a vertex you insert takes weights interpolated from its neighbours, and the other vertices stay untouched. Edit Mesh is for meshes only; boxes are always edited with Edit Bounding Box.

Animating a box#

In Animate mode (see Animating), a bounding box follows its bone like any attachment. If you want the shape itself to change, for example a hit box that grows during a punch, select the box and drag one of its vertices. This records a deform key (see Keys) on the timeline, as it does for a mesh. Between keys the shape is interpolated, and the hit test follows the animated shape, so a click always meets the box where you see it. The vertex tools of Edit Bounding Box are for Setup only; in Animate you drag the vertices of the selected box directly.

Weighted boxes and their deform keys are written to Spine JSON, to the binary skeleton and to the Unity package, so a game can use the same polygon that you see in the editor. A box with Export off is left out of all of them. Keep the setup shape as the resting state of the box and key the changes in the animation, so that the box returns to the setup shape when no key applies.