0
\$\begingroup\$

I am beginner in Unity and I have created tilemap using new tilemap system in unity which looks like this:

enter image description here

I created a script that lets me swap tiles. First I click on some tile and than I choose second tile, after I click second time, tiles swap their positions. Which will than look like this:

enter image description here

How can I apply some animation to this process? Seems like I have no control over tile object as it is. I can only access TileBase which as I understand is not all information about tile. I can't create any animator controller or access its transform object. I want to add some custom animation when tiles swap their places. Thank you!

\$\endgroup\$
  • 1
    \$\begingroup\$ You may want to consider that the things that animate don't have to be the literal tiles you're swapping. Game development is often about trickery and sleight of hand. You could, for instance, change both tiles to blank squares, and in the same frame spawn two sprite renderers at the tiles' exact locations, bearing their tile graphic as a sprite. Then you can animate those sprite renderers moving or changing in any way you want, then once the animation is done, destroy the sprite renderers and set the tiles to their post-swap state. It still looks to the player like the tiles animated. \$\endgroup\$ – DMGregory Jan 13 at 23:44
  • \$\begingroup\$ @DMGregory thank you, that sounds interesting, i will try it. \$\endgroup\$ – Taras Fityo Jan 15 at 12:50
0
\$\begingroup\$

You can possibly achieve tile animation by using unity's "AnimatedTile" Script which comes with the 2d-Extra repo. This video from unity discusses how to use the AnimatedTile Script. I hope it helps.

https://github.com/Unity-Technologies/2d-extras/tree/4eff73f468142907629f09b4a88bceb2f0148dc5/Runtime/Tiles/AnimatedTile

|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ i saw video about animated tiles and i thought that it just makes one tile animated, basically waterfall animation is a list of sprites that play in some order, while i need little bit another behavior, but thank you, i will check it. \$\endgroup\$ – Taras Fityo Jan 15 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.