Defining "Sprite Pivot Point" and "Looping" for animations in games

Hello, everyone!

Aseprite has aided me greatly in producing assets in a timely manner, however, I’ve found two things to be missing:

  • The ability to expose a “Sprite Pivot Point” for a spritesheet in the .json-file
  • The ability to expose a “Loop” field for each animation in a sprite in the .json-file

My Use Case

I’m a programmer and an artist. I’m developing a 2D game in Unity and in my opinion, its animation tools are poorly suited for sprite-based animations, so I’ve written a custom Sprite Animator and an Unity-Editor Extension for it. With the spritesheet and .json-file created by Aseprite, the extension creates an “Animation Container” that my custom Animator references (“which sprites belong to which animation”, “duration of each frame”, etc. …) – all with the click of a single button.

Sprite Pivot Point

As much time as my extensions saves me, this one-click-solution is limited. I still need to work with Unity’s built-in Sprite Editor, cutting out the spritesheet and assigning a pivot point for each frame of the animation (for instance, in a sidescroller game you might define the pivot to be at the feet of a character.)

While Unity allows the user to cut out the sheet automatically/based on parameters, my goal is to completely skip the step of having even to deal with the editor. All I need for that is the ability to read the pivot point from a file.

Meta%20Pivot

That way, I could cut out the sheet and assign the pivot just by using code. I’ve temporarily circumvented this problem by creating a new “Animation Tag” for my Sprite and storing the pivot coordinates in there.

While this gets the job done, it feels dirty and is far from intuitive.

Implementation

Maybe you could have a “Pivot Tool”, which lets you pick a pixel on your sprite (similar to the color picker). That position is stored in the .ase file and, when it comes to exporting the spritesheet, that value gets inserted into the meta-block of the .json- file (if no value is picked, it will default to {0, 0}). That’s just off the top of my head, though.

"Loop" Field

Animations in my game know whether they are supposed to loop (i.e. a walking-animation) or only play once and then change to another animation (i.e. an attack- animation goes into an idle-animation). For this purpose I’d like another field exposed in the .json meta-block, which allows me to parse that data.

Meta%20Pivot%20Loop

Currently, I’m solving this by prefixing looping animations with “L_”.

Implementation

I’m imagining the “Animation Tag” window has a “loop”- checkbox that can be ticked.

Thank you for reading this lengthy post! I hope I was able to make my goals clear and explain why I and others could benefit from those features. While my particular problems stem from the use of Unity (perhabs a clever solution just eludes me), I could see these points be valid in other game-making scenarios as well. Aseprite has become my go-to source for making animations and integrating them into games. I love how it packages all the relevant data in a .json file and I feel like this could be extended even more in the future.

1 Like

I’d really like both of these features too!

I currently get around their absence by encoding the loop bool as “Loop_” at the start of the tag name (looks like @Salem does the same with L_ hehe), and by having a layer with my hitbox and pivot drawn and adding the pivot data in an external tool using that layer as reference.

I second (or it third) this! Being able to have “loop” in addition to forward, reverse and pingpong would be a huge time saver.

I had the same need to store custom pivot pixels. The Aseprite importer MetaSprite lets you define a layer as a pivot layer, and pixel(s) in it define the pivot point. I’ve improved it a little to let you add any store as many layers of coordinates as you want with MetaSpritePlus.

In case someone else comes to this thread - using *.aseprite file importer seems to be the way for now. It’s fairly easy to port the importer from MetaSprite to C++ or any other language, it’s pretty well written. I went with the similar way, using group “@points” in which every layer specifies single point (sprite pivot, hand locations, etc). Just use cel’s position.

Also, in case you need it, every cel is compressed using zlib, if you want to use “uncompress” function you’ll have to include 4 byte header and footer with hash, skipped in MetaSprite.

1 Like