• Editor
  • Toggling slot bounding boxes mid animation

Related Discussions
...

Hi I have a variety of weapons and want to switch both the graphic and the bounding box for the weapon programatically.

I do this currently using two slots on the left hand:

"weapons" slot (contains graphics for each weapon)
"weapons_boundingbox" slot (contains bounding boxes for each weapon)

1.) Is this the best way to set up my file?

2.) I would like to only enable the bounding box for the weapon on specific frames of the "attack" animation, so for example when fully extended in frames 8-12, but not to be enabled during the swing before frame 8 or after frame 12.

Is there a way to accomplish this in Spine? It seems that changing these values mid-animation don't change the data in the JSON file at all, whether making the bounding boxes slot active/inactive on those frames or the individual bounding box itself.

Hello Volte6,
since you posted in the editor section, I'll answer the editor part:

  1. yes! since only one element (be it an attachment or bounding box) can be active at the same time within the same slot, this setup is great

  2. bounding boxes can be keyed and animated Bounding Boxes - Spine User Guide so you can make the attachment you need active at the desired frame, then switch it off at the other frame.

Important note: you need to switch the attachment/bounding box off, not the slot. slot visibility is there only to unclutter the view in the editor but has no effect at runtime.

You might want to place these attachments inside a skin placeholder, and programmatically populate the skin placeholder at runtime: Skins - Spine User Guide: Combining skins