Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Syncing VFX to Animation

Discussion in 'Animation' started by ggreer, Aug 18, 2022.

  1. ggreer

    ggreer

    Joined:
    May 22, 2019
    Posts:
    4
    Hi everyone, I'm wondering what's the best way to sync particle vfx to animations. Initially I was using an animation events setup, where we would just instantiate a vfx prefab on certain frames, but we're now pooling the vfx prefabs, and animation events don't seem to have an easy solution for specifying which gameobject we're targeting. Our approach now is to create a simple state machine for each vfx that mirrors the players state machine, and control the activation using state machine behaviors but I'm not sure what might be the best way to adjust the timings. My current approach is to create a main monobehavior to contain some coroutines ("start vfx after x seconds", "stop vfx after y seconds" for example) and then trigger those coroutines in state machine behaviors, but maybe there's a more efficient way I'm not thinking of?

    TIA!