Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Swap out sprite sheets for existing animations on the fly?

Discussion in 'Animation' started by PixelPockets, Feb 21, 2023.

  1. PixelPockets

    PixelPockets

    Joined:
    Sep 7, 2020
    Posts:
    143
    I've been doing a bit of searching on this, and it looks like all of the sprite-swap methods that are covered in YouTube tutorials are done with animated rigs, and that's not what I'm after, as I don't use rigs. I briefly looked into using Addressable Assets, but I'm not exactly sure if this would work for my purpose..

    Here's what I need to do -

    So, currently, I am using state machines to handle all of my player/enemy states. In these states, I control the animations manually through code. All of my sprite sheets have frames, which animate the player/enemy.

    I need to be able to swap out a sprite sheet that has already been set up in an animation that is currently playing, with a new, identical-in-size (and frame sizes) sprite sheet, on the fly. I am basically adding "skins" to the player character.

    Is there a way to do this programmatically, in a way that doesn't cause performance issues?
     
  2. PixelPockets

    PixelPockets

    Joined:
    Sep 7, 2020
    Posts:
    143
    Looks like Animancer has a script that does this, so if anyone else wants to know how to do the above, get Animancer lite and grab the Sprite Swapping script. It works perfectly ;-)