GetCurrentAnimatorStateInfo(0).IsName

Hello All

I’ve got a problem with GetCurrentAnimatorStateInfo(0).IsName at the moment
if(anim_Animator.GetCurrentAnimatorStateInfo(0).IsName(“LockedLevel2”))
{
Destroy (gameObject, this.GetComponent().GetCurrentAnimatorStateInfo(0).length + delay);
}
Now where it has “LockedLevel2” this 2 can be any int upto 20 seeing a as I have 20 levels, so how should I go about implementing this so it could be LockedLevel with any number, up to 20.

Thanks for any help

Make an array with all the LockedLevels

string[] lockedLevels = {"LockedLevel1", "LockedLevel2", "LockedLevel3", "LockedLevel4", "LockedLevel5", "LockedLevel6", "LockedLevel7", "LockedLevel8", "LockedLevel9", "LockedLevel10", "LockedLevel11", "LockedLevel12", "LockedLevel13", "LockedLevel14", "LockedLevel15", "LockedLevel16", "LockedLevel17", "LockedLevel18", "LockedLevel19", "LockedLevel20"};

Then:

    foreach (string x in lockedLevels)
    {
        if (anim_Animator.GetCurrentAnimatorStateInfo(0).IsName(x))
        {
            Destroy(gameObject); //you're going to destroy the game object, so put the //GetCurrentAnimatorStateInfo in another line
        }
    }

Thanks that did the trick.