• RuntimesUnity
  • Animation not found. Parameter name: animation name

  • Изменено

I added on my projectile spine game object as a child, added link to this object in my script. I'm trying to get component and set animation but unity returns an error.

[SerializeField]
    private GameObject _spineAnimator;
    [SpineAnimation]
    public string _onDeadAnimation;
public override void OnDamageDeal()
    {
        Spine.AnimationState skeletonAnimationState = _spineAnimator.GetComponent<SkeletonAnimation>().AnimationState;
        skeletonAnimationState.SetAnimation(0, _onDeadAnimation, true);
        //Destroy(gameObject);
    }

https://disk.yandex.ru/i/N77dH_Le996cRA
https://disk.yandex.ru/i/F75d61TyyVCEow
The object has this animation but unity can't find it. What the reason?
Can Sceleton Utility be the obstacle for it?

Related Discussions
...

@sxweb When does this exception occur? At runtime, or when you are selecting animations in the Inspector?

Could you please show the full track trace of the Log message (copy and paste the full exception log message here)?

  • sxweb ответили на это сообщение.

    Harald Hello. It happens in runtime. I can select this animation in inspector but script can't find it when i call it.https://disk.yandex.ru/i/Jdgh-GO0nYcyew

    ArgumentException: Animation not found: 
    Parameter name: animationName
    Spine.AnimationState.SetAnimation (System.Int32 trackIndex, System.String animationName, System.Boolean loop) (at Assets/Spine/Runtime/spine-csharp/AnimationState.cs:677)
    Arrow.OnDamageDeal () (at Assets/Scripts/Game/Arrow.cs:41)
    Projectile.OnTriggerEnter2D (UnityEngine.Collider2D other) (at Assets/Scripts/Game/Player/Weapons/Projectile.cs:21)

    @sxweb Thanks for the additional info. Are you sure that _spineAnimator is the same SkeletonAnimation GameObject that [SpineAnimation] public string _onDeadAnimation; populates its list with? By that I mean that it might be that the list is from another SkeletonAnimation component, listing other animations, and then setting this animation at _spineAnimator leads to a mismatch.

    If _spineAnimator for sure contains this named animation, could you please send us a minimal Unity project that still shows this issue? You can send as a zip file to contact@esotericsoftware.com, briefly mentioning this forum thread URL so that we know the context.

    • sxweb ответили на это сообщение.
    • sxweb оценил это.

      Harald You're right, thank you, it was my mistake. The script of me is on the parent component, and the Spine animation object is on the child. However, for some reason, in the public string _onDeadAnimation; field, I could choose the animation name of the child object. Thanks a lot for your help.

      @sxweb Glad to hear you're figured it out, thanks for getting back to us.

      • sxweb оценил это.