How to get info about completion of one of my animations?

Hey, I have monster named Fungant in my 2D platform game.
It can hide as mushroom and rise to his normal form.
I try to handle it in code, but I don’t know how to get information about finished animation (without it, animation of rising and hiding always was skipped).
I think the point there is to get info about complete of the one of two animations - Rise and Hide.
There is current code:

if (
            fungantAnimator.GetCurrentAnimatorStateInfo(0).IsName("Fungant Rise")
        )
        {
            fungantAnimator.SetBool("isRising", false);
            isRisen = true;


            fungantRigidbody.velocity = new Vector2(
            walkSpeed * Mathf.Sign(
                player.transform.position.x - transform.position.x),
                fungantRigidbody.velocity.y
            );
        }

        if (fungantAnimator.GetCurrentAnimatorStateInfo(0).IsName("Fungant Hide"))
        {
            fungantAnimator.SetBool("isHiding", false);
            isRisen = false;
        }

Here are two options to look into:

  • at the Animator level there are StateMachineBehaviours

  • at the Animation level there are AnimationEvents

Beyond that you can of course always just use a timer and match the play time (yuck).

I heard about this two options, but im learning unity and don’t have any idea how to access them from code.

StateMachineBehavoiur attempt

I would like to get StateMachineBehaviour, but how to get it?
No idea how to process this further.

AnimationEvents

Tried to do with animation event but every tutorial have list of functions to choose (looks easy), but in my Unity I can write Function, Float, Int, String or select object (what I should do?).

I decided to write test() function with Debug only inside, and create AnimationEvents with written “test()” in function field, but nothing happens.

Same as above, no more ideas how to process this further.

Well we know they didn’t stop working, so make a blank project, go back to the manual for these two systems, set up the simplest tiniest animation and state machine and get it working.

I mean what else can you do? I guess use the timer approach, but what a lot of future maintenance and hassle that would be.