AHAKuo

Hi there, I'm developing a game in which the main character has two modes. A small size, and big size (check photo). And in both of them, the animations are all the same name, all the same parameters and the same code controls them.

I have achieved the switch I'm looking for, but it causes a small spike in performance each time it is called, and I'm wondering if there's a way to do it better without the performance loss.

Preview:
unknown.png


The code I'm using to make it work is this:
if (playerInput.Spider())
{
if(skeletonMecanim.skeletonDataAsset == BigNeon)
{
skeletonMecanim.skeletonDataAsset = SmallNeon;
skeletonMecanim.Initialize(true);
animator.runtimeAnimatorController = animatorControllerNeonSmall;
}
else
{
skeletonMecanim.skeletonDataAsset = BigNeon;
skeletonMecanim.Initialize(true);
animator.runtimeAnimatorController = animatorControllerNeonBig;
}
}
Any help is appreciated!
Nemaš dopuštenje za pregledavanje privit(a)ka dodan(og)ih postu.
AHAKuo
  • Postovi: 5

Jamez0r

Hey AHAKuo, cool character :grinteeth:

Two options that you could try:

1) Have two SkeletonMecanim components - one for each version of the character. Then enable one and disable the other as needed when the character switches forms.

2) Combine both versions of the character into a single Spine project (skeleton), and use Skins to switch between the two. Note that Skins can have their own bones: Skins - Spine User Guide: Skin bones
Avatar
Jamez0r
  • Postovi: 358

Harald

Thanks @Jamez0r as always for answering! :)

@AHAKuo Please note that skeletonMecanim.Initialize(true) comes with quite some overhead, as it re-creates the skeleton hierarchy, re-applies the respective skin, and so on. So we would highly recommend to use any of the two ways suggested by Jamez0r.
Avatar
Harald

Harri
  • Postovi: 4088


Natrag na Unity