Chromokun Logo
Published on

Random Stuff I Learned - Part 2

Authors
  • avatar
    Name
    Devin T
    Twitter

Spine Gotchas

We use Spine 2D for our animations, and it's been really great. However, I ran into a few things that really frustrated me until I figured them out.

Importing assets

The first is more of a Unity Gotcha, but man is it annoying. When you import a new asset into Unity, you can just drag it into the Editor and it will import it. Great! But say H. sends me a new animation and I want to update it, just drag it in again, right? Nope, that'll import a new asset appended with "1". Instead, you need to replace the underlying file outside of Unity, and Unity will (usually) pick that up and re-import the changes.

Sometimes when you do that the change isn't picked up. I'm not sure why, but I'd pull in a new animation and everything would be rendered incorrectly. H. and I would spend a few hours pulling our hair out until I give up, drag a new copy of it into the Editor (creating a new asset), and update the entire game to use that one instead. H. still has trauma making large updates to animations due to this.

I still don't know why this happens, but I did learn you don't need to drag in a new asset. If you right click on an Asset in Unity, there is a "Re-import" option. If for whatever reason the change detection that triggers automatic re-import fails, you can just trigger it manually.

Animation events

Another gotcha I ran into is using Spine callbacks. They have various handy callbacks to do things in response to the animation lifecycle. Here are some nice docs they have on it. When I started using them I did not read the documentation. You really should read the documentation.

I needed to chain animations together, for example, in Spine, most of a players turn is essentially a series of animations playing, back to back. When one ends, we want to trigger the next one, and so on. With a bit of logic in between. No problem, I say, I'll use the "End" callback, and start the next animation when this one ends. Nope, big problem, it turns out when you play a non-looping animation and it gets to the end, it doesn't actually "End" in spine, it just continues playing the last frame until the next animation plays. Ok, no problem, I'll use "Complete", that seems to be what I want, well no, that only triggers when an animation fully completes, but sometimes I interrupt my animations, and it never fires. Once I found (and actually read) the documentation, I got it working. (The key is to use "End", but just make sure the animation actually ends, either by clearing the track or playing an empty animation afterward).

Mixing

We don't use much mixing on our project, so I don't fully understand the nuances of it. At a high-level: it's a standard animation feature that helps you transition from one animation to another by running a "blend" of the two for a bit as it transitions. But the "gotcha" here is basically just: If something is acting oddly in an animation, it might be due to mixing two animations that don't blend well together, or mixing them from the wrong places. We really noticed it when accidentally mixing some animation from its "end" position to a "start" position very far away from that. You end up with mixed values somewhere in between, and it looks very strange.

Spine turns mixing on by default, so we'd run into this fairly often. We ended up turning mixing off by default, and turning it on when we felt it would be useful. We still have a lot to learn about when and how to effectively use mixing.