Condition based on playtime of Animation

Hello,

I’m pretty new to coding and I’m trying to figure out a way to set a condition to trigger a cloned object based on the current playtime of the Animation.

I can get the length of the clip, but how do I read in real time the playtime so I can set the condition as below? obviously the code below fails as its testing the total length on not playtime.

public AnimationClip animPlantShootClip; // I set the animation clip from the inspector

void Update()
    {
        animShootLength = animPlantShootClip.length;

        if (isPlayerInShootRadius)
        {
            Animator.Play(PLANT_SHOOT);

            if (animShootLength == 0.4f)
            {
                print("Works");
                Shoot();
            }
        }
    }
1 Like

Thanks, but I’m having an issue with that…

When I use the line below:
public Animation anim;

It won’t let me add the Animation from the inspector. Thats why I initally used the AnimationClip.

Anyways I ended up creating timer variables, which works for now, but would be more percise based on playtime during runtime.