Search Unity

Resolved Animate Tile on Collision

Discussion in '2D' started by CBuckington, Oct 2, 2021.

  1. CBuckington

    CBuckington

    Joined:
    Sep 28, 2020
    Posts:
    20
    Hey guys I think I am stuck.

    I need a tile in my tilemap to play an animation when the character walks over it. Basically like the animation of walking through tall grass in Pokemon or Legend of Zelda.

    At first I thought this would be possible by assigning a script to the tile but that does not seem to work at all. I failed at using the scriptable object approach since all the tiles share one scriptable object and got animated at the same time.
    Animated tiles seem to always be animated, which is of no use to me.
    My last idea was to manually put an empty gameobject above the tile that has a collider attached to it. When this collider gets triggered I get the coordinates of my grass tile via screen coordinates and change the sprite basically "simulating" the animation. Doing this once or twice is fine, but having to manually put colliders everywhere does in fact not seem like the right way to do it. Is there any way to connect them up or something?

    So my question is the following:
    How do I properly set up tiles that play an animation under a specific condition, like an intersecting collider?

    thanks in advance!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    Are you perhaps looking for a Scriptable Tile?