Alternative to IK for lots of enemies

Morning,

I currently have animations on my enemies using IK, and it looks great.

The issue is that towards the end of each round there are 100’s of enemies, and some of my testers are reporting frame drops.

The profiler confirms that it is the IK nature of animation.

What is the alternative to this? I want to have high quality, high FPS animations that seamlessly blend between states.

Is this possible with sprites?

I read about “Baked” animations, would this be the road to look down?

Thank you.

Hi @Deridealized!

Using IK is great if you need your character parts to move to precise positions that change in runtime, e.g. hand reaching out for an item, foots touching the ground at specific point, etc.
With hundreds of dynamic characters you are sacrificing lots of performance to get that precision.

You can still blend between animation states and have high FPS animations with baked animations for Sprites.

To clarify, are you using the IK Manager 2D or some other system for your IK?

If you are looking for ways how to “bake” the IK animation to pure bone transform animation you could try using tools from Animation Rigging package. It is a 3D rigging package, however it might help you in case you use simple Limb solvers.

The closest equivalent to the Limb solver is the TwoBoneIKConstraint. After you record your animations using Rig Builder, Rig, and your TwoBoneIKConstraint, you will be able to bake it using the bidirectional motion transfer feature.

I’ve recorded a short video of how this could be done here.

Hi Marek,

Apologies for the delayed response!

I am indeed using the IK Manager 2D.

I’ve watched your video and this looks great, so does this remove alot of the performance overhead for these animations? Is this still usable for swapping from one animation to another mid animation? for example if you kill an enemy when they are mid run, will it “skip” to the death animation, or will the limbs move there?

Thank you for such a detailed reply!

Yes, you would not have the IK Manager overhead when you use baked animations and disable IK solvers.

If you are using an Animator to animate your character, then you can place different animations in their own states, and set the blend time in the transition between these states.

I recommend that you check the The definitive guide to animation in Unity - it’s a recent e-book that contains lots of useful informations about animating things in Unity, all in one place.

I hope this helps!

1 Like

Amazing, thank you very much indeed.