Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Synchronizing tile updates and animations

Discussion in '2D' started by MarketingMark, Sep 21, 2019.

  1. MarketingMark

    MarketingMark

    Joined:
    Nov 21, 2018
    Posts:
    2
    I have set up a tilemap with a number of tiles. Each of these tiles has a reference to an animated version of the tile containing 12 frames, and each animated tile has a reference back to the original tile. I can swap out these tiles in a tilemap on screen via a separate Monobehaviour script I have written.

    All of my (tile) animations run at 12 fps. I would like to be able to switch the tiles exactly in sync with the animations. More specifically, the goal is to switch out the static tile with an animated tile at a given frame and then switch it back as soon as the animation is over.

    I have no idea how this is most effectively done. Is it possible to keep an invokeRepeat or coroutine synchronized with the tile animation? Is putting the code in FixedUpdate possible or recommended?

    Thanks in advance for any help provided (˸
     
    Last edited: Sep 21, 2019