đź““

AnimationManager

public class AnimationManager
{
    public SpriteRenderer spriteRenderer;
    //work with 1 of these:
    //Matts animation system
    public List<SpriteAnimation> animations = new List<SpriteAnimation>();
    public int currentAnimation = 0;
    public int currentFrame = 0;
    public int frameTimer = 0;
    //or
    //Unity's animation system
    public AnimatorManager animatorManager;
//...

This is the main class to rely on for your NetworkEntity animations. You have to pick 1 of 2 ways to use it. Either use my custom animation system (extremely predictable frame based animation) or Unity’s animator wrapper approach(uses floats, so slightly less predictable).

Methods

public void Update()

Progresses the current animation by 1 frame. Looping animations will roll back over to the start if they reach the end of their animation

Note: This is not a MonoBehaviour. So the Update function is not called automatically. Its intentional. When entities are updated, you should update their AnimationManager too at that time. This ensures predictability, especially with rollbacks.

public void SetCurrentAnimation(int a)

Set current animation by index. Will use first animation if it cant find it

public void SetCurrentAnimation(string name)

Set current animation by animation name. Will use first animation if it cant find it

public void SetCurrentAnimationIfNotCurrentAnimation(string a)

Set current animation by animation name. Only swaps animation if its not the current to prevent relooping the same animationn. Will use first animation if it cant find it

public string GetCurrentAnimationName()

Gets name of current animation or “” if no animations

public bool DoesCurrentAnimationLoop()

Does current animation loop? True/False

public bool IsAnimationFinished()

Returns if an animation finished. Always returns false if its a looping animation

public void UpdateSprite()

Updates the sprite renderer with the correct animation frame

public void SetSpriteToSpecificAnimationFrame(int animation, int frame)

Update sprite renderer to use a specific frame from an animation

public SpriteAnimation GetSpriteAnimation(int index)

Get SpriteAnimation by index, or null if there is no match or you are using Unity’s animation system