Forum rules - please read before posting.

Resetting a Char's Animator reference at runtime

Hi,

I'm using Spine through the Animation Engine "Sprite Unity Complex". I want to use multiple animations to support different directions. So far I found two ways to achieve it:
  1. Add an Animator and a Skeleton Animator to the SpriteChild, plus a script that changes the Skeleton Animator's Skeleton Data on direction change.
  2. Add to the Player object a SpriteChild per direction, each containing an Animator and a Skeleton Animator, plus a script in the Player to switch the SpriteChild reference when the direction changes
It turns out that method 1 is not good because the character flickers when the Skeleton Animator is reinitialised with the new Skeleton Data.
Method 2 works but requires changing the SpriteChild and Animator reference of the Player.
The SpriteChild can be easily changed, as the property is public. However, there seems to be no way to change the Animator, so I added the following method to Char.cs:

public void ResetAnimator ()
{
     _animator = null;
}


This causes _animator to be set to the active SpriteChild's Animator the next time Char#GetAnimator() is called.
Is there any better way to do it? Otherwise is it possible to officially add the ResetAnimator() method?

Thanks!
Alberto

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.