0
\$\begingroup\$

I know that this is a very old Unity issue. I'm doing a 2D pixel art rpg and I want to sprite swap whenever the player gets an armor (helmet,vest,boots...).

I created an empty game object and parented all armor game objects to it.

After a long research, I found the Unity Sprite Library Asset that can swap the sprites of a category. I have a helmet idle sprites and registering this to the sprite library, and I can successfully swap the head helmet. The problem is that when I animate this, I can't swap the sprites because the animation keyframes animates only one sprite. I don't really know how to use the sprite library asset to change not only the single sprite render but all the sprites in the animation (I have sprite for each keyframe because I update the sprite, I don't use things like 2D bones)

That's the idle player animation: Player idle animation

That's the hat animation. Hat animation

That's how I configured the equipment objects (sprite renderer): Equipment config

Is there a way to help with my code?

\$\endgroup\$
1

1 Answer 1

2
\$\begingroup\$

If I understand your problem correctly, you are trying to reskin your character with different visuals. In that case, using the Sprite Library Asset is a good choice because it will allow you to create animations once and they should work fine after swapping the visuals.

Looking at your screenshots, it looks like you are animating the Sprite reference directly in your Sprite component. This is not right, because when working with Sprite Library Assets you want to animate the Sprite Resolver component instead. That way, your animation will be correct even after swapping to a different Sprite Library.

For more information you can check out the documentation of the 2D Animation package here. Hope this helps!

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .