1
votes

I created a 2D sprite animation using the 2d animation package and the 2D Ik package. My character is one sprite sheet (PBS file). In the PBS file all the spites (eyes, mouth, etc, - character is basically a square with a face) are arranged and bones are attached. Then I animated the character's idle animation in Unity.

The animation is complex and is a total of 1028 frames (about 17 seconds).

The scene is almost empty otherwise. There are a few sprites with colliders and rigid bodies for simple platforms. There is a background image which is 1024 px. x 1024 px.

In play mode the FPS drops down to around 30 FPS (and under).

I have another scene without the animation but with a HUGE number of assets (for a 2D scene hundreds of sprites and many of them constantly in motion). This scene runs at 210++ FPS consistently.

Why does this one animation kill the FPS? I'm just getting started with creating animation for all the characters. If I add similar animations to NPCs in the scene (enemies) then this thing will probably not function at all.

Any suggestions are appreciated.

enter image description here

2
Open Unity Profiler and see what takes more cpu time during the gameplay.VisDesign
The profiler show that the animation is taking up most the CPu resourse and second place is vsyncFatMunkey
Can you show us a picture of it?VisDesign
Added a link of the image for the profiler. BTW, I have been thinking of buying Spine. would that provide better performance? Maybe export the Spine keyframes as a sprite sheet or sprite atlas?FatMunkey
To me it seems the script is causing it. I dont know maybe the blue color does interfere.VisDesign

2 Answers

3
votes

For anyone having the same issue, make sure you have Burst and Collections packages installed (via the Package manager), it extremely improves the performance of 2D Animation.

1
votes

So I spent a couple of days this week and created sprite sheet animations to replace the skeletal animation I made in Unity. As I suspected, the performance is light years ahead. I have MORE animations now and some of them are as long as 270 frames. Yet I consistently see greater than 220 FPS. It's too bad that unity's 2D animattion package is so slow. To accomplish the same animation I was looking for, I ended up rigging and animating my character in Blender 2.8 using Andreas Esau's COA Tool (Cut-Out-Animation Tools) Add-On.

COA Tools is an awesome tool but I wish it could export a rendered sprite sheet to Unity. I ended up exporting each frame as a separate image and using TexturePacker to make the 2048px square sprite sheets I needed. Once I got the sprite Sheets into unity I was able to quickly set up animation clips and test it out.

As I said, the sprite sheets are far and away better than animation created directly in Unity.

If you bothered to read all the comments on my original post, I will say that there are a lot of scripts running and a lot of computation happening. It is there in the profiler for sure. But this was definately not the main culprit for taking down the FPS. It was absolutely the animations.