Skip to content

Aseprite animation frames are imported incorrectly (backwards, ignoring tags) #311

@rasgou

Description

@rasgou

I have a tsx file set to "Collection of Images", where each "tile" is a reference to an .aseprite file. Unlike a regular tileset, this one is meant for object layers, where I'll just put a reference to a "tile" object positioned in the map. My intention would be to locate it and replace it in code by whatever my corresponding custom prefab would be for that tile's class.

Anyway, v2.4.0 solved some errors with importing aseprite files, but it's still wrong in several ways:

1. The animation frames are being imported in reverse order.

This makes the animation play backwards!
Also the reference frame for the sprite displayed in the scene ends up being the last frame instead of the first one like in Tiled.
I dunno if that makes any difference, but my .aseprite files are created in LibreSprite v1.2-dev (Flathub).

2. The aseprite tags are being ignored.

If an aseprite file has multiple tags, each tag is meant for an animation pose (e.g. Idle, Walk, Jump, etc.) and in fact Unity's importer makes a different Animation Clip for each tag.
This importer is playing all frames, ignoring clip boundaries, which is (arguably) never really useful.

  • If you're going to animate it, it's better to play just the first tag if there's any (usually the "idle" or main pose) so at least the animation loops in a way that makes sense for the placed object.
    Or somehow let us to select a tag we want or all frames (though this would be better if it was supported in Tiled editor itself).
  • Don't forget to also implement support for the different directions (Forward, Reverse and Ping-Pong) in the tag.
  • If there are no tags, then sure, play all frames.

3. Should it even animate aseprite files at all? It's better to support Tile Animation Editor instead!

Tiled has its own animation editor! But it seems that's not supported by this importer yet?
EDIT: nevermind I guess it's supported and I didn't notice, my bad.

Details

You can animate a tile by manually selecting other tiles as its frames, so it appears animated in the tile map in Tiled. It would make more sense for the importer to reflect whatever this Tiled animation is in Unity, regardless of file type.

Currently, Tiled (v1.12.2) does support aseprite files but not their animations. Only the first frame is read. So the more logical way to match Tiled for now is... not animate it yet until supported?

  • Ideally, Tiled should somehow support making its animation frames automatically from the file when it has no custom frames (e.g. from gif, and from aseprite, preferably by letting the user select a tag).
  • Then this plugin should follow Tiled with the corresponding support, but animations should come from Tiled's animation data, regardless of if it's from aseprite, gif, or manually edited frames from PNGs in its animation editor.
  • Until then, it should be fine to animate aseprite when the tile has no custom animation frames. If one or more frames are added, then match Tiled animation instead of aseprite animation.

On a deeper inspection, I understand now that I'm supposed to use the "Prefab Replacements" feature for more complex cases of animations with multiple poses. So (2) and (3) are minor, I guess.

But if we're automatically doing animations for the simpler case, at least it should be useful, and pick a single tag if there are tags, or better yet, just correspond to whatever animation is shown in Tiled via its own animation editor; and if that's not enough, then the user is expected to use prefabs (like those made from Unity's own aseprite importer).

4. Support prefab mapping for the custom classes in .tiled-project files

On that note, this plugin could support .tiled-project files to read the Custom Types Editor directly to map classes, instead of having to export a objecttypes.xml every time. The class->prefab mapping could be set on that file's importer instead of on project settings!

So it would automatically list all custom classes added from Tiled when selecting it in Unity inspector, and allow to assign a prefab to each detected class name.

Any tileset and tilemap that belongs to that .tiled-project (i.e. located under a folder listed on that file's JSON) should use those settings.

This would make the prefab replacement feature much more discoverable than now, where it's under Unity's project settings, kinda hidden.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions