Animated Tiles

amaranth
Member
Registered: 2014-03-13
Posts: 17

Topic

Would love to see an easy way to add animated tiles. Animated tiles could be used for things like water, lava, etc. I'm working on a 2D game, and a cell-based solution would be nice.

Lea Hayes
Rotorz Limited
From: United Kingdom
Registered: 2014-03-04
Posts: 638

Response 1

Hey there!

For animated tiles I would suggest using Unity sprites with oriented brushes since the performance is pretty good.

To get your animated sprite to fit perfectly snug within a tile system cell you just need to set the "Pixels to Units" property of your sprite to match its dimensions.

I posted a little demonstration video recently which shows a happy animated bouncing block (approximately 1:05 in video):
http://forum.rotorz.com/viewtopic.php?id=92

Is this the sort of thing that you are after?

amaranth
Member
Registered: 2014-03-13
Posts: 17

Response 2

I've watched the video, but I think there is a lot of room to optimize this process. For example, to create four tileset brushes, it took 30 seconds in the video. To create an animated tile, it took 2 minutes, the creation of a custom script, and several steps in various locations in the Unity editor. For sprites, the method in the video makes sense because you need a custom workflow for the sprite's graphics and actions. For simple animations, though, it's quite a bit of work.

Here is a potential workflow for an animated brush:

1. Open RTS: Brushes tab
2. Click Create...
3. In the Create Brush / Tileset menu opens, select Animate
4. A window similar to the RTS: Designer opens, except that there is only one row.
5. You drag the tiles you want to be part of the animation into the window.
6. Set animation speed.
7. Save.

Last edited by amaranth (2014-09-24 03:08:49)

Lea Hayes
Rotorz Limited
From: United Kingdom
Registered: 2014-03-04
Posts: 638

Response 3

amaranth wrote:

To create an animated tile, it took 2 minutes, the creation of a custom script, and several steps in various locations in the Unity editor.

In the case of this video a custom script was added to the bouncy block but only to handle interaction with the player. The actual sprite animation was created in a matter of seconds using drag and drop.

A simple animated tile shouldn't take much more than 15-20 seconds to create:

The speed of the animation can be adjusted in the standard Unity way as desired. Plus you can take full advantage of Mechanim states, triggers, variables and animation events.

amaranth
Member
Registered: 2014-03-13
Posts: 17

Response 4

Nice, but what if I would like to use several tiles in a tileset? Would I need to cut each of them out into separate files? For example, if I go back to the animated water tiles... To create animated water in a top-down RPG will probably require 16 tiles. I like to keep tiles in tilesets. If each tile needs 4 frames of animation, this is a lot of tiles to keep track of...

Still wish this would be added.

Last edited by amaranth (2014-09-24 00:32:08)

Lea Hayes
Rotorz Limited
From: United Kingdom
Registered: 2014-03-04
Posts: 638

Response 5

The fundamental difference between tiles and animated sprites is that a tile remains mostly static whilst an animated sprite updates frequently. So it is also beneficial performance-wise to use these as separate systems.

Unity's sprite editor allows you to cut a sprite sheet into multiple sprites which can then be animated in the same way. I recorded a little demonstration for you:

Here is the sprite sheet:
example-sprite-sheet.png

If you are using the sprite packer tool (again provided with Unity Pro) then your sprite sheet doesn't even need to be square or power-of-two. You can even compensate for edge bleeding.

Last edited by Lea Hayes (2014-09-24 01:15:47)

amaranth
Member
Registered: 2014-03-13
Posts: 17

Response 6

Nice!