← Back to all addons

Character Attack Animation Trigger By Ability

Posted by Mr.Titan on Sep 21, 2025 at 8:31 PM

ExperimentalFeature3.0 Verified
💡 4 ❄️ 1

You can set a different animation for each of your abilities, since most of the time you have an ability per type (projectile, sword, punch).

In the video i’ve used the “invisible” animation just for showcase.

Update IAnimationStrategy.cs

Add the following method:

        bool PlayAnimation(string animationKey);

Update AAnimationStrategy.cs

Add the following:

        // Avoid checking the same key over and over; instead, store the value when evaluated
        private readonly System.Collections.Generic.Dictionary<string, bool> m_animationParameterCache = new();


        public virtual bool PlayAnimation(string animationKey)
        {
            if (string.IsNullOrEmpty(animationKey) || m_animator == null)
                return false;

            bool hasParameter;
            //avoids checking the value constantly, instead stores it's value the first time
            if (!m_animationParameterCache.TryGetValue(animationKey, out hasParameter))
            {
                hasParameter = AnimationUtils.HasParameter(m_animator, animationKey);
                m_animationParameterCache[animationKey] = hasParameter;
            }

            if (hasParameter)
            {
                m_animator.SetTrigger(animationKey);
                return true;
            }

            return false;
        }

Change AbilitySheet.cs

Add after the “m_orientationMode”:


        //AFTER THIS: [SerializeField] private EAbilityOrientationMode m_orientationMode = EAbilityOrientationMode.Polydirectional;
          //ADD THIS:
          [SerializeField] private string m_casterAnimation = "attack"; //YOU CAN SETUP YOUR DEFAULT ANIMATION KEY HERE INSTEAD OF "ATTACK"

        //AND ADD THIS TOO:
        public string casterAnimation => m_casterAnimation;

Note: If you leave this empty it will play no animation, maybe its better for most cases? I leave you decide

Change CharacterBase.cs

In the method public EAbilityFireCheckResult FireAbility(ITriggerableAbility ability):

//AFTER THIS
//if (isAbilityStateAutomaticallyManaged)
//{
//    abilityBase.gameObject.SetActive(true);
//    ability.Fire(() => abilityBase.gameObject.SetActive(false));
//}
//else
//{
//    ability.Fire(null);
//}

//ADD THIS
  m_animationStrategy.PlayAnimation(abilityBase.abilitySheet.casterAnimation);

[PRINT TO SHOWCASE]

Setup Animations

  1. In AC_Character open it
  2. On the top left side of the window you’ll find a Parameters tab, create a a trigger option an name it your attack (the same you setup in the AbilitySheet…. the default i gave you in the code was attack - IT’S IMPORTANT THAT YOU IT HAS THE SAME NAME)
  3. Create a clip and setup all the changes, and assign it to the animator and make the proper connections where you should have the condition has “attack” [image showcasing]

So the ability whenever triggered, the CharacterBase will get the “casterAnimation” from the ability, and check if it’s animator has this trigger, if it does then triggers the animation clip you setup

That’s it

💬 Comments (19)

Deleted User Sep 21, 2025 at 10:58 PM
You’re actually cracked bro, always droppin heat
Deleted User Sep 21, 2025 at 10:58 PM
❤️
BellBlitzKing Sep 23, 2025 at 04:07 PM

@Mr.Titan I have Attack Animations you can use to help this grow! Sword, Staff, Wand, Shield, Short Bow, Long Bow—anims in the Pixel Art Sprite Mixer with M2D export.

https://kingbell.itch.io/pixel-sprite-mixer"

❤️ 3
Mr.Titan Sep 23, 2025 at 04:09 PM
Nice! I’ll check that later to give an example!
Zuko Sep 23, 2025 at 08:19 PM
How did you make this!!!??
Zuko Sep 23, 2025 at 08:19 PM
Insane
Zuko Sep 23, 2025 at 08:19 PM
i need this so badly in my game
BellBlitzKing Sep 25, 2025 at 04:27 PM
@Zuko It’s free Anims. Use the link above the image. You can customize those anims further for Mythril.
❤️ 1
Zuko Sep 25, 2025 at 04:28 PM
Thanks man, you`re the best!!!
Mr.Titan Oct 05, 2025 at 06:46 PM

Then you end up with a network like this

Mr.Titan Oct 05, 2025 at 06:50 PM

Using my new “bow” animation

🔥 3
JP Oct 11, 2025 at 07:15 AM
Looks great !
Nolyn_Bittle Dec 20, 2025 at 03:08 AM
Mine stays stuck on a single sprite (usually idle frame 1 or attack frame 1) when i try and add any state or trigger to the animator have you ever ran into that?
Ganz Feb 15, 2026 at 12:04 AM
hi @Nolyn, I’m also experiencing this now. Did you find a solution to the problem?
Zuko Feb 15, 2026 at 01:12 AM
there are other ways to achieve this, what exactly u atr trying to pull off here?
Ganz Feb 15, 2026 at 01:41 AM

hi @Zuko, right now i’m just trying to follow the steps in this (edit: add-on) tutorial. I’ve set up the “Attack” state like in the picture, but the character stuck on a single sprite just like Nolyn had.

I just found out that if I used a motion provided by the demo (eg: ANIM_Character_Hit), it works as intended (no stuck on single sprite). Something might be wrong on how I make my motion, can you share a tutorial on how to make a motion to work on Mythril? I’m new to Unity. I’ve followed the tutorial here https://youtu.be/4xPHqEEa-V0?si=aEP2lv_HXFKGG6XO&t=143 minute 2:27

Zuko Feb 15, 2026 at 01:49 AM
i have sent u a dm
Ganz Feb 15, 2026 at 05:00 AM

Ok, with help of Zuko, I’ve found that the demo animation clips are using “Sprite Key” property, but whenever I create a new animation clip, I always add the sprites to “Sprite Hash” property. I think it’s because I’m using newer Unity?

In Unity, the difference between "Sprite Key" and "Sprite Hash" for the Sprite Resolver component is a matter of version compatibility and asset upgrade paths. 
- "Sprite Key" was the property used in older versions of the 2D Animation package (around Unity 2021 and earlier versions of the package) to animate the sprite.
- "Sprite Hash" is the new property introduced in later versions (around Unity 2022 and later package versions). 

We can’t mix the “Sprite Key” and “Sprite Hash”, so I recreate all the demo clips again, and it works as intended now. Thanks!

❤️ 1
Zuko Feb 15, 2026 at 03:15 PM
your welcome mate!

Want to continue the conversation?